Procházet zdrojové kódy

[feat]键盘插件,帮聊,不需要显示Loading,并处理点击按键后,会马上清空输入框的问题

hezihao před 8 měsíci
rodič
revize
cabc7043cb

+ 5 - 0
plugins/keyboard_android/android/src/main/kotlin/com/atmob/keyboard_android/component/child/impl/AiKeyboardCommonPanelComponent.kt

@@ -83,6 +83,8 @@ class AiKeyboardCommonPanelComponent @JvmOverloads constructor(
     override fun bindView(view: View) {
         mWaitLoadingController =
             WaitLoadingController(context, KeyboardHolder.getKeyboardService()?.getKeyboardWindow())
+        // 禁用Loading
+        mWaitLoadingController.setEnable(false)
 
         setupKeyList()
         setupActionBtn()
@@ -219,6 +221,9 @@ class AiKeyboardCommonPanelComponent @JvmOverloads constructor(
             }
             // 监听生成的Ai内容
             getKeyboardViewModel().chatSuperReplyResult.observe(getLifecycleOwner()) {
+                if (it.isBlank()) {
+                    return@observe
+                }
                 // 生成的内容,直接添加到输入框
                 KeyboardHolder.getKeyboardService()?.asInputMethodService()?.let { service ->
                     InputMethodUtil.inputText(service.currentInputConnection, it)

+ 1 - 0
plugins/keyboard_android/android/src/main/kotlin/com/atmob/keyboard_android/component/child/impl/AiKeyboardProloguePanelComponent.kt

@@ -93,6 +93,7 @@ class AiKeyboardProloguePanelComponent @JvmOverloads constructor(
     override fun bindView(view: View) {
         mWaitLoadingController =
             WaitLoadingController(context, KeyboardHolder.getKeyboardService()?.getKeyboardWindow())
+        mWaitLoadingController.setEnable(true)
 
         setupTabBar()
         setupKeyList()

+ 15 - 0
plugins/keyboard_android/android/src/main/kotlin/com/atmob/keyboard_android/util/loading/WaitLoadingController.java

@@ -23,6 +23,11 @@ public class WaitLoadingController {
      */
     private long showTime;
 
+    /**
+     * 是否可用
+     */
+    private boolean isEnable = true;
+
     public WaitLoadingController(Context context, Window hostWindow) {
         mMainHandler = new Handler(Looper.getMainLooper());
         setup(context, hostWindow);
@@ -34,8 +39,18 @@ public class WaitLoadingController {
         });
     }
 
+    /**
+     * 设置是否可用
+     */
+    public void setEnable(boolean enable) {
+        this.isEnable = enable;
+    }
+
     public void showWait() {
         ensureMainThreadRun(() -> {
+            if (!isEnable) {
+                return;
+            }
             if (vLoadingDialog != null && !vLoadingDialog.isShowing()) {
                 showTime = System.currentTimeMillis();
                 vLoadingDialog.show();