表盘:修复自定义表盘更新刷新异常
authorCaisking <3449750381@qq.com>
Tue, 22 Oct 2024 06:42:41 +0000 (14:42 +0800)
committerCaisking <3449750381@qq.com>
Tue, 22 Oct 2024 06:42:41 +0000 (14:42 +0800)
code/sdk/application/wearable/fd230app/nativeui/clock/src/MainClockView.cpp
code/sdk/application/wearable/fd230app/nativeui/set_dial/src/SetDialModel.cpp

index e19938c..39c387a 100644 (file)
@@ -176,8 +176,12 @@ namespace OHOS
         return true;
     }
     /*初始化表盘背景*/
-    bool MainClockView::InitBackground(const char *filename)
-    {
+    bool MainClockView::InitBackground(const char *filename) {
+
+        if (filename == nullptr) {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "filename is null");
+            return false;
+        }
         curFace = new UIImageView();
         if (curFace == nullptr)
         {
@@ -191,7 +195,7 @@ namespace OHOS
         if (image == nullptr)
         {
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "LoadAllDialFromRam loadimage %s fail",
-                          filename);
+                            filename);
             curFace->SetSrc(DEFAULT_DIALBACK_PATH);
             Add(curFace);
             return false;
index 825b108..67656e2 100644 (file)
@@ -408,8 +408,8 @@ void SetDialModel::UpdateDialSetting(uint16_t ID) {
   if (ID <= 4) {
     ID++;
   }
-  /*判断是否为当前表盘*/
-  if (currentDialID == ID) {
+  /*判断是否为当前表盘 如果是自定义表盘 需要更新*/
+  if (currentDialID == ID && ID >=5) {
     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
                   "UpdateDialSetting: Current dial cannot be updated");
     return;
@@ -690,7 +690,8 @@ void SetDialModel::LoadAllDialFromRam() {
     WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Processing Dial ID %u: Name: %s", i,
                   dialInfo.dialName.c_str());
 
-    // 加载图像资源
+    // 加载图像资源 (因为自定义表盘可能更新。需要先对其进行卸载)
+    ImageCacheManager::GetInstance().UnloadSingleRes(info->dialImg);
     ImageInfo *imageInfo =
         ImageCacheManager::GetInstance().LoadSingleRes(info->dialImg, false);
     if (imageInfo == nullptr) {