Merge #652 into sdk602patch0626 from refs/changes/652/head
author袁清梦 <3449750381@qq.com>
Tue, 6 Aug 2024 10:58:12 +0000 (10:58 +0000)
committersnickersun@163.com <accounts_62b90f7fcf51ade33b6f628e@mail.teambition.com>
Tue, 6 Aug 2024 10:58:12 +0000 (10:58 +0000)
Code review from 袁清梦

* refs/changes/652/head: (8 commits squashed)

  - 屏蔽血氧监测过程中的数值显示

  - Merge branch &#39;sdk602patch0626&#39; of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626

  - 增加表盘星期string类model

  - 增加血氧&amp;心率数据重启之后恢复

  - 筛选表盘血氧无效数据

  - Merge branch &#39;sdk602patch0626&#39; of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626

  - Merge branch &#39;sdk602patch0626&#39; of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626

  - 修复星期显示

Signed-off-by: Caisking <3449750381@qq.com>
Reviewed-by: snickersun@163.com <accounts_62b90f7fcf51ade33b6f628e@mail.teambition.com>
Merged-by: snickersun@163.com <accounts_62b90f7fcf51ade33b6f628e@mail.teambition.com>
link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/652
code/sdk/application/wearable/fd230app/CMakeLists.txt
code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenModel.cpp
code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartModel.cpp
code/sdk/application/wearable/fd230app/nativeui/main/include/dial/DialDataBase.h
code/sdk/application/wearable/fd230app/nativeui/main/include/dial/DialModelWeekStr.h [new file with mode: 0644]
code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialLabelView.cpp
code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelSPO2.cpp
code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelWeekStr.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialViewGroup.cpp
code/sdk/application/wearable/fd230app/nativeui/main/src/dial/ModelDialDataFactory.cpp
code/sdk/application/wearable/fd230app/nativeui/main/src/dial/parser/DialBinParser.cpp

index a09ea58..da16ed3 100644 (file)
@@ -162,6 +162,8 @@ set(SOURCES
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/main/src/dial/DialModelSPO2.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/main/src/dial/DialModelDistance.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/main/src/dial/DialModelCalorie.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/main/src/dial/DialModelWeekStr.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/main/src/dial/DialModelWeather.cpp
 
     #exception handling
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/heart_blood/CheckAbnormalView.cpp
index 73ee6de..105c0fe 100644 (file)
@@ -6,6 +6,7 @@
 #include "heart_blood/health_service/health_service.h"
 #include "custom_utils.h"
 extern "C" errcode_t uapi_get_timestamp_ms(uint32_t *tm);
+
 #include "custom_utils.h"
 #include "ppg_service.h"
 #include "ConfigModel.h"
@@ -27,6 +28,8 @@ namespace OHOS
         {
             currentspo2 = data->SPO2;
             timestamp_ms = data->timestamp;
+            // 更新表盘血氧数据
+            DialModelSPO2::GetInstance()->UpdateSPO2(currentspo2);
             delete data;
         }
         else
index 438cea6..fca77f3 100644 (file)
@@ -8,6 +8,7 @@
 #include "heartrate/include/HeartRateView.h"\r
 #include "heartrate/include/HeartDetectionPresenter.h"\r
 #include "heartrate/include/HeartResultPresenter.h"\r
+#include "DialModelHeartRate.h"\r
 \r
 #include <iostream>\r
 #include <random>\r
@@ -194,12 +195,15 @@ namespace OHOS
 \r
     HeartModel::HeartModel()\r
     {\r
+        /*初始化读取文件*/\r
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "HeartModel::HeartModel()");\r
         HeartRateData *data = HealthService::GetInstance()->ReadHeartRateData();\r
         if (data != nullptr)\r
         {\r
             currentheart = data->Heart;\r
             timestamp_ms = data->timestamp;\r
+            // 更新表盘心率数据\r
+            DialModelHeartRate::GetInstance()->UpdateHeartRate(currentheart);\r
             delete data;\r
         }\r
         else\r
index 914dc80..2a52f5b 100644 (file)
@@ -1,22 +1,4 @@
-/***
- * @Date: 2024-04-15 10:55:58
- * @LastEditors: Caisking 3449750381@qq.com
- * @LastEditTime: 2024-07-31 17:52:21
- * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/main/include/dial/DialDataBase.h
- */
-/***
- * @Date: 2024-04-15 10:55:58
- * @LastEditors: Caisking 3449750381@qq.com
- * @LastEditTime: 2024-04-27 11:16:57
- * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/main/include/dial/DialDataBase.h
- */
 
-/*
- * Copyright (c) CompanyNameMagicTag 2023. All rights reserved.
- * Description: DialBaseModel
- * Author:
- * Create: 2023-12
- */
 
 #ifndef DIAL_DATA_BASE_H
 #define DIAL_DATA_BASE_H
@@ -50,11 +32,12 @@ enum class DialDataType
     DATA_TYPE_DISTANCE,      // 运动距离
     DATA_TYPE_WEATHER,       // 天气
     DATA_TYPE_POWER_STANDBY, // 备用电量数据类型
-
+  
     DATA_TYPE_MULTI_FLOAT_BASE = 0x2fff, // 多个浮点数据类型基值
 
-    DATA_TYPE_TEXT_BASE = 0x4fff, // 文本数据类型基值
+    DATA_TYPE_TEXT_BASE = 0x4fff,        // 文本数据类型基值
+    DATA_TYPE_WEEK_STR,                  // 星期(string)
 
-    DATA_TYPE_MAX = 0x7fff, // 数据类型的最大值
+    DATA_TYPE_MAX = 0x7fff,              // 数据类型的最大值
 };
 #endif
diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/include/dial/DialModelWeekStr.h b/code/sdk/application/wearable/fd230app/nativeui/main/include/dial/DialModelWeekStr.h
new file mode 100644 (file)
index 0000000..7b7cffe
--- /dev/null
@@ -0,0 +1,28 @@
+
+#ifndef DIAL_MODEL_PATH_H
+#define DIAL_MODEL_PATH_H
+
+#include "DialBaseModel.h"
+#include <cstdint>
+#include <string>
+
+namespace OHOS
+{
+    class DialModelWeekStr : public DialBaseModel
+    {
+    public:
+        DialModelWeekStr() {}
+        virtual ~DialModelWeekStr() {}
+        static DialModelWeekStr *GetInstance()
+        {
+            static DialModelWeekStr instance;
+            return &instance;
+        }
+        bool GetDialTextData(DialDataType &type, std::string *&out, int16_t &strNum) override;
+        void UpdateWeekStr(const std::string *&dialWeekStr);
+
+    private:
+        std::string dialWeekStr_;
+    };
+}
+#endif
\ No newline at end of file
index 9216d67..dc84cb2 100644 (file)
@@ -81,40 +81,48 @@ namespace OHOS
 
     void DialLabelView::HandleTextData(const std::string *data, uint16_t num)
     {
-        char tempBuf[MAX_BUF_SIZE] = {0};
-        if (num == 1)
+        if (num == 0 || data == nullptr)
         {
-            if (snprintf_s(tempBuf, MAX_BUF_SIZE, MAX_BUF_SIZE - 1, text_, data[0].c_str()) < 0)
-            {
-                GRAPHIC_LOGE("snprintf_s failed.\n");
-                return;
-            }
+            GRAPHIC_LOGE("Invalid data or num.");
+            return;
         }
-        else if (num == 2)
-        { // 2: wildcard cnt
-            if (snprintf_s(tempBuf, MAX_BUF_SIZE, MAX_BUF_SIZE - 1, text_, data[0].c_str(), data[1].c_str()) < 0)
-            {
-                GRAPHIC_LOGE("snprintf_s failed.\n");
-                return;
-            }
+
+        // printf("HandleTextData called with num: %d, data[0]: %s\n", num, data[0].c_str());
+
+        char tempBuf[MAX_BUF_SIZE] = {0};
+#if 0
+        for (uint16_t i = 0; i < num; ++i)
+        {
+            printf("data[%d]: %s\n", i, data[i].c_str());
         }
-        else if (num == 3)
-        { // 3: wildcard cnt
-            if (snprintf_s(tempBuf, MAX_BUF_SIZE, MAX_BUF_SIZE - 1, text_,
-                           data[0].c_str(), "年", data[1].c_str(), "月", data[2].c_str(), "日") < 0)
-            { // 2: index
-                GRAPHIC_LOGE("snprintf_s failed.\n");
-                return;
-            }
+#endif
+        int ret;
+        switch (num)
+        {
+        case 1:
+            ret = snprintf_s(tempBuf, MAX_BUF_SIZE, MAX_BUF_SIZE - 1, text_, data[0].c_str());
+            break;
+        case 2:
+            ret = snprintf_s(tempBuf, MAX_BUF_SIZE, MAX_BUF_SIZE - 1, text_, data[0].c_str(), data[1].c_str());
+            break;
+        case 3:
+            ret = snprintf_s(tempBuf, MAX_BUF_SIZE, MAX_BUF_SIZE - 1, text_,
+                             data[0].c_str(), "年", data[1].c_str(), "月", data[2].c_str(), "日");
+            break;
+        default:
+            GRAPHIC_LOGE("Invalid num: %d. Max size is 3.\n", num);
+            return;
         }
-        else
+
+        if (ret < 0)
         {
-            GRAPHIC_LOGE("max size is 3.\n");
+            GRAPHIC_LOGE("snprintf_s failed with error code: %d\n", ret);
             return;
         }
+
+        // printf("Constructed tempBuf: %s\n", tempBuf);
         SetTextWithWildcardInner(tempBuf);
     }
-
     void DialLabelView::HandleFloatData(const float *data, uint16_t num)
     {
         char tempBuf[MAX_BUF_SIZE] = {0};
index 63c3147..fbda6a4 100644 (file)
@@ -1,3 +1,9 @@
+/*** 
+ * @Date: 2024-04-27 18:32:46
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-08-06 15:37:21
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelSPO2.cpp
+ */
 /*
  * Copyright (c) CompanyNameMagicTag 2023. All rights reserved.
  * Description: DialModelSPO2
@@ -22,6 +28,8 @@ namespace OHOS
 
     void DialModelSPO2::UpdateSPO2(uint8_t SPO2)
     {
+        if (SPO2 == 0)
+            return;
         SPO2_ = static_cast<float>(SPO2);
         if (onChangeListener_ != nullptr)
         {
diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelWeekStr.cpp b/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelWeekStr.cpp
new file mode 100644 (file)
index 0000000..6be3e64
--- /dev/null
@@ -0,0 +1,46 @@
+#include "RegisterDialModel.h"
+#include "DialModelWeekStr.h"
+#include <string>
+#include <ctime>
+#include <time.h>
+#include "sys/time.h"
+#include "wearable_log.h"
+
+REGIST_DIAL_MODULE(DialDataType::DATA_TYPE_WEEK_STR, OHOS::DialModelWeekStr::GetInstance());
+namespace OHOS
+{
+    //  Cnweekdays 是一个包含星期字符串的数组
+    const std::string Cnweekdays[] = {"星期天", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"};
+
+    bool DialModelWeekStr::GetDialTextData(DialDataType &type, std::string *&out, int16_t &strNum)
+    {
+        (void)type;
+
+        struct tm local_time = {0};
+        time_t seconds = time(nullptr);
+
+        if (localtime_r(&seconds, &local_time) == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "get localtime error!");
+            return false;
+        }
+
+        dialWeekStr_.clear();
+        dialWeekStr_ = Cnweekdays[local_time.tm_wday];
+        // printf("dialWeekStr_:%s\r\n", dialWeekStr_.c_str());
+        out = &dialWeekStr_;
+        strNum = 1;
+        // printf("GetDialTextData %d\r\n",strNum);
+        return true;
+    }
+
+    void DialModelWeekStr::UpdateWeekStr(const std::string *&dialWeekStr)
+    {
+        dialWeekStr_.clear();
+        dialWeekStr_ = *dialWeekStr; // 更新字符串
+        if (onChangeListener_ != nullptr)
+        {
+            onChangeListener_->OnDialTextDataUpdate(DialDataType::DATA_TYPE_WEEK_STR, &dialWeekStr_, dialWeekStr_.size());
+        }
+    }
+}
\ No newline at end of file
index b25a7ce..5906b5c 100644 (file)
 #ifdef SUPPORT_AT_OHOSFWK
 #include "ui_screennotify.h"
 #endif
-namespace OHOS {
-static DialVideoView* g_video = nullptr;
+namespace OHOS
+{
+    static DialVideoView *g_video = nullptr;
 
 #ifdef SUPPORT_AT_OHOSFWK
-static void ScreenStatusNotify(ScreenStatus status)
-{
-    if (g_video == nullptr) {
-        return;
-    }
-    if (status == SCREEN_STATUS_OFF && g_video->IsPlayed()) {
-        g_video->PausePlay();
-    } else if (status == SCREEN_STATUS_ON) {
-        if (g_video->IsPaused()) {
-            g_video->ResumePlay();
-        } else if (!g_video->IsPlayed()) {
-            g_video->StartPlay();
+    static void ScreenStatusNotify(ScreenStatus status)
+    {
+        if (g_video == nullptr)
+        {
+            return;
+        }
+        if (status == SCREEN_STATUS_OFF && g_video->IsPlayed())
+        {
+            g_video->PausePlay();
+        }
+        else if (status == SCREEN_STATUS_ON)
+        {
+            if (g_video->IsPaused())
+            {
+                g_video->ResumePlay();
+            }
+            else if (!g_video->IsPlayed())
+            {
+                g_video->StartPlay();
+            }
         }
     }
-}
 #endif
 
-DialViewGroup::DialViewGroup(void)
-{
-    SetTouchable(true);
-    SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
-    SetCoverable(true);
-}
+    DialViewGroup::DialViewGroup(void)
+    {
+        SetTouchable(true);
+        SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
+        SetCoverable(true);
+    }
 
-DialViewGroup::~DialViewGroup(void)
-{
-    if (video_ != nullptr) {
+    DialViewGroup::~DialViewGroup(void)
+    {
+        if (video_ != nullptr)
+        {
 #ifdef SUPPORT_AT_OHOSFWK
-        deregisterNotifyScreenStatus(ScreenStatusNotify);
+            deregisterNotifyScreenStatus(ScreenStatusNotify);
 #endif
-        g_video = nullptr;
-    }
-    if (kaleidoscope_ != nullptr) {
-        kaleidoscope_->ClearFocus();
-        kaleidoscope_ = nullptr;
-    }
-    ClearDial();
-}
-
-void DialViewGroup::ClearDial()
-{
-    ImageCacheManager::GetInstance().UnloadAllInMultiRes(filePath_);
-    ListNode<DialDataType>* passiveNode = passiveUpdateTypes_.Head();
-    while (passiveNode != passiveUpdateTypes_.End()) {
-        DialDataType type = passiveNode->data_;
-        ModelDialDataFactory::GetInstance().UnRegisterDialDataListener(type);
-        passiveNode = passiveNode->next_;
-    }
-    passiveUpdateTypes_.Clear();
-
-    ListNode<DialClick>* clickNode = dialClicks_.Head();
-    while (clickNode != dialClicks_.End()) {
-        DialClick click = clickNode->data_;
-        if (!click.isSliceType) {
-            UIFree(click.bundleName);
+            g_video = nullptr;
+        }
+        if (kaleidoscope_ != nullptr)
+        {
+            kaleidoscope_->ClearFocus();
+            kaleidoscope_ = nullptr;
         }
-        clickNode = clickNode->next_;
+        ClearDial();
     }
-    dialClicks_.Clear();
-
-    periodicUpdateTypes_.Clear();
 
-    dataTypeMap_.clear();
+    void DialViewGroup::ClearDial()
+    {
+        ImageCacheManager::GetInstance().UnloadAllInMultiRes(filePath_);
+        ListNode<DialDataType> *passiveNode = passiveUpdateTypes_.Head();
+        while (passiveNode != passiveUpdateTypes_.End())
+        {
+            DialDataType type = passiveNode->data_;
+            ModelDialDataFactory::GetInstance().UnRegisterDialDataListener(type);
+            passiveNode = passiveNode->next_;
+        }
+        passiveUpdateTypes_.Clear();
+
+        ListNode<DialClick> *clickNode = dialClicks_.Head();
+        while (clickNode != dialClicks_.End())
+        {
+            DialClick click = clickNode->data_;
+            if (!click.isSliceType)
+            {
+                UIFree(click.bundleName);
+            }
+            clickNode = clickNode->next_;
+        }
+        dialClicks_.Clear();
 
-    ListNode<UIView*>* viewNode = dialViews_.Head();
-    while (viewNode != dialViews_.End()) {
-        UIViewGroup::Remove(viewNode->data_);
-        delete(viewNode->data_);
-        viewNode = viewNode->next_;
-    }
-    dialViews_.Clear();
+        periodicUpdateTypes_.Clear();
 
-    period_ = DEFAULT_TASK_PERIOD;
+        dataTypeMap_.clear();
 
-    video_ = nullptr;
+        ListNode<UIView *> *viewNode = dialViews_.Head();
+        while (viewNode != dialViews_.End())
+        {
+            UIViewGroup::Remove(viewNode->data_);
+            delete (viewNode->data_);
+            viewNode = viewNode->next_;
+        }
+        dialViews_.Clear();
 
-    if (fp_ != nullptr) {
-        fclose(fp_);
-        fp_ = nullptr;
-    }
-}
+        period_ = DEFAULT_TASK_PERIOD;
 
-void DialViewGroup::SetDial(std::string filePath)
-{
-    ClearDial();
-    resPreloaded_ = false;
-    filePath_ = filePath;
-}
+        video_ = nullptr;
 
-void DialViewGroup::PreLoad(void)
-{
-    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DialViewGroup::PreLoad");
-     uint32_t startTime_ = HALTick::GetInstance().GetTime();
-    if (!resPreloaded_) {
-        fp_ = fopen(filePath_.c_str(), "rb");
-        if (fp_ == nullptr) {
-            GRAPHIC_LOGE("cannot open file: %s\n", filePath_.c_str());
-            return;
+        if (fp_ != nullptr)
+        {
+            fclose(fp_);
+            fp_ = nullptr;
         }
-        DialBinParser::GetInstance()->UpdateDial(filePath_, fp_, this);
-        resPreloaded_ = true;
     }
 
-    if(!resLoadStatus)
+    void DialViewGroup::SetDial(std::string filePath)
     {
-        // if(PullUpDownView::GetInstance()!=nullptr)
-        // {
-        //     PullUpDownView::GetInstance()->PreLoad();
-        // }
-
-        // if(MessageControlView::GetInstance()!=nullptr)
-        // {
-        //     MessageControlView::GetInstance()->PreLoad();
-        // }
-        resLoadStatus = true;
+        ClearDial();
+        resPreloaded_ = false;
+        filePath_ = filePath;
     }
-    uint32_t elapseTime = HALTick::GetInstance().GetElapseTime(startTime_);
-    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DialViewGroup::GetElapseTime %d", elapseTime);
-}
 
-void DialViewGroup::UnLoad(void)
-{
-    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DialViewGroup::UnLoad");
-    if(resLoadStatus)
+    void DialViewGroup::PreLoad(void)
     {
-        // if(PullUpDownView::GetInstance()!=nullptr)
-        // {
-        //     PullUpDownView::GetInstance()->UnLoad();
-        // }
-
-        // if(MessageControlView::GetInstance()!=nullptr)
-        // {
-        //     MessageControlView::GetInstance()->UnLoad();
-        // }
-        resLoadStatus = false;
-    }
-}
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DialViewGroup::PreLoad");
+        uint32_t startTime_ = HALTick::GetInstance().GetTime();
+        if (!resPreloaded_)
+        {
+            fp_ = fopen(filePath_.c_str(), "rb");
+            if (fp_ == nullptr)
+            {
+                GRAPHIC_LOGE("cannot open file: %s\n", filePath_.c_str());
+                return;
+            }
+            DialBinParser::GetInstance()->UpdateDial(filePath_, fp_, this);
+            resPreloaded_ = true;
+        }
 
-void DialViewGroup::ProcessData(DialDataType type, DialView* view)
-{
-    int16_t value = static_cast<int16_t>(type) >> 13; // 13: bit shift
-    if (value == 0) { // 0: float
-        float floatData = 0;
-        ModelDialDataFactory::GetInstance().GetDialFloatData(type, floatData);
-        view->HandleFloatData(floatData);
-    } else if (value == 1) { // 1: text
-        std::string* textData = nullptr;
-        int16_t num = 0;
-        ModelDialDataFactory::GetInstance().GetDialTextData(type, textData, num);
-        view->HandleTextData(textData, num);
-    } else if (value == 2) { // 2: multifloat
-        float* floatsData = nullptr;
-        int16_t num = 0;
-        ModelDialDataFactory::GetInstance().GetDialFloatData(type, floatsData, num);
-        view->HandleFloatData(floatsData, num);
+        if (!resLoadStatus)
+        {
+            /*打印已经注册的表盘model类型*/
+            ModelDialDataFactory::GetInstance().DumpModules();
+            resLoadStatus = true;
+        }
+        uint32_t elapseTime = HALTick::GetInstance().GetElapseTime(startTime_);
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DialViewGroup::GetElapseTime %d", elapseTime);
     }
-}
 
