|
|
@@ -4,6 +4,7 @@ import android.annotation.SuppressLint
|
|
|
import android.content.Context
|
|
|
import android.util.AttributeSet
|
|
|
import android.view.View
|
|
|
+import androidx.recyclerview.widget.GridLayoutManager
|
|
|
import androidx.recyclerview.widget.RecyclerView
|
|
|
import com.atmob.keyboard_android.R
|
|
|
import com.atmob.keyboard_android.component.base.BaseUIComponent
|
|
|
@@ -128,29 +129,39 @@ class AiKeyboardCommonPanelComponent @JvmOverloads constructor(
|
|
|
FlutterBridgeManager.jump2CharacterMarketPage()
|
|
|
})
|
|
|
}
|
|
|
- // 水平分页布局管理器
|
|
|
- layoutManager = PagerGridLayoutManager(
|
|
|
- Constants.AI_KEYBOARD_KEY_LIST_SPAN_COUNT,
|
|
|
- Constants.AI_KEYBOARD_KEY_LIST_SPAN_COUNT,
|
|
|
- PagerGridLayoutManager.HORIZONTAL
|
|
|
- ).apply {
|
|
|
- // 设置滚动监听
|
|
|
- setPageListener(object : PageListener {
|
|
|
- override fun onPageSizeChanged(pageSize: Int) {
|
|
|
- // 当总页数确定时的回调
|
|
|
- }
|
|
|
+ if (Constants.AI_KEYBOARD_KEY_LIST_PAGE_ENABLE) {
|
|
|
+ // 分页布局管理器
|
|
|
+ layoutManager = PagerGridLayoutManager(
|
|
|
+ Constants.AI_KEYBOARD_KEY_LIST_SPAN_COUNT,
|
|
|
+ Constants.AI_KEYBOARD_KEY_LIST_SPAN_COUNT,
|
|
|
+ PagerGridLayoutManager.HORIZONTAL
|
|
|
+ ).apply {
|
|
|
+ // 设置滚动监听
|
|
|
+ setPageListener(object : PageListener {
|
|
|
+ override fun onPageSizeChanged(pageSize: Int) {
|
|
|
+ // 当总页数确定时的回调
|
|
|
+ }
|
|
|
|
|
|
- override fun onPageSelect(pageIndex: Int) {
|
|
|
- // 当页面被选中时的回调(从 0 开始)
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- // 设置滚动辅助工具
|
|
|
- val pageSnapHelper = PagerGridSnapHelper().apply {
|
|
|
- // 设置滚动阀值
|
|
|
- setFlingThreshold(minFlingVelocity)
|
|
|
+ override fun onPageSelect(pageIndex: Int) {
|
|
|
+ // 当页面被选中时的回调(从 0 开始)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ // 设置滚动辅助工具
|
|
|
+ val pageSnapHelper = PagerGridSnapHelper().apply {
|
|
|
+ // 设置滚动阀值
|
|
|
+ setFlingThreshold(minFlingVelocity)
|
|
|
+ }
|
|
|
+ pageSnapHelper.attachToRecyclerView(this)
|
|
|
+ } else {
|
|
|
+ // 不分页,只网格
|
|
|
+ layoutManager = GridLayoutManager(
|
|
|
+ context,
|
|
|
+ Constants.AI_KEYBOARD_KEY_LIST_SPAN_COUNT,
|
|
|
+ GridLayoutManager.VERTICAL,
|
|
|
+ false
|
|
|
+ )
|
|
|
}
|
|
|
- pageSnapHelper.attachToRecyclerView(this)
|
|
|
// 设置适配器
|
|
|
adapter = mKeyListAdapter
|
|
|
// 添加分割线
|