增加选择表情切换
authorxue <2144439972@qq.com>
Wed, 24 Sep 2025 12:22:37 +0000 (20:22 +0800)
committerxue <2144439972@qq.com>
Wed, 24 Sep 2025 12:22:37 +0000 (20:22 +0800)
code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdModel.h
code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdModel.cpp

index 0d156a7..2c6005f 100644 (file)
@@ -165,6 +165,9 @@ namespace OHOS
         
         // 任务提醒处理函数
         void HandleTaskReminder(const char* scheduleName);
+        
+        // 表情切换函数
+        bool SwitchExpression(const char* eyeShape, const char* eyeColor);
 
     private:
         ThunderBirdModel();
index 1c0293e..e5705a6 100644 (file)
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Processing task reminder: %s", scheduleName);
         }
     }
+    bool ThunderBirdModel::SwitchExpression(const char* eyeShape, const char* eyeColor)
+   {
+       // 参数验证
+       if (eyeShape == nullptr || eyeColor == nullptr) {
+           return false;
+       }
+       
+       // 构建表情文件路径:/user/res/video/CloseEyes/{eyeShape}/{eyeColor}.mp4
+       std::string expressionPath = "/user/res/video/CloseEyes/";
+       expressionPath += eyeShape;
+       expressionPath += "/";
+       expressionPath += eyeColor;
+       expressionPath += ".mp4";
+       
+       // 通过图形服务调用 ThunderBirdMainView 的 SwitchVideo 函数
+       bool result = false;
+       GraphicService::GetInstance()->PostGraphicEvent(
+           [expressionPath, &result]() {
+               if (ThunderBirdMainView::GetInstance()) {
+                   result = ThunderBirdMainView::GetInstance()->SwitchVideo(expressionPath.c_str());
+               }
+           });
+       
+       return result;
+   }
 
  }
  
\ No newline at end of file