-void DialViewGroup::AddView(UIView* view, bool isDialVideoView)
-{
-    if (view == nullptr) {
-        GRAPHIC_LOGE("Parameter is nullptr.\n");
-        return;
+    void DialViewGroup::UnLoad(void)
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DialViewGroup::UnLoad");
+        if (resLoadStatus)
+        {
+            resLoadStatus = false;
+        }
     }
-    dialViews_.PushBack(view);
-    Add(view);
 
-    if (view->GetViewType() == UI_KALEIDOSCOPE_VIEW) {
-        kaleidoscope_ = dynamic_cast<UIKaleidoscopeView*>(view);
+    void DialViewGroup::ProcessData(DialDataType type, DialView *view)
+    {
+        int16_t value = static_cast<int16_t>(type) >> 14; // 14: bit shift
+        if (value == 0)
+        { // 0: float
+            float floatData = 0;
+            ModelDialDataFactory::GetInstance().GetDialFloatData(type, floatData);
+            view->HandleFloatData(floatData);
+        }
+        else if (value == 1)
+        { // 1: text
+            std::string *textData = nullptr;
+            int16_t num = 0;
+            bool ret = ModelDialDataFactory::GetInstance().GetDialTextData(type, textData, num);
+            // printf("ModelDialDataFactory type %d  num %d ret %d \r\n", type, num, ret);
+            view->HandleTextData(textData, num);
+        }
+        else if (value == 2)
+        { // 2: multifloat
+            float *floatsData = nullptr;
+            int16_t num = 0;
+            ModelDialDataFactory::GetInstance().GetDialFloatData(type, floatsData, num);
+            view->HandleFloatData(floatsData, num);
+        }
     }
 
-    if (isDialVideoView) {
-        if (video_ != nullptr) {
-            GRAPHIC_LOGE("Already added a video view.\n");
+    void DialViewGroup::AddView(UIView *view, bool isDialVideoView)
+    {
+        if (view == nullptr)
+        {
+            GRAPHIC_LOGE("Parameter is nullptr.\n");
             return;
         }
-        video_ = reinterpret_cast<DialVideoView*>(view);
-        g_video = video_;
+        dialViews_.PushBack(view);
+        Add(view);
+
+        if (view->GetViewType() == UI_KALEIDOSCOPE_VIEW)
+        {
+            kaleidoscope_ = dynamic_cast<UIKaleidoscopeView *>(view);
+        }
+
+        if (isDialVideoView)
+        {
+            if (video_ != nullptr)
+            {
+                GRAPHIC_LOGE("Already added a video view.\n");
+                return;
+            }
+            video_ = reinterpret_cast<DialVideoView *>(view);
+            g_video = video_;
 #ifdef SUPPORT_AT_OHOSFWK
-        registerNotifyScreenStatus(ScreenStatusNotify);
+            registerNotifyScreenStatus(ScreenStatusNotify);
 #endif
+        }
     }
-}
 
-void DialViewGroup::AddView(DialDataType type, DialView* view, bool isPeriodic)
-{
-    if (view == nullptr) {
-        GRAPHIC_LOGE("Parameter is nullptr.\n");
-        return;
+    void DialViewGroup::AddView(DialDataType type, DialView *view, bool isPeriodic)
+    {
+        if (view == nullptr)
+        {
+            GRAPHIC_LOGE("Parameter is nullptr.\n");
+            return;
+        }
+
+        dataTypeMap_.insert(std::make_pair(static_cast<int16_t>(type), view));
+        if (isPeriodic)
+        {
+            periodicUpdateTypes_.PushBack(type);
+        }
+        else
+        {
+            ModelDialDataFactory::GetInstance().RegisterDialDataListener(type, this);
+            passiveUpdateTypes_.PushBack(type);
+        }
+        dialViews_.PushBack(dynamic_cast<UIView *>(view));
+        ProcessData(type, view);
+        Add(dynamic_cast<UIView *>(view));
     }
 
-    dataTypeMap_.insert(std::make_pair(static_cast<int16_t>(type), view));
-    if (isPeriodic) {
-        periodicUpdateTypes_.PushBack(type);
-    } else {
-        ModelDialDataFactory::GetInstance().RegisterDialDataListener(type, this);
-        passiveUpdateTypes_.PushBack(type);
+    void DialViewGroup::SetPeriod(uint32_t period)
+    {
+        if (period_ < DEFAULT_TASK_PERIOD)
+        {
+            period_ = DEFAULT_TASK_PERIOD;
+        }
+        else
+        {
+            period_ = period;
+        }
     }
-    dialViews_.PushBack(dynamic_cast<UIView*>(view));
-    ProcessData(type, view);
-    Add(dynamic_cast<UIView*>(view));
-}
 
-void DialViewGroup::SetPeriod(uint32_t period)
-{
-    if (period_ < DEFAULT_TASK_PERIOD) {
-        period_ = DEFAULT_TASK_PERIOD;
-    } else {
-        period_ = period;
+    uint32_t DialViewGroup::GetPeriod()
+    {
+        return period_;
     }
-}
 
-uint32_t DialViewGroup::GetPeriod()
-{
-    return period_;
-}
+    void DialViewGroup::UpdateViewsByPeriodicUpdateData()
+    {
+        ListNode<DialDataType> *node = periodicUpdateTypes_.Head();
+        while (node != periodicUpdateTypes_.End())
+        {
+            DialDataType type = node->data_;
+            auto iter = dataTypeMap_.find(static_cast<int16_t>(type));
+            if (iter != dataTypeMap_.end())
+            {
+                ProcessData(type, iter->second);
+            }
+            node = node->next_;
+        }
+        if (LowPowerManager::GetInstance()->IsLiteSurfaceInRootView())
+        {
+            Invalidate();
+        }
+    }
 
-void DialViewGroup::UpdateViewsByPeriodicUpdateData()
-{
-    ListNode<DialDataType>* node = periodicUpdateTypes_.Head();
-    while (node != periodicUpdateTypes_.End()) {
-        DialDataType type = node->data_;
+    void DialViewGroup::OnDialFloatDataUpdate(DialDataType type, float data)
+    {
         auto iter = dataTypeMap_.find(static_cast<int16_t>(type));
-        if (iter != dataTypeMap_.end()) {
-            ProcessData(type, iter->second);
+        if (iter != dataTypeMap_.end())
+        {
+            DialView *view = iter->second;
+            view->HandleFloatData(data);
         }
-        node = node->next_;
-    }
-    if (LowPowerManager::GetInstance()->IsLiteSurfaceInRootView()) {
-        Invalidate();
     }
-}
 
-void DialViewGroup::OnDialFloatDataUpdate(DialDataType type, float data)
-{
-    auto iter = dataTypeMap_.find(static_cast<int16_t>(type));
-    if (iter != dataTypeMap_.end()) {
-        DialView* view = iter->second;
-        view->HandleFloatData(data);
+    void DialViewGroup::OnDialFloatDataUpdate(DialDataType type, const float *data, uint16_t num)
+    {
+        auto iter = dataTypeMap_.find(static_cast<int16_t>(type));
+        if (iter != dataTypeMap_.end())
+        {
+            DialView *view = iter->second;
+            view->HandleFloatData(data, num);
+        }
     }
-}
 
-void DialViewGroup::OnDialFloatDataUpdate(DialDataType type, const float* data, uint16_t num)
-{
-    auto iter = dataTypeMap_.find(static_cast<int16_t>(type));
-    if (iter != dataTypeMap_.end()) {
-        DialView* view = iter->second;
-        view->HandleFloatData(data, num);
+    void DialViewGroup::OnDialTextDataUpdate(DialDataType type, const std::string *data, uint16_t num)
+    {
+        auto iter = dataTypeMap_.find(static_cast<int16_t>(type));
+        if (iter != dataTypeMap_.end())
+        {
+            DialView *view = iter->second;
+            view->HandleTextData(data, num);
+        }
     }
-}
 
-void DialViewGroup::OnDialTextDataUpdate(DialDataType type, const std::string* data, uint16_t num)
-{
-    auto iter = dataTypeMap_.find(static_cast<int16_t>(type));
-    if (iter != dataTypeMap_.end()) {
-        DialView* view = iter->second;
-        view->HandleTextData(data, num);
+    void DialViewGroup::AddDialClick(Rect &rect, const char *bundleName)
+    {
+        if (bundleName == nullptr)
+        {
+            return;
+        }
+        uint32_t len = static_cast<uint32_t>(strlen(bundleName));
+        char *name = static_cast<char *>(UIMalloc(++len));
+        if (name == nullptr)
+        {
+            return;
+        }
+        if (memcpy_s(name, len, bundleName, len) != EOK)
+        {
+            UIFree(name);
+            name = nullptr;
+            return;
+        }
+        name[len] = '\0';
+        DialClick click = {rect, false, {.bundleName = name}};
+        dialClicks_.PushBack(click);
     }
-}
 
-void DialViewGroup::AddDialClick(Rect& rect, const char* bundleName)
-{
-    if (bundleName == nullptr) {
-        return;
-    }
-    uint32_t len = static_cast<uint32_t>(strlen(bundleName));
-    char* name = static_cast<char*>(UIMalloc(++len));
-    if (name == nullptr) {
-        return;
-    }
-    if (memcpy_s(name, len, bundleName, len) != EOK) {
-        UIFree(name);
-        name = nullptr;
-        return;
-    }
-    name[len] = '\0';
-    DialClick click = {rect, false, {.bundleName = name}};
-    dialClicks_.PushBack(click);
-}
+    void DialViewGroup::AddDialClick(Rect &rect, uint32_t sliceId)
+    {
+        if (sliceId == 0)
+        {
+            return;
+        }
 
-void DialViewGroup::AddDialClick(Rect& rect, uint32_t sliceId)
-{
-    if (sliceId == 0) {
-        return;
+        DialClick click = {rect, true, {.sliceId = sliceId}};
+        dialClicks_.PushBack(click);
     }
 
-    DialClick click = {rect, true, {.sliceId = sliceId}};
-    dialClicks_.PushBack(click);
-}
-
-bool DialViewGroup::OnClickEvent(const ClickEvent& event)
-{
-    Point point = event.GetCurrentPos();
-    ListNode<DialClick>* node = dialClicks_.Head();
-    while (node != dialClicks_.End()) {
-        DialClick dialClick = node->data_;
-        if (dialClick.area.IsContains(point)) {
-            if (dialClick.isSliceType) {
-                NativeAbility::GetInstance().ChangeSlice(dialClick.sliceId);
-            } else {
+    bool DialViewGroup::OnClickEvent(const ClickEvent &event)
+    {
+        Point point = event.GetCurrentPos();
+        ListNode<DialClick> *node = dialClicks_.Head();
+        while (node != dialClicks_.End())
+        {
+            DialClick dialClick = node->data_;
+            if (dialClick.area.IsContains(point))
+            {
+                if (dialClick.isSliceType)
+                {
+                    NativeAbility::GetInstance().ChangeSlice(dialClick.sliceId);
+                }
+                else
+                {
 #ifdef JS_ENABLE
-                StartJsApp(dialClick.bundleName);
+                    StartJsApp(dialClick.bundleName);
 #endif
+                }
+                return true;
             }
-            return true;
+            node = node->next_;
         }
-        node = node->next_;
+        return false;
     }
-    return false;
-}
 
-void DialViewGroup::ScrollBegin(bool isActive)
-{
-    if (kaleidoscope_ != nullptr) {
-        if (isActive) {
-            kaleidoscope_->ClearFocus();
-            kaleidoscope_->StopRotateAnimator();
+    void DialViewGroup::ScrollBegin(bool isActive)
+    {
+        if (kaleidoscope_ != nullptr)
+        {
+            if (isActive)
+            {
+                kaleidoscope_->ClearFocus();
+                kaleidoscope_->StopRotateAnimator();
+            }
+            return;
         }
-        return;
-    }
 
-    if (video_ == nullptr) {
-        return;
-    }
-    if (video_->IsPlayed()) {
-        video_->PausePlay();
+        if (video_ == nullptr)
+        {
+            return;
+        }
+        if (video_->IsPlayed())
+        {
+            video_->PausePlay();
+        }
     }
-}
 
-void DialViewGroup::ScrollEnd(bool isActive)
-{
-    if (kaleidoscope_ != nullptr) {
-        if (isActive) {
-            kaleidoscope_->StartRotateAnimator();
-            kaleidoscope_->RequestFocus();
+    void DialViewGroup::ScrollEnd(bool isActive)
+    {
+        if (kaleidoscope_ != nullptr)
+        {
+            if (isActive)
+            {
+                kaleidoscope_->StartRotateAnimator();
+                kaleidoscope_->RequestFocus();
+            }
+            return;
         }
-        return;
-    }
 
-    if (video_ == nullptr) {
-        return;
-    }
+        if (video_ == nullptr)
+        {
+            return;
+        }
 
-    if (isActive) {
-        if (video_->IsPaused()) {
-            video_->ResumePlay();
-        } else if (!video_->IsPlayed()) {
-            video_->StartPlay();
+        if (isActive)
+        {
+            if (video_->IsPaused())
+            {
+                video_->ResumePlay();
+            }
+            else if (!video_->IsPlayed())
+            {
+                video_->StartPlay();
+            }
+            g_video = video_;
         }
-        g_video = video_;
-    } else {
-        if (video_->IsPaused() || video_->IsPlayed()) {
-            video_->StopPlay();
+        else
+        {
+            if (video_->IsPaused() || video_->IsPlayed())
+            {
+                video_->StopPlay();
+            }
+            ClearCache();
+            g_video = nullptr;
         }
-        ClearCache();
-        g_video = nullptr;
     }
-}
 
-void DialViewGroup::CoverBegin(bool isCovered)
-{
-    if (kaleidoscope_ != nullptr) {
-        if (!isCovered) {
-            kaleidoscope_->StopRotateAnimator();
-            kaleidoscope_->ClearFocus();
+    void DialViewGroup::CoverBegin(bool isCovered)
+    {
+        if (kaleidoscope_ != nullptr)
+        {
+            if (!isCovered)
+            {
+                kaleidoscope_->StopRotateAnimator();
+                kaleidoscope_->ClearFocus();
+            }
+            return;
         }
-        return;
-    }
 
-    if (video_ == nullptr) {
-        return;
+        if (video_ == nullptr)
+        {
+            return;
+        }
+
+        if (video_->IsPlayed())
+        {
+            video_->PausePlay();
+        }
     }
 
-    if (video_->IsPlayed()) {
-        video_->PausePlay();
+    void DialViewGroup::CoverEnd(bool isCovered)
+    {
+        if (kaleidoscope_ != nullptr)
+        {
+            if (!isCovered)
+            {
+                kaleidoscope_->RequestFocus();
+                kaleidoscope_->StartRotateAnimator();
+            }
+            return;
+        }
+        if (video_ == nullptr)
+        {
+            return;
+        }
+        if (isCovered)
+        {
+            g_video = nullptr;
+        }
+        else
+        {
+            if (video_->IsPaused())
+            {
+                video_->ResumePlay();
+            }
+            else if (!video_->IsPlayed())
+            {
+                video_->StartPlay();
+            }
+            g_video = video_;
+        }
     }
-}
 
-void DialViewGroup::CoverEnd(bool isCovered)
-{
-    if (kaleidoscope_ != nullptr) {
-        if (!isCovered) {
+    void DialViewGroup::OnActive(void)
+    {
+        if (video_ != nullptr)
+        {
+            if (video_->IsPaused())
+            {
+                video_->ResumePlay();
+            }
+            else if (!video_->IsPlayed())
+            {
+                video_->StartPlay();
+            }
+            g_video = video_;
+        }
+        else if (kaleidoscope_ != nullptr)
+        {
             kaleidoscope_->RequestFocus();
             kaleidoscope_->StartRotateAnimator();
         }
-        return;
-    }
-    if (video_ == nullptr) {
-        return;
     }
-    if (isCovered) {
-        g_video = nullptr;
-    } else {
-        if (video_->IsPaused()) {
-            video_->ResumePlay();
-        } else if (!video_->IsPlayed()) {
-            video_->StartPlay();
-        }
-        g_video = video_;
-    }
-}
 
-void DialViewGroup::OnActive(void)
-{
-    if (video_ != nullptr) {
-        if (video_->IsPaused()) {
-            video_->ResumePlay();
-        } else if (!video_->IsPlayed()) {
-            video_->StartPlay();
-        }
-        g_video = video_;
-    } else if (kaleidoscope_ != nullptr) {
-        kaleidoscope_->RequestFocus();
-        kaleidoscope_->StartRotateAnimator();
-    }
-}
-
-void DialViewGroup::OnInactive(void)
-{
-    if (video_ != nullptr) {
-        if (!video_->IsStopped()) {
-            video_->StopPlay();
-        }
-        g_video = nullptr;
-    } else if (kaleidoscope_ != nullptr) {
-        kaleidoscope_->StopRotateAnimator();
-        kaleidoscope_->ClearFocus();
+    void DialViewGroup::OnInactive(void)
+    {
+        if (video_ != nullptr)
+        {
+            if (!video_->IsStopped())
+            {
+                video_->StopPlay();
+            }
+            g_video = nullptr;
+        }
+        else if (kaleidoscope_ != nullptr)
+        {
+            kaleidoscope_->StopRotateAnimator();
+            kaleidoscope_->ClearFocus();
+        }
     }
 }
-}
index d17de5b..88ce467 100644 (file)
@@ -13,6 +13,7 @@ bool ModelDialDataFactory::GetDialTextData(DialDataType& type, std::string*& out
     if (model == nullptr) {
         return false;
     }
+    // printf("type %d strNum %d\r\n",type,strNum);
     return model->GetDialTextData(type, out, strNum);
 }
 
index a61df48..21a4c30 100644 (file)
@@ -418,6 +418,7 @@ int32_t DialBinParser::ParserDialLabel(FILE* fp)
     view->SetTextColor(color);\r
     view->SetAlign(static_cast<UITextLanguageAlignment>(data->align));\r
     if (data->bindData != 0) {\r
+        //printf("%s\r\n",data->text);\r
         view->SetTextWithWildcard(data->text);\r
         dialGroup_->AddView(static_cast<DialDataType>(data->bindData), view, data->isPeriod);\r
     } else {\r