主界面添加load和unload 下拉和上拉资源功能
authorluozheng <1732036298@qq.com>
Wed, 26 Jun 2024 12:08:25 +0000 (20:08 +0800)
committerluozheng <1732036298@qq.com>
Wed, 26 Jun 2024 12:08:25 +0000 (20:08 +0800)
code/sdk/application/wearable/fd230app/nativeui/clock/include/MainClockView.h
code/sdk/application/wearable/fd230app/nativeui/clock/src/MainClockView.cpp
code/sdk/application/wearable/fd230app/nativeui/main/include/PullUpDownView.h
code/sdk/application/wearable/fd230app/nativeui/main/include/dial/DialViewGroup.h
code/sdk/application/wearable/fd230app/nativeui/main/src/PullUpDownView.cpp
code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialViewGroup.cpp
code/sdk/application/wearable/fd230app/nativeui/message/include/MessageControlView.h
code/sdk/application/wearable/fd230app/nativeui/message/src/MessageControlView.cpp

index 48abe6b..319ed49 100644 (file)
@@ -71,6 +71,7 @@ private:
     Image *medCircle{nullptr};
     Image *smallCircle{nullptr};
     bool viewiInitStatus{false};
+    bool resLoadStatus{false};
 };
 } // namespace OHOS
 #endif // MAIN_CLOCK_VIEW_H
index ec190bf..3278362 100644 (file)
@@ -16,6 +16,8 @@
 #include <sstream>
 #include <iomanip>
 #include "custom_runtime.h"
+#include "main/include/PullUpDownView.h"
+#include "message/include/MessageControlView.h"
 std::string weekdays[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
 namespace OHOS
 {
@@ -184,16 +186,44 @@ namespace OHOS
 
     void MainClockView::PreLoad(void)
     {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainClockView::PreLoad");
         if (!viewiInitStatus)
         {
             InitView();
             viewiInitStatus = true;
         }
+
+        if(!resLoadStatus)
+        {
+            if(PullUpDownView::GetInstance()!=nullptr)
+            {
+                PullUpDownView::GetInstance()->PreLoad();
+            }
+            if(MessageControlView::GetInstance()!=nullptr)
+            {
+                MessageControlView::GetInstance()->PreLoad();
+            }
+            resLoadStatus = true;
+        }
     }
 
     void MainClockView::UnLoad(void)
     {
-        // Main clock view is commonly used page, so we do not release it's resources inner slice.
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainClockView::UnLoad");
+
+        if(resLoadStatus)
+        {
+            if(PullUpDownView::GetInstance()!=nullptr)
+            {
+                PullUpDownView::GetInstance()->UnLoad();
+            }
+
+            if(MessageControlView::GetInstance()!=nullptr)
+            {
+                MessageControlView::GetInstance()->UnLoad();
+            }
+            resLoadStatus = false;
+        }
     }
 
     bool MainClockView::InitView(void)
index f7ebe22..2d4f894 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: luozheng 1732036298@qq.com
  * @Date: 2024-04-17 15:26:49
  * @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-06-17 18:36:36
+ * @LastEditTime: 2024-06-26 19:51:48
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/main/include/PullUpDownView.h
  */
 /*
@@ -53,6 +53,7 @@ namespace OHOS
         ~PullUpDownView() override;
         static PullUpDownView *GetInstance(void);
         void PreLoad(void) override;
+        void UnLoad(void) override;
         void UpdatePhoneStatus(int status);
         void UpdateEarPhoneStatus(int status);
         void UpdateBlueToothStatus(int status);
@@ -121,6 +122,7 @@ namespace OHOS
         Animator *progressanimator_ = nullptr;
 
         bool viewiInitStatus{false};
+        bool resLoadStatus{false};
     };
 }
 #endif
index 2a28997..d50a7d3 100644 (file)
@@ -86,6 +86,7 @@ public:
     * @brief  Preload resource callback.
     */
     void PreLoad(void) override;
+    void UnLoad(void) override;
 
     /**
     * @brief  Scroll begin callback. If a video is played, it will be paused.
@@ -111,6 +112,10 @@ public:
     * @brief  This function is invoked when the function SetHorCurrentPage() is called.
     */
     void OnActive(void) override;
+    
+private:
+    bool resLoadStatus{false};
+
 
 private:
     void ProcessData(DialDataType type, DialView* view);
index 97230ee..478b57d 100644 (file)
@@ -294,24 +294,25 @@ namespace OHOS
                 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "dropIconBackground[%d] new fail", i);
                 return;
             }
