优化角色切换逻辑,修复绑定后闪屏Bug
authorxue <2144439972@qq.com>
Mon, 3 Nov 2025 07:39:57 +0000 (15:39 +0800)
committerxue <2144439972@qq.com>
Mon, 3 Nov 2025 07:39:57 +0000 (15:39 +0800)
code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdModel.h
code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdModel.cpp

index 0f82ff7..474ada2 100644 (file)
@@ -331,6 +331,14 @@ namespace OHOS
         std::string screenImage_;
         bool screenImageAsEmoji_{false};
 
+        // 上次角色配置
+        std::string last_eyesShape_;
+        std::string last_hairColor_;
+        std::string last_eyesColor_;
+        std::string last_hairStyle_;
+        std::string last_screenImage_;
+        bool last_screenImageAsEmoji_{false};
+
         // 对话状态显示相关变量
         std::string m_currentExpression;    // 当前表情状态
         std::string m_currentStatusText;    // 当前状态文本
index a4c38ff..bd9ca35 100644 (file)
          uapi_setScreenDuration(30000);//自动息屏30秒
          Readlocalconfig();
 
+         last_eyesShape_ = eyesShape_;
+         last_hairColor_ = hairColor_;
+         last_eyesColor_ = eyesColor_;
+         last_hairStyle_ = hairStyle_;
+         last_screenImageAsEmoji_ = screenImageAsEmoji_;
+
          printf("  eyesShape_ = %s", eyesShape_.c_str());
          printf("  hairColor_ = %s", hairColor_.c_str());
          printf("  eyesColor_ = %s", eyesColor_.c_str());
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "  hairStyle: %s", hairStyle ? hairStyle : "null");
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "  screenImageAsEmoji: %d", screenImageAsEmoji);
         
-        eyesShape_ = eyesShape;
-        hairColor_ = hairColor;
-        eyesColor_ = eyesColor;
-        hairStyle_ = hairStyle;
-        screenImageAsEmoji_ = screenImageAsEmoji;
+        if(eyesShape == last_eyesShape_ && hairColor == last_hairColor_ && eyesColor == last_eyesColor_ && hairStyle == last_hairStyle_ && screenImageAsEmoji == last_screenImageAsEmoji_)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::HandleCharacterConfigChange: 角色配置没有变化,不进行处理");
+            return;
+        }
+        //更新上次角色配置信息
+        last_eyesShape_ = eyesShape_;
+        last_hairColor_ = hairColor_;
+        last_eyesColor_ = eyesColor_;
+        last_hairStyle_ = hairStyle_;
+        last_screenImageAsEmoji_ = screenImageAsEmoji_;
+        
         
 
         // 这里可以添加角色配置更改的具体处理逻辑
                 ThunderBirdMainView::GetInstance()->OpenScreenImageModel();
             }
         }
+        //更新角色配置信息
+        eyesShape_ = eyesShape;
+        hairColor_ = hairColor;
+        eyesColor_ = eyesColor;
+        hairStyle_ = hairStyle;
+        screenImageAsEmoji_ = screenImageAsEmoji;
 
         // SaveCharacterConfig(characterId, characterName, eyesShape, hairColor, eyesColor, hairStyle, screenImageAsEmoji);
     }