修改步数刷新
authorhcj <1224667075@qq.com>
Wed, 6 Nov 2024 10:03:27 +0000 (18:03 +0800)
committerhcj <1224667075@qq.com>
Wed, 6 Nov 2024 10:03:27 +0000 (18:03 +0800)
code/sdk/application/wearable/fd230app/nativeui/activity/src/ActivityModel.cpp
code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp

index f0948c3..ccebd96 100644 (file)
@@ -129,103 +129,7 @@ static void Notify(void *args, const Topic topic, Request* request)
         return;
     }
 
-    if (request->msgId == TOPIC_EVENT_STEPDATA_UPDATE)
-    {
-        if (request->data == nullptr) {
-            return;
-        }
-        // 计步数据累加
-        uint32_t counter =
-            0; // OHOS::ActivityModel::GetInstance()->GetStepCounter();
-        counter = *(uint32_t *)request->data;
-        set_step_data(counter);
-        counter = get_step_data();//*(uint32_t *)request->data;
-        OHOS::ActivityModel::GetInstance()->ReviseStepCounter(counter);
-
-        OHOS::DialModelSteps::GetInstance() ->UpdateSteps(counter);//更新表盘步数
-        OHOS::DialModelStepgoal::GetInstance() ->UpdateStepgoal(counter);//更新表盘目标
-        OHOS::DialModelDistance::GetInstance() ->UpdateDistance(get_distance_data());//更新表盘距离
-        OHOS::DialModelCalorie::GetInstance() ->UpdateCalorie(get_calories_data());//更新表盘卡路里
-
-        GraphicService::GetInstance()->PostGraphicEvent(
-            std::bind(&ActivityModel::SetStepData, ActivityModel::GetInstance(), counter));
-        RefreshStepControls(counter, TOPIC_EVENT_STEPDATA_UPDATE);
     
-
-    #ifdef FD230
-        if(OHOS::GoalView::GetInstance())
-        {
-            OHOS::GoalView::GetInstance()->GoalViewrefresh();
-        }
-        if(OHOS::GoalotherView::GetInstance())
-        {
-            OHOS::GoalotherView::GetInstance()->GoalViewrefresh();
-        }
-
-        if(OHOS::GoalModel::GetInstance().getstepvalue()>=100)
-        {
-
-            goal_type=GOAL_STEP;
-            if(get_Is_show_flag(goal_type))
-            {   
-                if(OHOS::GoalModel::GetInstance().get_step_goal_show())
-                {
-                    CustomEventPublish(TOPIC_EVENT_GOAL_SHOW_VIEW,(uint8_t *)&goal_type,1);
-                }
-            }
-        }
-
-        if(OHOS::GoalModel::GetInstance().is_goal_DISTANCE_done())
-        {
-            goal_type=GOAL_DISTANCE;
-            if(get_Is_show_flag(goal_type))
-            {   
-                if(OHOS::GoalModel::GetInstance().get_other_goal_show())
-                {
-                    CustomEventPublish(TOPIC_EVENT_GOAL_SHOW_VIEW,(uint8_t *)&goal_type,1);
-                }
-            
-            }
-        }
-
-        if(OHOS::GoalModel::GetInstance().is_goal_fatburning_done())
-        {
-            goal_type=GOAL_FAT;
-            if(get_Is_show_flag(goal_type))
-            {   
-                if(OHOS::GoalModel::GetInstance().get_other_goal_show())
-                {
-                    CustomEventPublish(TOPIC_EVENT_GOAL_SHOW_VIEW,(uint8_t *)&goal_type,1);
-                }
-            }
-        }
-
-        if(OHOS::GoalModel::GetInstance().is_goal_stand_done())
-        {
-            goal_type=GOAL_STAND;
-            if(get_Is_show_flag(goal_type))
-            {   
-                if(OHOS::GoalModel::GetInstance().get_other_goal_show())
-                {
-                    CustomEventPublish(TOPIC_EVENT_GOAL_SHOW_VIEW,(uint8_t *)&goal_type,1);
-                }
-            }
-        }
-
-        if(OHOS::GoalModel::GetInstance().is_goal_calories_done())
-        {
-            goal_type=GOAL_CALOREIE;
-            if(get_Is_show_flag(goal_type))
-            {   
-            if(OHOS::GoalModel::GetInstance().get_other_goal_show())
-                {
-                    CustomEventPublish(TOPIC_EVENT_GOAL_SHOW_VIEW,(uint8_t *)&goal_type,1);
-                }
-            }
-        }
-    }
-#endif
-
     if (request->msgId == TOPIC_EVENT_NEXTDAY_UPDATE) {
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "STEP:TOPIC_EVENT_NEXTDAY_UPDATE");
 