+            group[DROPDOWNVIEW]->Add(dropIconBackground[i]);
         }
         dropIconBackground[SETTING_INDEX]->SetPosition(SETTING_IMG_X, SETTING_IMG_Y);
         dropIconBackground[LIGHTING_INDEX]->SetPosition(LIGHTING_IMG_X, LIGHTING_IMG_Y);
         dropIconBackground[DNOTDISTURB_INDEX]->SetPosition(DNOTDISTURB_IMG_X, DNOTDISTURB_IMG_Y);
         dropIconBackground[SAVEPOWER_INDEX]->SetPosition(SAVEPOWER_IMG_X, SAVEPOWER_IMG_Y);
         dropIconBackground[FINDPHONE_INDEX]->SetPosition(FINDPHONE_IMG_X, FINDPHONE_IMG_Y);
-        for (int i = 0; i < MAX_INDEX; i++)
-        {
-            if (i == DNOTDISTURB_INDEX && DnotDisturbModel::GetInstance().GetDoNotDisturbModeEnabled() == true)
-            {
-                ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, dropIconBackground[i], DROPDOWN_ICONELLIPSEPURPLE);
-            }
-            else
-            {
-                ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, dropIconBackground[i], DROPDOWN_ICONELLIPSEBLACK);
-            }
-            group[DROPDOWNVIEW]->Add(dropIconBackground[i]);
-        }
+        // for (int i = 0; i < MAX_INDEX; i++)
+        // {
+        //     if (i == DNOTDISTURB_INDEX && DnotDisturbModel::GetInstance().GetDoNotDisturbModeEnabled() == true)
+        //     {
+        //         ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, dropIconBackground[i], DROPDOWN_ICONELLIPSEPURPLE);
+        //     }
+        //     else
+        //     {
+        //         ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, dropIconBackground[i], DROPDOWN_ICONELLIPSEBLACK);
+        //     }
+        //     group[DROPDOWNVIEW]->Add(dropIconBackground[i]);
+        // }
     }
 
     /// @brief 初始化icon图标
@@ -331,7 +332,7 @@ namespace OHOS
         dropSetting->SetPosition(SETTING_IMG_X, SETTING_IMG_Y, ICON_IMG_SIZE_W, ICON_IMG_SIZE_H);
         dropSetting->SetAutoEnable(false);
         dropSetting->SetResizeMode(UIImageView::CENTER);
-        ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, dropSetting, DROPDOWN_SETTING);
+        // ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, dropSetting, DROPDOWN_SETTING);
         dropSetting->SetViewId(DROPDOWN_CLICK_SETTING); // 进入设置界面
         dropSetting->SetTouchable(true);
         dropSetting->SetOnClickListener(clickListener);
@@ -345,7 +346,7 @@ namespace OHOS
         dropLighting->SetPosition(LIGHTING_IMG_X, LIGHTING_IMG_Y, ICON_IMG_SIZE_W, ICON_IMG_SIZE_H);
         dropLighting->SetAutoEnable(false);
         dropLighting->SetResizeMode(UIImageView::CENTER);
-        ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, dropLighting, DROPDOWN_BLUETOOTH);
+        // ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, dropLighting, DROPDOWN_BLUETOOTH);
         dropLighting->SetViewId(DROPDOWN_CLICK_LIGHTING); // 进入亮屏界面
         dropLighting->SetTouchable(true);
         dropLighting->SetOnClickListener(clickListener);
@@ -359,7 +360,7 @@ namespace OHOS
         dropDnotDisturb->SetPosition(DNOTDISTURB_IMG_X, DNOTDISTURB_IMG_Y, ICON_IMG_SIZE_W, ICON_IMG_SIZE_H);
         dropDnotDisturb->SetAutoEnable(false);
         dropDnotDisturb->SetResizeMode(UIImageView::CENTER);
-        ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, dropDnotDisturb, DROPDOWN_DNOTDISTURB);
+        // ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, dropDnotDisturb, DROPDOWN_DNOTDISTURB);
         dropDnotDisturb->SetViewId(DROPDOWN_CLICK_DNOTDISTURB); // 进入勿扰模式界面
         dropDnotDisturb->SetTouchable(true);
         dropDnotDisturb->SetOnClickListener(clickListener);
