优化睡眠card处理
authorCaisking <3449750381@qq.com>
Tue, 3 Sep 2024 08:39:33 +0000 (16:39 +0800)
committerCaisking <3449750381@qq.com>
Tue, 3 Sep 2024 08:39:33 +0000 (16:39 +0800)
code/sdk/application/wearable/fd230app/nativeui/sleep/include/SleepCardView.h
code/sdk/application/wearable/fd230app/nativeui/sleep/include/SleepControlView.h
code/sdk/application/wearable/fd230app/nativeui/sleep/include/SleepModel.h
code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepCardView.cpp
code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepControlPresenter.cpp
code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepControlView.cpp

index c916e8e..624d489 100644 (file)
@@ -1,3 +1,9 @@
+/***\r
+ * @Date: 2024-06-25 10:41:32\r
+ * @LastEditors: Caisking 3449750381@qq.com\r
+ * @LastEditTime: 2024-09-03 15:10:21\r
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/sleep/include/SleepCardView.h\r
+ */\r
 #ifndef SLEEP_CARD_VIEW_H\r
 #define SLEEP_CARD_VIEW_H\r
 \r
@@ -13,13 +19,17 @@ namespace OHOS
     public:\r
         SleepCardView();\r
         virtual ~SleepCardView();\r
+        static SleepCardView *GetInstance(void);\r
+\r
         bool InitView(void);\r
         void PreLoad(void) override;\r
         void UnLoad(void) override;\r
+        UISwipeView *GetSleepCardView();\r
 \r
     private:\r
         void ClearAll(void);\r
         SleepControlView *sleepcontrolView{nullptr};\r
+        UISwipeView *SleepSwipView{nullptr};\r
         UISwipeView::OnSwipeListener *sleepOnSwipeListener{nullptr};\r
         bool viewiInitStatus{false};\r
     };\r
index 4af27f9..c552368 100644 (file)
@@ -1,3 +1,9 @@
+/***
+ * @Date: 2024-06-25 10:41:08
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-09-02 09:22:33
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/sleep/include/SleepControlView.h
+ */
 /***
  * @Date: 2024-06-25 10:41:08
  * @LastEditors: Caisking 3449750381@qq.com
@@ -43,8 +49,8 @@ namespace OHOS
         SleepView *GetSleepView(void);
         SleepTimeView *GetSleepTimeView(void);
 
-        UIView *GetSleepControlPageView(void);
-
+        UISwipeView *GetSleepControlPageView(void);
+        void ChangeView(int16_t hideView, int16_t showView);
 
     public:
         void OnStart() override;
index 88c848f..1a2796f 100644 (file)
@@ -119,6 +119,16 @@ namespace OHOS
         void Sleep_StartTimer(uint32_t interval);
         void Sleep_StopTimer(void);
 
+        /*主界面卡片相关*/
+        void SetCardId(int cardid)
+        {
+            CradId = cardid;
+        }
+        int GetCardId()
+        {
+            return CradId;
+        }
+
     private:
         SleepModel();
         SleepModel(const SleepModel &);
@@ -137,6 +147,7 @@ namespace OHOS
         int goal_total_time = 0;
 
         SLEEPSTATE sleepstate_ = SLEEPSTATE::WAKE;
+        int CradId = 0; // 主界面状态
     };
 }
 
index 2164e2e..79ec677 100644 (file)
@@ -9,18 +9,23 @@
 #include "sleep/include/SleepControlPresenter.h"\r
 namespace OHOS\r
 {\r
+    static SleepCardView *g_pSleepCardView = nullptr;\r
     SleepCardView::SleepCardView()\r
     {\r
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SleepCardView::SleepCardView");\r
         SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);\r
+        g_pSleepCardView = this;\r
     }\r
-\r
     SleepCardView::~SleepCardView()\r
     {\r
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SleepCardView::~SleepCardView");\r
         ClearAll();\r
+        g_pSleepCardView = nullptr;\r
+    }\r
+    SleepCardView *SleepCardView::GetInstance()\r
+    {\r
+        return g_pSleepCardView;\r
     }\r
-\r
     void SleepCardView::ClearAll(void)\r
     {\r
         if (viewiInitStatus == true)\r
@@ -53,14 +58,14 @@ namespace OHOS
             return false;\r
         }\r
 \r
-        UISwipeView *SleepSwipView = dynamic_cast<UISwipeView *>(sleepcontrolView->GetSleepControlPageView());\r
+        SleepSwipView = dynamic_cast<UISwipeView *>(sleepcontrolView->GetSleepControlPageView());\r
         if (SleepSwipView == nullptr)\r
         {\r
             WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SleepView->SleepViewInit() == nullptr!!");\r
             return false;\r
         }\r
 \r
-        sleepOnSwipeListener = static_cast<UISwipeView::OnSwipeListener *>(new SleepControlPresenter());\r
+        sleepOnSwipeListener = static_cast<UISwipeView::OnSwipeListener *>(new SleepOnSwipeListener());\r
         if (sleepOnSwipeListener == nullptr)\r
         {\r
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "sleepOnSwipeListener new fail");\r
@@ -71,7 +76,10 @@ namespace OHOS
 \r
         return true;\r
     }\r
-\r
+    UISwipeView *SleepCardView::GetSleepCardView()\r
+    {\r
+        return SleepSwipView;\r
+    }\r
     void SleepCardView::PreLoad(void)\r
     {\r
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SleepCardView::PreLoad");\r
index d300dc7..8691a4f 100644 (file)
@@ -111,14 +111,6 @@ namespace OHOS
     void SleepOnSwipeListener::OnSwipe(UISwipeView &view)
     {
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SleepOnSwipeListener::OnSwipe,current tab index = %d", view.GetCurrentPage());
-        if (view.GetCurrentPage() == MAINSLEEPVIEW)
-        {
-            view.SetIntercept(false);
-        }
-        else
-        {
-            view.SetIntercept(true);
-        }
         return;
     }
 }
\ No newline at end of file
index 473a730..97b3bfc 100644 (file)
@@ -1,3 +1,9 @@
+/***
+ * @Date: 2024-09-02 14:46:10
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-09-03 16:01:25
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepControlView.cpp
+ */
 /***
  * @Date: 2024-06-25 10:41:15
  * @LastEditors: Caisking 3449750381@qq.com
@@ -82,10 +88,11 @@ namespace OHOS
     }
 
     /*获取睡眠主界面*/
-    UIView *SleepControlView::GetSleepControlPageView()
+    UISwipeView *SleepControlView::GetSleepControlPageView()
     {
-        return dynamic_cast<UIView *>(SleepControlViewInit());
+        return SleepControlViewInit();
     }
+
     /*OnStart 增加界面控制*/
     void SleepControlView::OnStart()
     {