|
|
@@ -33,6 +33,7 @@ import com.atmob.keyboard_android.util.KeyboardHolder
|
|
|
import com.atmob.keyboard_android.util.LogUtil
|
|
|
import com.atmob.keyboard_android.util.UserInfoHelper
|
|
|
import com.atmob.keyboard_android.util.bridge.FlutterBridgeManager
|
|
|
+import com.atmob.keyboard_android.util.bridge.model.resp.CharacterListResp.CharacterInfo
|
|
|
import com.atmob.keyboard_android.util.recyclerview.GridDivider
|
|
|
import com.atmob.keyboard_android.widget.LongTouchContainer
|
|
|
import com.blankj.utilcode.util.ConvertUtils
|
|
|
@@ -234,6 +235,10 @@ class AiKeyboardCommonPanelComponent @JvmOverloads constructor(
|
|
|
*/
|
|
|
private fun setupViewModel() {
|
|
|
KeyboardHolder.getKeyboardService()?.run {
|
|
|
+ // 监听人设列表更新
|
|
|
+ getKeyboardViewModel().characterList.observe(getLifecycleOwner()) {
|
|
|
+ renderList(it)
|
|
|
+ }
|
|
|
// 监听帮助模式更新,切换键盘
|
|
|
getKeyboardViewModel().helpMode.observe(getLifecycleOwner()) { newMode ->
|
|
|
// 隐藏AI生成内容面板
|
|
|
@@ -294,27 +299,33 @@ class AiKeyboardCommonPanelComponent @JvmOverloads constructor(
|
|
|
@SuppressLint("NotifyDataSetChanged")
|
|
|
private fun loadKeyList() {
|
|
|
KeyboardHolder.getKeyboardService()?.getKeyboardViewModel()
|
|
|
- ?.getCharacterList(onSuccess = {
|
|
|
- val newList = (it.characterInfos ?: listOf()).map {
|
|
|
- AiKeyboardKeyModel(
|
|
|
- // 显示的文本 = 表情 + 名字
|
|
|
- text = "${it.emoji} ${it.name}",
|
|
|
- // 拓展字段,存储人设Id
|
|
|
- payload = it.id,
|
|
|
- // 是否需要VIP
|
|
|
- isVip = it.isVip
|
|
|
- )
|
|
|
- }
|
|
|
- mKeyListItems.clear()
|
|
|
- // 添加按键列表
|
|
|
- mKeyListItems.addAll(newList)
|
|
|
- // 添加人设按钮
|
|
|
- mKeyListItems.add(AddCharacterModel())
|
|
|
- mKeyListAdapter.notifyDataSetChanged()
|
|
|
+ ?.getCharacterList()
|
|
|
+ }
|
|
|
|
|
|
- // 显示键盘引导页
|
|
|
- tryShowKeyboardGuide()
|
|
|
- })
|
|
|
+ /**
|
|
|
+ * 根据数据,渲染列表
|
|
|
+ */
|
|
|
+ @SuppressLint("NotifyDataSetChanged")
|
|
|
+ private fun renderList(characterList: List<CharacterInfo>) {
|
|
|
+ val newList = characterList.map {
|
|
|
+ AiKeyboardKeyModel(
|
|
|
+ // 显示的文本 = 表情 + 名字
|
|
|
+ text = "${it.emoji} ${it.name}",
|
|
|
+ // 拓展字段,存储人设Id
|
|
|
+ payload = it.id,
|
|
|
+ // 是否需要VIP
|
|
|
+ isVip = it.isVip
|
|
|
+ )
|
|
|
+ }
|
|
|
+ mKeyListItems.clear()
|
|
|
+ // 添加按键列表
|
|
|
+ mKeyListItems.addAll(newList)
|
|
|
+ // 添加人设按钮
|
|
|
+ mKeyListItems.add(AddCharacterModel())
|
|
|
+ mKeyListAdapter.notifyDataSetChanged()
|
|
|
+
|
|
|
+ // 显示键盘引导页
|
|
|
+ tryShowKeyboardGuide()
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -353,12 +364,15 @@ class AiKeyboardCommonPanelComponent @JvmOverloads constructor(
|
|
|
// 找到目标条目,则显示引导
|
|
|
if (viewHolder != null) {
|
|
|
val itemView = viewHolder.itemView
|
|
|
- KeyboardGuideDialogUtil.showGuideDialog(itemView, itemData, object : IKeyboardGuideComponent.OnActionCallback {
|
|
|
- override fun onFinishGuide() {
|
|
|
- mKeyboardGuideShowing = false
|
|
|
- KeyboardGuideRecordUtil.setFirstShowKeyboardGuide(false)
|
|
|
- }
|
|
|
- })
|
|
|
+ KeyboardGuideDialogUtil.showGuideDialog(
|
|
|
+ itemView,
|
|
|
+ itemData,
|
|
|
+ object : IKeyboardGuideComponent.OnActionCallback {
|
|
|
+ override fun onFinishGuide() {
|
|
|
+ mKeyboardGuideShowing = false
|
|
|
+ KeyboardGuideRecordUtil.setFirstShowKeyboardGuide(false)
|
|
|
+ }
|
|
|
+ })
|
|
|
mKeyboardGuideShowing = true
|
|
|
}
|
|
|
}
|