@@ -373,7 +374,7 @@ namespace OHOS
         dropSavePower->SetPosition(SAVEPOWER_IMG_X, SAVEPOWER_IMG_Y, ICON_IMG_SIZE_W, ICON_IMG_SIZE_H);
         dropSavePower->SetAutoEnable(false);
         dropSavePower->SetResizeMode(UIImageView::CENTER);
-        ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, dropSavePower, DROPDOWN_SAVEPOWER);
+        // ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, dropSavePower, DROPDOWN_SAVEPOWER);
         dropSavePower->SetViewId(DROPDOWN_CLICK_SAVEELE); // 进入省电界面
 
         dropSavePower->SetTouchable(true);
@@ -388,7 +389,7 @@ namespace OHOS
         drofindPhone->SetPosition(FINDPHONE_IMG_X, FINDPHONE_IMG_Y, ICON_IMG_SIZE_W, ICON_IMG_SIZE_H);
         drofindPhone->SetAutoEnable(false);
         drofindPhone->SetResizeMode(UIImageView::CENTER);
-        ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, drofindPhone, DROPDOWN_FINDPHONE);
+        // ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, drofindPhone, DROPDOWN_FINDPHONE);
         drofindPhone->SetViewId(DROPDOWN_CLICK_FINDMYPHONE); // 找手机界面
         drofindPhone->SetTouchable(true);
         drofindPhone->SetOnClickListener(clickListener);
@@ -400,7 +401,7 @@ namespace OHOS
             return;
         }
         dropLine->SetPosition(LINE_IMG_X, LINE_IMG_Y, ICON_IMG_SIZE_W, ICON_IMG_SIZE_H);
-        ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, dropLine, DROPDOWN_LINE);
+        // ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, dropLine, DROPDOWN_LINE);
         /* -------------------------------- 添加组件到视图上 -------------------------------- */
         group[DROPDOWNVIEW]->Add(dropSetting);
         group[DROPDOWNVIEW]->Add(dropLighting);
@@ -434,7 +435,7 @@ namespace OHOS
         //     return true;
         // else
         //     return false;
-        
+
         return SettingModel::GetInstance().GetEarPhoneConnectStatus();
     }
 
@@ -448,7 +449,7 @@ namespace OHOS
         //     return true;
         // else
         //     return false;
-        
+
         return SettingModel::GetInstance().GetBlueToothConnectStatus();
     }
 
@@ -485,14 +486,14 @@ namespace OHOS
         showPhoneConnectedStatus->SetAutoEnable(false);
         showPhoneConnectedStatus->SetResizeMode(UIImageView::CENTER);
         showPhoneConnectedStatus->SetStyle(STYLE_BORDER_RADIUS, 30);
-        if (GetPhoneConnectedStatus()) // 获取手机连接状态
-        {
-            ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, showPhoneConnectedStatus, DROPDOWN_PHONECONNECTED);
-        }
-        else
-        {
-            ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, showPhoneConnectedStatus, DROPDOWN_PHONEDISCONNECTED);
-        }
+        // if (GetPhoneConnectedStatus()) // 获取手机连接状态
+        // {
+        //     ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, showPhoneConnectedStatus, DROPDOWN_PHONECONNECTED);
+        // }
+        // else
+        // {
+        //     ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, showPhoneConnectedStatus, DROPDOWN_PHONEDISCONNECTED);
+        // }
 
         /* -------------------------------- 显示耳机连接状态 -------------------------------- */
         showEarPhoneConnectedStatus = new UIImageView();
@@ -505,14 +506,14 @@ namespace OHOS
         showEarPhoneConnectedStatus->SetAutoEnable(false);
         showEarPhoneConnectedStatus->SetResizeMode(UIImageView::CENTER);
         showEarPhoneConnectedStatus->SetStyle(STYLE_BORDER_RADIUS, 30);
-        if (GetEarPhoneConnectedStatus()) // 获取耳机连接状态
-        {
-            ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, showEarPhoneConnectedStatus, DROPDOWN_EARPHONESCONNECTED);
-        }
-        else
-        {
-            ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, showEarPhoneConnectedStatus, DROPDOWN_EARPHONESDISCONNECTED);
-        }
+        // if (GetEarPhoneConnectedStatus()) // 获取耳机连接状态
+        // {
+        //     ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, showEarPhoneConnectedStatus, DROPDOWN_EARPHONESCONNECTED);
+        // }
+        // else
+        // {
+        //     ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, showEarPhoneConnectedStatus, DROPDOWN_EARPHONESDISCONNECTED);
+        // }
 
         /* -------------------------------- 显示蓝牙连接状态 -------------------------------- */
         showBluetoothConnectedStatus = new UIImageView();