index f04395d..46cd19a 100644 (file)
 #include "ui_service.h"
 
 #include "UiConfig.h"
+#include "DialModelSteps.h"
+#include "DialModelCalorie.h"
+#include "DialModelDistance.h"
+#include "DialModelStepgoal.h"
 
 #define DIALDATASET 1
 //#include "Systemupgrade.h"
@@ -409,13 +413,103 @@ void MsgCenterNotifygoalnotificationviewProc(const Topic topic, Request* req)
   
 }
 
+static uint8_t goal_type=0;
 
 void MsgCenterNotifystepProc(const Topic topic, Request* req)
 {
-    unused(req);
+    //unused(req);
+    if (req->msgId == TOPIC_EVENT_STEPDATA_UPDATE)
+    {
+        
+    #ifdef FD230
+        if (req->data == nullptr) {
+            return;
+        }
+        // 计步数据累加
+        uint32_t counter =
+            0; // OHOS::ActivityModel::GetInstance()->GetStepCounter();
+        counter = *(uint32_t *)req->data;
+        set_step_data(counter);
+
+        OHOS::DialModelSteps::GetInstance() ->UpdateSteps(counter);//更新表盘步数
+        OHOS::DialModelStepgoal::GetInstance() ->UpdateStepgoal(counter);//更新表盘目标
+        OHOS::DialModelDistance::GetInstance() ->UpdateDistance(get_distance_data());//更新表盘距离
+        OHOS::DialModelCalorie::GetInstance() ->UpdateCalorie(get_calories_data());//更新表盘卡路里
+
+
+        if(OHOS::GoalView::GetInstance())
+        {
+            OHOS::GoalView::GetInstance()->GoalViewrefresh();
+        }
+        if(OHOS::GoalotherView::GetInstance())
+        {
+            OHOS::GoalotherView::GetInstance()->GoalViewrefresh();
+        }
+
+        if(OHOS::GoalModel::GetInstance().getstepvalue()>=100)
+        {
+
+            goal_type=GOAL_STEP;
+            if(get_Is_show_flag(goal_type))
+            {   
+                if(OHOS::GoalModel::GetInstance().get_step_goal_show())
+                {
+                    CustomEventPublish(TOPIC_EVENT_GOAL_SHOW_VIEW,(uint8_t *)&goal_type,1);
+                }
+            }
+        }
+
+        if(OHOS::GoalModel::GetInstance().is_goal_DISTANCE_done())
+        {
+            goal_type=GOAL_DISTANCE;
+            if(get_Is_show_flag(goal_type))
+            {   
+                if(OHOS::GoalModel::GetInstance().get_other_goal_show())
+                {
+                    CustomEventPublish(TOPIC_EVENT_GOAL_SHOW_VIEW,(uint8_t *)&goal_type,1);
+                }
+            
+            }
+        }
+
+        if(OHOS::GoalModel::GetInstance().is_goal_fatburning_done())
+        {
+            goal_type=GOAL_FAT;
+            if(get_Is_show_flag(goal_type))
+            {   
+                if(OHOS::GoalModel::GetInstance().get_other_goal_show())
+                {
+                    CustomEventPublish(TOPIC_EVENT_GOAL_SHOW_VIEW,(uint8_t *)&goal_type,1);
+                }
+            }
+        }
+
+        if(OHOS::GoalModel::GetInstance().is_goal_stand_done())
+        {
+            goal_type=GOAL_STAND;
+            if(get_Is_show_flag(goal_type))
+            {   
+                if(OHOS::GoalModel::GetInstance().get_other_goal_show())
+                {
+                    CustomEventPublish(TOPIC_EVENT_GOAL_SHOW_VIEW,(uint8_t *)&goal_type,1);
+                }
+            }
+        }
+
+        if(OHOS::GoalModel::GetInstance().is_goal_calories_done())
+        {
+            goal_type=GOAL_CALOREIE;
+            if(get_Is_show_flag(goal_type))
+            {   
+            if(OHOS::GoalModel::GetInstance().get_other_goal_show())
+                {
+                    CustomEventPublish(TOPIC_EVENT_GOAL_SHOW_VIEW,(uint8_t *)&goal_type,1);
+                }
+            }
+        }
+    }
+#endif
 
-    // The alarm notification is not displayed if the incoming call notification is already being processed
-   // cywee_save_data();
 
 }