@@ -525,14 +526,14 @@ namespace OHOS
         showBluetoothConnectedStatus->SetAutoEnable(false);
         showBluetoothConnectedStatus->SetResizeMode(UIImageView::CENTER);
         showBluetoothConnectedStatus->SetStyle(STYLE_BORDER_RADIUS, 30);
-        if (GetBlueToothConnectedStatus()) // 获取蓝牙连接状态
-        {
-            ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, showBluetoothConnectedStatus, DROPDOWN_BLUETOOTHCONNECTED);
-        }
-        else
-        {
-            ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, showBluetoothConnectedStatus, DROPDOWN_BLUETOOTHDISCONNECTED);
-        }
+        // if (GetBlueToothConnectedStatus()) // 获取蓝牙连接状态
+        // {
+        //     ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, showBluetoothConnectedStatus, DROPDOWN_BLUETOOTHCONNECTED);
+        // }
+        // else
+        // {
+        //     ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, showBluetoothConnectedStatus, DROPDOWN_BLUETOOTHDISCONNECTED);
+        // }
         /* -------------------------------------------------------------------------- */
         group[DROPDOWNVIEW]->Add(showPhoneConnectedStatus);
         group[DROPDOWNVIEW]->Add(showEarPhoneConnectedStatus);
@@ -646,7 +647,7 @@ namespace OHOS
         NoSignal->SetPosition(160, 176, 36, 38);
         NoSignal->SetAutoEnable(false);
         NoSignal->SetResizeMode(UIImageView::CENTER);
-        ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, NoSignal, DROPDOWN_NOSIGNAL);
+        // ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, NoSignal, DROPDOWN_NOSIGNAL);
         NoSignal->SetVisible(false);
         group[DROPDOWNVIEW]->Add(NoSignal);
         /* -------------------------------------------------------------------------- */
@@ -920,12 +921,91 @@ namespace OHOS
 
     void PullUpDownView::PreLoad(void)
     {
-        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PullUpDownView::PreLoad");
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PullUpDownView::PreLoad");
         if (!viewiInitStatus)
         {
             PullUpDownViewInit();
             viewiInitStatus = true;
         }
+
+        if (!resLoadStatus)
+        {
+            /* -------------------------------------------------------------------------- */
+            for (int i = 0; i < MAX_INDEX; i++)
+            {
+                if (i == DNOTDISTURB_INDEX && DnotDisturbModel::GetInstance().GetDoNotDisturbModeEnabled() == true)
+                {
+                    ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, dropIconBackground[i], DROPDOWN_ICONELLIPSEPURPLE);
+                }
+                else
+                {
+                    ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, dropIconBackground[i], DROPDOWN_ICONELLIPSEBLACK);
+                }
+            }
+            /* -------------------------------------------------------------------------- */
+            ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, dropSetting, DROPDOWN_SETTING);
+            ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, dropLighting, DROPDOWN_BLUETOOTH);
+            ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, dropDnotDisturb, DROPDOWN_DNOTDISTURB);
+            ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, dropSavePower, DROPDOWN_SAVEPOWER);
+            ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, drofindPhone, DROPDOWN_FINDPHONE);
+            ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, dropLine, DROPDOWN_LINE);
+            /* -------------------------------------------------------------------------- */
+            if (GetPhoneConnectedStatus()) // 获取手机连接状态
+            {
+                ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, showPhoneConnectedStatus, DROPDOWN_PHONECONNECTED);
+            }
+            else
+            {
+                ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, showPhoneConnectedStatus, DROPDOWN_PHONEDISCONNECTED);
+            }
+
+            if (GetEarPhoneConnectedStatus()) // 获取耳机连接状态
+            {
+                ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, showEarPhoneConnectedStatus, DROPDOWN_EARPHONESCONNECTED);
+            }
+            else
+            {
+                ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, showEarPhoneConnectedStatus, DROPDOWN_EARPHONESDISCONNECTED);
+            }
+
+            if (GetBlueToothConnectedStatus()) // 获取蓝牙连接状态
+            {
+                ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, showBluetoothConnectedStatus, DROPDOWN_BLUETOOTHCONNECTED);
+            }
+            else
+            {
+                ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, showBluetoothConnectedStatus, DROPDOWN_BLUETOOTHDISCONNECTED);
+            }
+            /* -------------------------------------------------------------------------- */
+            ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, NoSignal, DROPDOWN_NOSIGNAL);
+            /* -------------------------------------------------------------------------- */
+            resLoadStatus = true;
+        }
+    }
+
+    void PullUpDownView::UnLoad(void)
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PullUpDownView::UnLoad");
+        if (resLoadStatus)
+        {
+            ImageInfo *img =nullptr;
+            for (int i = 0; i < MAX_INDEX; i++)
+            {
+                dropIconBackground[i]->SetSrc(img);
+            }
+            dropSetting->SetSrc(img);
+            dropLighting->SetSrc(img);
+            dropDnotDisturb->SetSrc(img);
+            dropSavePower->SetSrc(img);
+            drofindPhone->SetSrc(img);
+            dropLine->SetSrc(img);
+            showPhoneConnectedStatus->SetSrc(img);
+            showEarPhoneConnectedStatus->SetSrc(img);
+            showBluetoothConnectedStatus->SetSrc(img);
+            NoSignal->SetSrc(img);
+            ImageCacheManager::GetInstance().UnloadAllInMultiRes(DROPDOWN_IAMGES);
+            resLoadStatus = false;
+        }
     }
 
     // 更新手机连接状态
index 2eea946..c018577 100644 (file)
@@ -7,7 +7,8 @@
 #include "DialBinParser.h"
 #include "ModelDialDataFactory.h"
 #include "common/low_power_manager.h"
-
+#include "main/include/PullUpDownView.h"
+#include "message/include/MessageControlView.h"
 namespace OHOS {
 DialViewGroup::DialViewGroup(void)
 {
@@ -76,6 +77,7 @@ void DialViewGroup::SetDial(std::string filePath)
 
 void DialViewGroup::PreLoad(void)
 {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DialViewGroup::PreLoad");
     if (!resPreloaded_) {
         fp_ = fopen(filePath_.c_str(), "rb");
         if (fp_ == nullptr) {
@@ -93,6 +95,38 @@ void DialViewGroup::PreLoad(void)
         }
         resPreloaded_ = true;
     }
+
+    if(!resLoadStatus)
+    {
+        if(PullUpDownView::GetInstance()!=nullptr)
+        {
+            PullUpDownView::GetInstance()->PreLoad();
+        }
+
+        if(MessageControlView::GetInstance()!=nullptr)
+        {
+            MessageControlView::GetInstance()->PreLoad();
+        }
+        resLoadStatus = true;
+    }
+}
+
+void DialViewGroup::UnLoad(void)
+{
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DialViewGroup::UnLoad");
+    if(resLoadStatus)
+    {
+        if(PullUpDownView::GetInstance()!=nullptr)
+        {
+            PullUpDownView::GetInstance()->UnLoad();
+        }
+
+        if(MessageControlView::GetInstance()!=nullptr)
+        {
+            MessageControlView::GetInstance()->UnLoad();
+        }
+        resLoadStatus = false;
+    }
 }
 
 void DialViewGroup::ProcessData(DialDataType type, DialView* view)
index 0dab83d..6b63f40 100644 (file)
@@ -28,6 +28,7 @@ namespace OHOS
     public:
         MessageControlView();
         ~MessageControlView() override;
+        static MessageControlView *GetInstance();
         bool InitView(void);
         void PreLoad(void) override;
         void UnLoad(void) override;
index 13f0c57..861c2ea 100644 (file)
@@ -6,15 +6,17 @@
  */
 #include "message/include/MessageControlView.h"
 #include "message/include/MessageModel.h"
-#include"message/include/MessageControlPresenter.h"
+#include "message/include/MessageControlPresenter.h"
 #include "wearable_log.h"
 
 namespace OHOS
 {
+    static MessageControlView *g_pMessageControlView{nullptr};
     MessageControlView::MessageControlView()
     {
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MessageControlView::MessageControlView()");
         SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
+        g_pMessageControlView = this;
     }
 
     MessageControlView::~MessageControlView()
@@ -24,7 +26,14 @@ namespace OHOS
         {
             ClearAll();
         }
+        g_pMessageControlView = nullptr;
     }
+
+    MessageControlView *MessageControlView::GetInstance()
+    {
+        return g_pMessageControlView;
+    }
+
     void MessageControlView::ClearAll(void)
     {
         RemoveAll();