秒表视图修改提交
author罗正yun <1732036298@qq.com>
Wed, 13 Dec 2023 12:13:53 +0000 (20:13 +0800)
committer罗正yun <1732036298@qq.com>
Wed, 13 Dec 2023 12:13:53 +0000 (20:13 +0800)
19 files changed:
.vscode/settings.json [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/CMakeLists.txt
code/sdk/application/wearable/nativeapp/nativelauncher/include/AppViewIDs.h
code/sdk/application/wearable/nativeapp/nativelauncher/include/NativeLauncher.h
code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeLauncher.cpp
code/sdk/application/wearable/nativeapp/nativeui/screensetting/include/ScreenModels.h
code/sdk/application/wearable/nativeapp/nativeui/stopwatch/include/MainStopWatchPresenter.h
code/sdk/application/wearable/nativeapp/nativeui/stopwatch/include/MainStopWatchView.h
code/sdk/application/wearable/nativeapp/nativeui/stopwatch/include/StopWatchRecordCycleToLimitPresenter.h [deleted file]
code/sdk/application/wearable/nativeapp/nativeui/stopwatch/include/StopWatchRecordCycleToLimitView.h
code/sdk/application/wearable/nativeapp/nativeui/stopwatch/include/StopWatchRecordTimeToLimitPresenter.h [deleted file]
code/sdk/application/wearable/nativeapp/nativeui/stopwatch/include/StopWatchRecordTimeToLimitView.h
code/sdk/application/wearable/nativeapp/nativeui/stopwatch/src/MainStopWatchPresenter.cpp
code/sdk/application/wearable/nativeapp/nativeui/stopwatch/src/MainStopWatchView.cpp
code/sdk/application/wearable/nativeapp/nativeui/stopwatch/src/StopWatchRecordCycleToLimitPresenter.cpp [deleted file]
code/sdk/application/wearable/nativeapp/nativeui/stopwatch/src/StopWatchRecordCycleToLimitView.cpp
code/sdk/application/wearable/nativeapp/nativeui/stopwatch/src/StopWatchRecordTimeToLimitPresenter.cpp [deleted file]
code/sdk/application/wearable/nativeapp/nativeui/stopwatch/src/StopWatchRecordTimeToLimitView.cpp
code/sdk/drivers/chips/brandy/porting/uart/uart_porting.c

diff --git a/.vscode/settings.json b/.vscode/settings.json
new file mode 100644 (file)
index 0000000..011a1a6
--- /dev/null
@@ -0,0 +1,9 @@
+{
+    "files.associations": {
+        "*.def": "cpp",
+        "limits": "cpp",
+        "*.tcc": "cpp",
+        "type_traits": "cpp",
+        "iterator": "cpp"
+    }
+}
\ No newline at end of file
index cf7b694..58e40e1 100755 (executable)
@@ -342,9 +342,7 @@ set(SOURCES
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/stopwatch/src/MainStopWatchPresenter.cpp\r
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/stopwatch/src/MainStopWatchView.cpp\r
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/stopwatch/src/StopWatchModel.cpp\r
-    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/stopwatch/src/StopWatchRecordCycleToLimitPresenter.cpp\r
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/stopwatch/src/StopWatchRecordCycleToLimitView.cpp\r
-    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/stopwatch/src/StopWatchRecordTimeToLimitPresenter.cpp\r
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/stopwatch/src/StopWatchRecordTimeToLimitView.cpp\r
 \r
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/displaybrightness/src/DisplayBrightnessModel.cpp\r
index c1b85fd..ceb8399 100755 (executable)
@@ -117,8 +117,6 @@ typedef enum : uint16_t
     VIEW_PHONECALLUP,  // 通话界面\r
     VIEW_PHONEDIR,     // 电话簿\r
     VIEW_MAIN_STOPWATCH,// 秒表主视图\r
-    VIEW_STOPWATCH_RECORD_CYCLE_TO_LIMIT, //秒表记录圈速到达上限\r
-    VIEW_STOPWATCH_RECORD_TIME_TO_LIMIT,  //秒表记录时间到达上限\r
     VIEW_MAIN_COUNTDOWN,// 倒计时主视图\r
     VIEW_COUNTDOWN_TIME_CONFIG,//倒计时时间配置\r
     VIEW_START_COUNTDOWN,//开始倒计时\r
index 3684c83..7f914ab 100755 (executable)
@@ -121,8 +121,6 @@ public:
     void InitStartCountDownSlice(void);\r
     void InitCountDownTimeNotNullSlice(void);\r
     void InitMainStopWatchSlice(void);\r
-    void InitStopWatchRecordCycleToLimitSlice(void);\r
-    void InitStopWatchRecordTimeToLimitSlice(void);\r
 private:\r
     void InitAllNativeSlices(void);\r
 \r
index d211d99..4e87e7e 100755 (executable)
 #include "countdown/include/CountDownTimeNotNullView.h"\r
 #include "stopwatch/include/MainStopWatchPresenter.h"\r
 #include "stopwatch/include/MainStopWatchView.h"\r
-#include "stopwatch/include/StopWatchRecordCycleToLimitPresenter.h"\r
-#include "stopwatch/include/StopWatchRecordCycleToLimitView.h"\r
-#include "stopwatch/include/StopWatchRecordTimeToLimitPresenter.h"\r
-#include "stopwatch/include/StopWatchRecordTimeToLimitView.h"\r
 \r
 namespace OHOS {\r
 struct AppViewMapper\r
@@ -335,8 +331,6 @@ static const AppViewMapper SLICE_MAPPER[] = {
     {VIEW_START_COUNTDOWN,&NativeLauncher::InitStartCountDownSlice},                             //开始倒计时\r
     {VIEW_COUNTDOWN_TIME_NOT_NULL,&NativeLauncher::InitCountDownTimeNotNullSlice},               //倒计时不能为0\r
     {VIEW_MAIN_STOPWATCH,&NativeLauncher::InitMainStopWatchSlice},                               //秒表主视图\r
-    {VIEW_STOPWATCH_RECORD_CYCLE_TO_LIMIT,&NativeLauncher::InitStopWatchRecordCycleToLimitSlice},\r
-    {VIEW_STOPWATCH_RECORD_TIME_TO_LIMIT,&NativeLauncher::InitStopWatchRecordTimeToLimitSlice},\r
     {VIEW_UISAMPLE, &NativeLauncher::InitUISampleSlice}\r
 };\r
 \r
@@ -398,9 +392,7 @@ static const ViewIdToString VIEW_MAPPER[] = {
     {VIEW_COUNTDOWN_TIME_CONFIG,"CountDownTimeConfig"},\r
     {VIEW_START_COUNTDOWN,"StartCountDown"},\r
     {VIEW_COUNTDOWN_TIME_NOT_NULL,"CountDownTimeNotNull"}, \r
-    {VIEW_MAIN_STOPWATCH,"MainStopWatch"},\r
-    {VIEW_STOPWATCH_RECORD_CYCLE_TO_LIMIT,"StopWatchRecordCycleToLimit"},      \r
-    {VIEW_STOPWATCH_RECORD_TIME_TO_LIMIT,"StopWatchRecordTimeToLimit"},                         \r
+    {VIEW_MAIN_STOPWATCH,"MainStopWatch"},                        \r
     {VIEW_UISAMPLE, "UISample"}\r
 };\r
 \r
@@ -1319,22 +1311,4 @@ void NativeLauncher::InitMainStopWatchSlice(void)  //倒计时时间不能为0
     }\r
     NativeAbility::GetInstance().AddSliceProxy(VIEW_MAIN_STOPWATCH, mainstopwatch);\r
 }\r
-\r
-void NativeLauncher::InitStopWatchRecordCycleToLimitSlice(void)\r
-{  \r
-    SliceProxy *stopwatchrecordcycletolimit = new AbilitySliceProxy<StopWatchRecordCycleToLimitView,StopWatchRecordCycleToLimitPresenter>;\r
-    if (stopwatchrecordcycletolimit == nullptr) {\r
-        return;\r
-    }\r
-    NativeAbility::GetInstance().AddSliceProxy(VIEW_STOPWATCH_RECORD_CYCLE_TO_LIMIT, stopwatchrecordcycletolimit);\r
-}\r
-\r
-void NativeLauncher::InitStopWatchRecordTimeToLimitSlice(void)  \r
-{\r
-    SliceProxy *stopwatchrecordtimetolimit = new AbilitySliceProxy<StopWatchRecordTimeToLimitView,StopWatchRecordTimeToLimitPresenter>;\r
-    if (stopwatchrecordtimetolimit == nullptr) {\r
-        return;\r
-    }\r
-    NativeAbility::GetInstance().AddSliceProxy(VIEW_STOPWATCH_RECORD_TIME_TO_LIMIT, stopwatchrecordtimetolimit);\r
-}\r
 }\r
index 3553965..bf5d0c8 100755 (executable)
 \r
 namespace OHOS {\r
 typedef enum {\r
-    MUSIC_PLAYER = 0,\r
+    WATCH_FACE = 0,\r
     HEART_RATE,\r
     COMPASS,\r
     ACTIVITY,\r
-    WATCH_FACE,\r
+    MUSIC_PLAYER ,\r
     MAX_CARD,\r
 } CardId;\r
 \r
index bdfbb26..e355ed6 100755 (executable)
@@ -4,13 +4,24 @@
 #include "Presenter.h"\r
 #include "MainStopWatchView.h"\r
 #include "components/ui_checkbox.h"\r
+#include "components/ui_button.h"\r
+#include "components/ui_label.h"\r
+#include <string>\r
 /*秒表主视图*/\r
 namespace OHOS\r
 {\r
+    typedef enum\r
+    {\r
+        MAIN_STOPWATCH = 0,              // 秒表主视图\r
+        STOPWATCH_RECORD_CYCLE_TO_LIMIT, // 到达秒表计时的最高记录圈数后弹出视图\r
+        STOPWATCH_RECORD_TIME_TO_LIMIT,  // 到达秒表最大的记录时间后弹出该视图\r
+        STOPWATCH_MAXVIEWID,             // 秒表的视图id数量\r
+    } StopWatchViewId;\r
     class MainStopWatchView;\r
     class MainStopWatchPresenter : public Presenter<MainStopWatchView>,\r
                                    public UIView::OnClickListener,\r
-                                   public UIView::OnDragListener\r
+                                   public UIView::OnDragListener,\r
+                                   public UICheckBox::OnChangeListener\r
     {\r
     public:\r
         MainStopWatchPresenter();\r
@@ -20,11 +31,23 @@ namespace OHOS
         void OnResume() override;\r
         void OnStop() override;\r
         static MainStopWatchPresenter *GetInstance();\r
+        void SetCheckBoxAndButton(UICheckBox *checkbox, UIButton *button);\r
+        void SetLable(UILabel *label1, UILabel *label2);\r
+        void SetShowTimeLableStyle(UILabel *label, int x, int y, int TextFont, int LineHeight);\r
 \r
     private:\r
         // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承;\r
         bool OnClick(UIView &view, const ClickEvent &event) override;\r
         bool OnDrag(UIView &view, const DragEvent &event) override;\r
+        bool OnChange(UICheckBox::UICheckBoxState state) override;\r
+\r
+    private:\r
+        UICheckBox *m_checkbox{nullptr};\r
+        UIButton *m_button{nullptr};\r
+        UILabel *m_stopWatchlabel{nullptr};\r
+        UILabel *m_showTimelabel{nullptr};\r
+        int RecordCycleNumber{0};              // 用来记录点击计时按钮("Mark")的次数\r
+        std::string RecordMaxTime{"99:59.59"}; // 计时时间最高为99:59.59\r
     };\r
 } // namespace OHOS\r
 \r
index 2d6176c..9429c9b 100755 (executable)
@@ -8,6 +8,8 @@
 #include "components/ui_label.h"\r
 #include "components/ui_checkbox.h"\r
 #include "components/ui_button.h"\r
+#include "stopwatch/include/StopWatchRecordCycleToLimitView.h"\r
+#include "stopwatch/include/StopWatchRecordTimeToLimitView.h"\r
 /*秒表主视图*/\r
 namespace OHOS\r
 {\r
@@ -34,16 +36,26 @@ namespace OHOS
         void OnSetUpView() override;\r
         void OnTearDownView() override;\r
         void OnStop() override;\r
+        void SetViewIsVisible(UIView *view, bool status);\r
+        bool ClickFunc(int16_t interface);\r
+        void ChangeView(int16_t hideView, int16_t showView);\r
+        bool ChangeMainStopWatch(int16_t thisView);\r
+        bool ChangeStopWatchRecordCycleLimit(int16_t thisView);\r
+        bool ChangeMainStopWatchRecordTimeLimit(int16_t thisView);\r
 \r
     private:\r
-        void InitView(void);\r
+        void InitMainStopWatchView(void);\r
         void DeInitView(void);\r
         void PreLoad(void);\r
 \r
+    private:\r
+        StopWatchRecordCycleToLimitView *p_StopWatchRecordCycleToLimitView{nullptr}; // 圈数到达上限后弹出该视图\r
+        StopWatchRecordTimeToLimitView *p_StopWatchRecordTimeToLimitView{nullptr};   // 计时时间到达上限后弹出该视图\r
+\r
     private:\r
         UIViewGroup *container_ = nullptr;\r
-        UIScrollView *scrollView1_ = nullptr;\r
-        UILabel *label1_ = nullptr;\r
+        UIScrollView *scrollView[3] = {nullptr};\r
+        UILabel *stopWatchlabel = nullptr;         // 内容为“秒表”的标签\r
         UILabel *showTimelabel = nullptr;          // 用来显示计时时间\r
         UICheckBox *PlayOrPausecheckBox = nullptr; // 播放或暂停复选框\r
         UIButton *ResetOrMarkbutton = nullptr;     // 重置或标记按钮\r
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/stopwatch/include/StopWatchRecordCycleToLimitPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/stopwatch/include/StopWatchRecordCycleToLimitPresenter.h
deleted file mode 100755 (executable)
index 0d548cd..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-#ifndef STOPWATCH_RECORD_CYCLE_TO_LIMIT_PRESENTER_H\r
-#define STOPWATCH_RECORD_CYCLE_TO_LIMIT_PRESENTER_H\r
-\r
-#include "Presenter.h"\r
-#include "StopWatchRecordCycleToLimitView.h"\r
-\r
-/*弹窗视图:到达最高圈数99时弹出*/\r
-namespace OHOS\r
-{\r
-    class StopWatchRecordCycleToLimitView;\r
-\r
-    class StopWatchRecordCycleToLimitPresenter : public Presenter<StopWatchRecordCycleToLimitView>,\r
-                                                 public UIView::OnClickListener,\r
-                                                 public UIView::OnDragListener\r
-    {\r
-    public:\r
-        StopWatchRecordCycleToLimitPresenter();\r
-        virtual ~StopWatchRecordCycleToLimitPresenter();\r
-\r
-        void OnStart() override;\r
-        void OnPause() override;\r
-        void OnResume() override;\r
-        void OnStop() override;\r
-\r
-        static StopWatchRecordCycleToLimitPresenter *GetInstance();\r
-\r
-    private:\r
-        // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承;\r
-        bool OnClick(UIView &view, const ClickEvent &event) override;\r
-        bool OnDrag(UIView &view, const DragEvent &event) override;\r
-    };\r
-} // namespace OHOS\r
-\r
-#endif
\ No newline at end of file
index f69f361..390fa0c 100755 (executable)
 /*弹窗视图:到达最高圈数99时弹出*/\r
 namespace OHOS\r
 {\r
-    class StopWatchRecordCycleToLimitPresenter;\r
-    class StopWatchRecordCycleToLimitView : public View<StopWatchRecordCycleToLimitPresenter>\r
+    class StopWatchRecordCycleToLimitView\r
     {\r
 \r
     public:\r
         StopWatchRecordCycleToLimitView();\r
+        void DeInitView(void);\r
         virtual ~StopWatchRecordCycleToLimitView();\r
         static StopWatchRecordCycleToLimitView *GetInstance(void);\r
-\r
-        void OnStart() override;\r
-        void OnSetUpView() override;\r
-        void OnTearDownView() override;\r
-        void OnStop() override;\r
-\r
-    private:\r
-        void InitView(void);\r
-        void DeInitView(void);\r
-        void PreLoad(void);\r
+        UIScrollView *InitStopWatchRecordCycleToLimitView(void);\r
 \r
     private:\r
         UIViewGroup *container_ = nullptr;\r
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/stopwatch/include/StopWatchRecordTimeToLimitPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/stopwatch/include/StopWatchRecordTimeToLimitPresenter.h
deleted file mode 100755 (executable)
index 6a158dd..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef STOPWATCH_RECORD_TIME_TO_LIMIT_PRESENTER_H\r
-#define STOPWATCH_RECORD_TIME_TO_LIMIT_PRESENTER_H\r
-\r
-#include "Presenter.h"\r
-#include "StopWatchRecordTimeToLimitView.h"\r
-/*弹窗视图:到达最高时间99:59.99时弹出*/\r
-namespace OHOS\r
-{\r
-    class StopWatchRecordTimeToLimitView;\r
-    class StopWatchRecordTimeToLimitPresenter : public Presenter<StopWatchRecordTimeToLimitView>,\r
-                                                public UIView::OnClickListener,\r
-                                                public UIView::OnDragListener\r
-    {\r
-    public:\r
-        StopWatchRecordTimeToLimitPresenter();\r
-        virtual ~StopWatchRecordTimeToLimitPresenter();\r
-\r
-        void OnStart() override;\r
-        void OnPause() override;\r
-        void OnResume() override;\r
-        void OnStop() override;\r
-\r
-        static StopWatchRecordTimeToLimitPresenter *GetInstance();\r
-\r
-    private:\r
-        // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承;\r
-        bool OnClick(UIView &view, const ClickEvent &event) override;\r
-        bool OnDrag(UIView &view, const DragEvent &event) override;\r
-    };\r
-} // namespace OHOS\r
-\r
-#endif
\ No newline at end of file
index 9667176..22495f2 100755 (executable)
 /*弹窗视图:到达最高时间99:59.99时弹出*/\r
 namespace OHOS\r
 {\r
-    class StopWatchRecordTimeToLimitPresenter;\r
-    class StopWatchRecordTimeToLimitView : public View<StopWatchRecordTimeToLimitPresenter>\r
+    class StopWatchRecordTimeToLimitView\r
     {\r
-\r
     public:\r
         StopWatchRecordTimeToLimitView();\r
         virtual ~StopWatchRecordTimeToLimitView();\r
         static StopWatchRecordTimeToLimitView *GetInstance(void);\r
-\r
-        void OnStart() override;\r
-        void OnSetUpView() override;\r
-        void OnTearDownView() override;\r
-        void OnStop() override;\r
-\r
-    private:\r
-        void InitView(void);\r
+        UIScrollView *InitStopWatchRecordTimeToLimitView(void);\r
         void DeInitView(void);\r
-        void PreLoad(void);\r
 \r
     private:\r
-        UIViewGroup *container_ = nullptr;\r
         UIScrollView *scrollView1_ = nullptr;\r
         UILabel *label1_ = nullptr;\r
         UIImageView *image1_ = nullptr;\r
index 8cd78aa..dd5f176 100755 (executable)
@@ -50,9 +50,42 @@ namespace OHOS
         Presenter<MainStopWatchView>::OnStop();\r
     }\r
 \r
-    bool MainStopWatchPresenter::OnDrag(UIView &view, const DragEvent &event)\r
+    /// @brief 设置复选框和按钮\r
+    /// @param checkbox\r
+    /// @param button\r
+    void MainStopWatchPresenter::SetCheckBoxAndButton(UICheckBox *checkbox, UIButton *button)\r
+    {\r
+        m_checkbox = checkbox;\r
+        m_button = button;\r
+    }\r
+\r
+    /// @brief 设置标签\r
+    /// @param label1\r
+    /// @param label2\r
+    void MainStopWatchPresenter::SetLable(UILabel *label1, UILabel *label2)\r
+    {\r
+        m_stopWatchlabel = label1;\r
+        m_showTimelabel = label2;\r
+    }\r
+\r
+    /// @brief 设置显示时间的标签样式\r
+    /// @param label\r
+    /// @param x\r
+    /// @param y\r
+    /// @param TextFont\r
+    /// @param LineHeight\r
+    void MainStopWatchPresenter::SetShowTimeLableStyle(UILabel *label, int x, int y, int TextFont, int LineHeight)\r
     {\r
+        label->SetPosition(x, y);\r
+        label->SetStyle(STYLE_TEXT_FONT, TextFont);\r
+        label->SetStyle(STYLE_LINE_HEIGHT, LineHeight);\r
+        label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, TextFont);\r
+        label->Invalidate();\r
+    }\r
 \r
+    bool MainStopWatchPresenter::OnDrag(UIView &view, const DragEvent &event)\r
+    {\r
+        UNUSED(view);\r
         if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT &&\r
             (event.GetDeltaX() > 20) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY()))))\r
         {\r
@@ -64,7 +97,62 @@ namespace OHOS
     bool MainStopWatchPresenter::OnClick(UIView &view, const ClickEvent &event)\r
     {\r
         UNUSED(view);\r
-        UNUSED(event);\r
+        if (strcmp(view.GetViewId(), ResetOrMarkButton_MARK_VIEWID) == 0)\r
+        {\r
+            printf("mark!\n");\r
+            RecordCycleNumber += 1;\r
+            printf("RecordCycleNumber:%d\n", RecordCycleNumber);\r
+            if (RecordCycleNumber > 3)\r
+            {\r
+                // MainStopWatchView::GetInstance()->ChangeView(MAIN_STOPWATCH, STOPWATCH_RECORD_CYCLE_TO_LIMIT);\r
+                MainStopWatchView::GetInstance()->ChangeView(MAIN_STOPWATCH, STOPWATCH_RECORD_TIME_TO_LIMIT);\r
+                return true;\r
+            }\r
+            /* -------------------------------------------------------------------------- */\r
+            MainStopWatchView::GetInstance()->SetViewIsVisible(m_stopWatchlabel, false);\r
+            /* -------------------------------------------------------------------------- */\r
+            SetShowTimeLableStyle(m_showTimelabel, 93, 60, 65, 78);\r
+            /* -------------------------------------------------------------------------- */\r
+        }\r
+        else if (strcmp(view.GetViewId(), ResetOrMarkButton_RESET2_VIEWID) == 0)\r
+        {\r
+            printf("Reset2!\n");\r
+            m_button->SetViewId(ResetOrMarkButton_RESET1_VIEWID);\r
+            m_button->SetImageSrc(ResetOrMarkButtonImg_Reset1, ResetOrMarkButtonImg_Reset1);\r
+            m_button->Invalidate();\r
+            /* -------------------------------------------------------------------------- */\r
+            MainStopWatchView::GetInstance()->SetViewIsVisible(m_stopWatchlabel, true);\r
+            /* -------------------------------------------------------------------------- */\r
+            SetShowTimeLableStyle(m_showTimelabel, 63, 160, 80, 94);\r
+            /* -------------------------------------------------------------------------- */\r
+        }\r
+        else if (strcmp(view.GetViewId(), "CycleToLimitReturnButton") == 0)\r
+        {\r
+            MainStopWatchView::GetInstance()->ChangeView(STOPWATCH_RECORD_CYCLE_TO_LIMIT, MAIN_STOPWATCH);\r
+            return true;\r
+        }\r
+        else if (strcmp(view.GetViewId(), "TimeToLimitReturnButton") == 0)\r
+        {\r
+            MainStopWatchView::GetInstance()->ChangeView(STOPWATCH_RECORD_TIME_TO_LIMIT, MAIN_STOPWATCH);\r
+            return true;\r
+        }\r
+        return true;\r
+    }\r
+\r
+    bool MainStopWatchPresenter::OnChange(UICheckBox::UICheckBoxState state)\r
+    {\r
+        if (state == UICheckBox::UICheckBoxState::SELECTED)\r
+        {\r
+            m_button->SetViewId(ResetOrMarkButton_MARK_VIEWID);\r
+            m_button->SetImageSrc(ResetOrMarkButtonImg_Mark, nullptr);\r
+            m_button->Invalidate(); // 图片重新赋值要刷新该区域\r
+        }\r
+        else\r
+        {\r
+            m_button->SetViewId(ResetOrMarkButton_RESET2_VIEWID);\r
+            m_button->SetImageSrc(ResetOrMarkButtonImg_Reset2, nullptr);\r
+            m_button->Invalidate();\r
+        }\r
         return true;\r
     }\r
 }
\ No newline at end of file
index 29c080b..5c42304 100755 (executable)
 /*秒表主视图*/\r
 namespace OHOS\r
 {\r
-    /*点击该复选框会播放或暂停计时*/\r
-    class PlayOrPausecheckBoxOnChangeListener : public UICheckBox::OnChangeListener\r
+\r
+    static MainStopWatchView *g_pMainStopWatchView{nullptr};\r
+\r
+    MainStopWatchView::MainStopWatchView()\r
     {\r
-    public:\r
-        PlayOrPausecheckBoxOnChangeListener(UICheckBox *checkbox, UIButton *button)\r
-        {\r
-            m_checkbox = checkbox;\r
-            m_button = button;\r
-        }\r
-        bool OnChange(UICheckBox::UICheckBoxState state) override\r
+\r
+        g_pMainStopWatchView = this;\r
+    }\r
+\r
+    MainStopWatchView::~MainStopWatchView()\r
+    {\r
+        if (viewInitStatus == true)\r
         {\r
-            if (state == UICheckBox::UICheckBoxState::SELECTED)\r
-            {\r
-                m_button->SetViewId(ResetOrMarkButton_MARK_VIEWID);\r
-                m_button->SetImageSrc(ResetOrMarkButtonImg_Mark, nullptr);\r
-                m_button->Invalidate(); // 图片重新赋值要刷新该区域\r
-            }\r
-            else\r
-            {\r
-                m_button->SetViewId(ResetOrMarkButton_RESET2_VIEWID);\r
-                m_button->SetImageSrc(ResetOrMarkButtonImg_Reset2, nullptr);\r
-                m_button->Invalidate();\r
-            }\r
-            return true;\r
+            DeInitView();\r
         }\r
+        g_pMainStopWatchView = nullptr;\r
+    }\r
 \r
-    private:\r
-        UICheckBox *m_checkbox{nullptr};\r
-        UIButton *m_button{nullptr};\r
-    };\r
-    int flag = 0;\r
-    /*标记或重置时间按钮监听*/\r
-    class ResetOrMarkbuttonOnClickListener : public UIView::OnClickListener\r
+    MainStopWatchView *MainStopWatchView::GetInstance()\r
+    {\r
+\r
+        return g_pMainStopWatchView;\r
+    }\r
+\r
+    /// @brief 设置视图是否可见\r
+    /// @param view 具体视图\r
+    /// @param status true 可见 false 不可见\r
+    void MainStopWatchView::SetViewIsVisible(UIView *view, bool status)\r
     {\r
-    public:\r
-        ResetOrMarkbuttonOnClickListener(UIButton *button)\r
+        if (status == true)\r
         {\r
-            m_button = button;\r
+            view->SetVisible(true);\r
         }\r
+        else\r
+        {\r
+            view->SetVisible(false);\r
+        }\r
+        RootView::GetInstance()->Invalidate();\r
+    }\r
+\r
+    // 切换到秒表主视图\r
+    bool MainStopWatchView::ChangeMainStopWatch(int16_t thisView)\r
+    {\r
+        container_->Add(scrollView[thisView]);\r
+        return true;\r
+    }\r
 \r
-        bool OnClick(UIView &view, const ClickEvent &event) override\r
+    // 切换到秒表到达最高圈数视图\r
+    bool MainStopWatchView::ChangeStopWatchRecordCycleLimit(int16_t thisView)\r
+    {\r
+        if (scrollView[thisView] == nullptr)\r
         {\r
-            if (strcmp(view.GetViewId(), ResetOrMarkButton_MARK_VIEWID) == 0)\r
+            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainAlarmView::StopWatchRecordCycleToLimitView");\r
+            p_StopWatchRecordCycleToLimitView = new StopWatchRecordCycleToLimitView();\r
+            if (p_StopWatchRecordCycleToLimitView == nullptr)\r
             {\r
-                printf("mark!\n");\r
-                if (flag == 0)\r
-                {\r
-                    flag = 1;\r
-                    NativeAbility::GetInstance().ChangeSlice(VIEW_STOPWATCH_RECORD_CYCLE_TO_LIMIT);\r
-                }\r
-                else\r
-                {\r
-                    flag = 0;\r
-                    NativeAbility::GetInstance().ChangeSlice(VIEW_STOPWATCH_RECORD_TIME_TO_LIMIT);\r
-                }\r
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainStopWatchView:: new scrollView[%d] fail", thisView);\r
+                return false;\r
             }\r
-            else if (strcmp(view.GetViewId(), ResetOrMarkButton_RESET2_VIEWID) == 0)\r
+            scrollView[thisView] = p_StopWatchRecordCycleToLimitView->InitStopWatchRecordCycleToLimitView();\r
+            container_->Add(scrollView[thisView]);\r
+        }\r
+        return true;\r
+    }\r
+\r
+    // 切换到秒表到达最大时间计时视图\r
+    bool MainStopWatchView::ChangeMainStopWatchRecordTimeLimit(int16_t thisView)\r
+    {\r
+        if (scrollView[thisView] == nullptr)\r
+        {\r
+            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainAlarmView::ChangeMainStopWatchRecordTimeLimit");\r
+            p_StopWatchRecordTimeToLimitView = new StopWatchRecordTimeToLimitView();\r
+            if (p_StopWatchRecordTimeToLimitView == nullptr)\r
             {\r
-                printf("Reset2!\n");\r
-                m_button->SetViewId(ResetOrMarkButton_RESET1_VIEWID);\r
-                m_button->SetImageSrc(ResetOrMarkButtonImg_Reset1, ResetOrMarkButtonImg_Reset1);\r
-                m_button->Invalidate();\r
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainStopWatchView:: new scrollView[%d] fail", thisView);\r
+                return false;\r
             }\r
-            return true;\r
+            scrollView[thisView] = p_StopWatchRecordTimeToLimitView->InitStopWatchRecordTimeToLimitView();\r
+            container_->Add(scrollView[thisView]);\r
         }\r
-        UIButton *m_button{nullptr};\r
+        return true;\r
+    }\r
+    /* -------------------------------------------------------------------------- */\r
+    // 1.MainStopWatchViewMapper:结构体定义了一个将视图ID映射到特定成员函数指针的映射表。\r
+    struct MainStopWatchViewMapper\r
+    {\r
+        const int16_t viewId;\r
+        bool (MainStopWatchView::*func)(int16_t thisView);\r
     };\r
-}\r
-namespace OHOS\r
-{\r
-\r
-    static MainStopWatchView *g_pMainStopWatchView{nullptr};\r
 \r
-    MainStopWatchView::MainStopWatchView()\r
+    // 2.ViewMapper[] 是一个静态的视图映射数组,将视图ID与MainStopWatchView类中的特定成员函数指针进行了绑定。\r
+    static const MainStopWatchViewMapper ViewMapper[] =\r
     {\r
+        {MAIN_STOPWATCH, &MainStopWatchView::ChangeMainStopWatch},\r
+        {STOPWATCH_RECORD_CYCLE_TO_LIMIT, &MainStopWatchView::ChangeStopWatchRecordCycleLimit},\r
+        {STOPWATCH_RECORD_TIME_TO_LIMIT, &MainStopWatchView::ChangeMainStopWatchRecordTimeLimit}\r
+    };\r
 \r
-        g_pMainStopWatchView = this;\r
-    }\r
-\r
-    MainStopWatchView::~MainStopWatchView()\r
+    // 3.根据传入的interface参数执行相应视图ID关联的成员函数。\r
+    bool MainStopWatchView::ClickFunc(int16_t interface)\r
     {\r
-        if (viewInitStatus == true)\r
+        int funcSize = sizeof(ViewMapper) / sizeof(ViewMapper[0]);\r
+        for (int i = 0; i < funcSize; i++)\r
         {\r
-            DeInitView();\r
+            if (interface == ViewMapper[i].viewId)\r
+            {\r
+                bool jug = (this->*(ViewMapper[i].func))(interface);\r
+                if (jug == false)\r
+                {\r
+                    return false;\r
+                }\r
+                return true;\r
+            }\r
         }\r
-        g_pMainStopWatchView = nullptr;\r
+        return false;\r
     }\r
 \r
-    MainStopWatchView *MainStopWatchView::GetInstance()\r
+    // 4.切换视图\r
+    void MainStopWatchView::ChangeView(int16_t hideView, int16_t showView)\r
     {\r
-\r
-        return g_pMainStopWatchView;\r
+        if (hideView > STOPWATCH_MAXVIEWID)\r
+        {\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainStopWatchView:: StopWatchViewId Overstep ones bounds");\r
+            return;\r
+        }\r
+        scrollView[hideView]->SetVisible(false);\r
+        ClickFunc(showView);\r
+        scrollView[showView]->SetVisible(true);\r
+        Draw();\r
     }\r
-\r
-    void MainStopWatchView::InitView()\r
+    /* -------------------------------------------------------------------------- */\r
+    // 初始化秒表主视图\r
+    void MainStopWatchView::InitMainStopWatchView()\r
     {\r
-        if (scrollView1_ == nullptr)\r
+        if (scrollView[MAIN_STOPWATCH] == nullptr)\r
         {\r
-            scrollView1_ = new UIScrollView();\r
+            scrollView[MAIN_STOPWATCH] = new UIScrollView();\r
         }\r
-        scrollView1_->SetPosition(0, 0);\r
-        scrollView1_->Resize(466, 466);\r
-        scrollView1_->SetViewId("scrollView1");\r
-        scrollView1_->SetStyle(STYLE_BACKGROUND_OPA, 0xff);\r
-        container_->Add(scrollView1_);\r
-        scrollView1_->SetVisible(true);\r
+        scrollView[MAIN_STOPWATCH]->SetPosition(0, 0);\r
+        scrollView[MAIN_STOPWATCH]->Resize(466, 466);\r
+        scrollView[MAIN_STOPWATCH]->SetViewId("scrollView1");\r
+        scrollView[MAIN_STOPWATCH]->SetStyle(STYLE_BACKGROUND_OPA, 0xff);\r
+        container_->Add(scrollView[MAIN_STOPWATCH]);\r
+        scrollView[MAIN_STOPWATCH]->SetVisible(true);\r
         /* -------------------------------------------------------------------------- */\r
-        if (label1_ == nullptr)\r
+        if (stopWatchlabel == nullptr)\r
         {\r
-            label1_ = new UILabel();\r
+            stopWatchlabel = new UILabel();\r
         }\r
-        label1_->SetPosition(203, 52);\r
-        label1_->Resize(60, 35);\r
-        label1_->SetViewId("label1");\r
-        label1_->SetStyle(STYLE_TEXT_FONT, 30);\r
-        label1_->SetStyle(STYLE_LINE_HEIGHT, 35);\r
-        label1_->SetText("秒表");\r
-        label1_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);\r
-        label1_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
-        label1_->SetRollSpeed(0);\r
-        label1_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
-        scrollView1_->Add(label1_);\r
-        label1_->SetVisible(true);\r
+        stopWatchlabel->SetPosition(203, 52);\r
+        stopWatchlabel->Resize(60, 35);\r
+        stopWatchlabel->SetViewId("label1");\r
+        stopWatchlabel->SetStyle(STYLE_TEXT_FONT, 30);\r
+        stopWatchlabel->SetStyle(STYLE_LINE_HEIGHT, 35);\r
+        stopWatchlabel->SetText("秒表");\r
+        stopWatchlabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);\r
+        stopWatchlabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
+        stopWatchlabel->SetRollSpeed(0);\r
+        stopWatchlabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
+        scrollView[MAIN_STOPWATCH]->Add(stopWatchlabel);\r
+        stopWatchlabel->SetVisible(true);\r
         /* -------------------------------------------------------------------------- */\r
         if (showTimelabel == nullptr)\r
         {\r
@@ -144,7 +182,7 @@ namespace OHOS
         showTimelabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
         showTimelabel->SetRollSpeed(0);\r
         showTimelabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 80);\r
-        scrollView1_->Add(showTimelabel);\r
+        scrollView[MAIN_STOPWATCH]->Add(showTimelabel);\r
         showTimelabel->SetVisible(true);\r
         /* -------------------------------------------------------------------------- */\r
         // Add CheckBox to App\r
@@ -153,13 +191,13 @@ namespace OHOS
             PlayOrPausecheckBox = new UICheckBox();\r
         }\r
         PlayOrPausecheckBox->SetPosition(118, 321);\r
-        PlayOrPausecheckBox->Resize(100, 100);\r
+        PlayOrPausecheckBox->Resize(120, 120);\r
         PlayOrPausecheckBox->SetViewId(PlayOrPausecheckBoxVIEWID);\r
         PlayOrPausecheckBox->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff);\r
         PlayOrPausecheckBox->SetStyle(STYLE_BORDER_RADIUS, 51);\r
         PlayOrPausecheckBox->SetImages(checkBox1selectedImg, checkBox1unSelectedImg);\r
         // Add to scrollView1\r
-        scrollView1_->Add(PlayOrPausecheckBox);\r
+        scrollView[MAIN_STOPWATCH]->Add(PlayOrPausecheckBox);\r
         PlayOrPausecheckBox->SetVisible(true);\r
         /* -------------------------------------------------------------------------- */\r
         // Add Button to App\r
@@ -167,7 +205,7 @@ namespace OHOS
         {\r
             ResetOrMarkbutton = new UIButton();\r
         }\r
-        ResetOrMarkbutton->SetPosition(248, 321);\r
+        ResetOrMarkbutton->SetPosition(256, 333);\r
         ResetOrMarkbutton->Resize(100, 100);\r
         ResetOrMarkbutton->SetViewId(ResetOrMarkButton_RESET1_VIEWID);\r
         ResetOrMarkbutton->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff);\r
@@ -176,22 +214,24 @@ namespace OHOS
         ResetOrMarkbutton->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xfffbfbfb, UIButton::PRESSED);\r
         ResetOrMarkbutton->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED);\r
         ResetOrMarkbutton->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);\r
-        scrollView1_->Add(ResetOrMarkbutton);\r
+        scrollView[MAIN_STOPWATCH]->Add(ResetOrMarkbutton);\r
         ResetOrMarkbutton->SetVisible(true);\r
         /* -------------------------------------------------------------------------- */\r
+        MainStopWatchPresenter::GetInstance()->SetCheckBoxAndButton(PlayOrPausecheckBox, ResetOrMarkbutton);\r
+        MainStopWatchPresenter::GetInstance()->SetLable(stopWatchlabel, showTimelabel);\r
         // Add the CallBack about events\r
-        PlayOrPausecheckBoxChangeListener = static_cast<UICheckBox::OnChangeListener *>(new PlayOrPausecheckBoxOnChangeListener(PlayOrPausecheckBox, ResetOrMarkbutton));\r
+        PlayOrPausecheckBoxChangeListener = static_cast<UICheckBox::OnChangeListener *>(MainStopWatchPresenter::GetInstance());\r
         PlayOrPausecheckBox->SetOnChangeListener(PlayOrPausecheckBoxChangeListener);\r
-        ResetOrMarkbuttonClick = static_cast<UIView::OnClickListener *>(new ResetOrMarkbuttonOnClickListener(ResetOrMarkbutton));\r
+        ResetOrMarkbuttonClick = static_cast<UIView::OnClickListener *>(MainStopWatchPresenter::GetInstance());\r
         ResetOrMarkbutton->SetOnClickListener(ResetOrMarkbuttonClick);\r
     }\r
 \r
     void MainStopWatchView::DeInitView()\r
     {\r
-        if (label1_ != nullptr)\r
+        if (stopWatchlabel != nullptr)\r
         {\r
-            delete label1_;\r
-            label1_ = nullptr;\r
+            delete stopWatchlabel;\r
+            stopWatchlabel = nullptr;\r
         }\r
         if (showTimelabel != nullptr)\r
         {\r
@@ -223,10 +263,10 @@ namespace OHOS
             delete ResetOrMarkbuttonClick;\r
             ResetOrMarkbuttonClick = nullptr;\r
         }\r
-        if (scrollView1_ != nullptr)\r
+        if (scrollView[MAIN_STOPWATCH] != nullptr)\r
         {\r
-            delete scrollView1_;\r
-            scrollView1_ = nullptr;\r
+            delete scrollView[MAIN_STOPWATCH];\r
+            scrollView[MAIN_STOPWATCH] = nullptr;\r
         }\r
         if (container_ != nullptr)\r
         {\r
@@ -239,7 +279,7 @@ namespace OHOS
     {\r
         if (!viewInitStatus)\r
         {\r
-            InitView();\r
+            InitMainStopWatchView();\r
             viewInitStatus = true;\r
         }\r
     }\r
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/stopwatch/src/StopWatchRecordCycleToLimitPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/stopwatch/src/StopWatchRecordCycleToLimitPresenter.cpp
deleted file mode 100755 (executable)
index 730c2c9..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-#include "AppViewIDs.h"\r
-#include "NativeAbility.h"\r
-#include "stopwatch/include/StopWatchRecordCycleToLimitPresenter.h"\r
-\r
-/*弹窗视图:到达最高圈数99时弹出*/\r
-namespace OHOS\r
-{\r
-\r
-    // 当前Presenter属性实例化的内存指针\r
-    static StopWatchRecordCycleToLimitPresenter *g_pStopWatchRecordCycleToLimitPresenter = nullptr;\r
-\r
-    StopWatchRecordCycleToLimitPresenter::StopWatchRecordCycleToLimitPresenter()\r
-    {\r
-\r
-        g_pStopWatchRecordCycleToLimitPresenter = this;\r
-    }\r
-\r
-    StopWatchRecordCycleToLimitPresenter::~StopWatchRecordCycleToLimitPresenter()\r
-    {\r
-\r
-        g_pStopWatchRecordCycleToLimitPresenter = nullptr;\r
-    }\r
-\r
-    StopWatchRecordCycleToLimitPresenter *StopWatchRecordCycleToLimitPresenter::GetInstance()\r
-    {\r
-\r
-        return g_pStopWatchRecordCycleToLimitPresenter;\r
-    }\r
-\r
-    void StopWatchRecordCycleToLimitPresenter::OnStart()\r
-    {\r
-\r
-        Presenter<StopWatchRecordCycleToLimitView>::OnStart();\r
-    }\r
-\r
-    void StopWatchRecordCycleToLimitPresenter::OnPause(void)\r
-    {\r
-\r
-        Presenter<StopWatchRecordCycleToLimitView>::OnPause();\r
-    }\r
-\r
-    void StopWatchRecordCycleToLimitPresenter::OnResume(void)\r
-    {\r
-\r
-        Presenter<StopWatchRecordCycleToLimitView>::OnResume();\r
-    }\r
-\r
-    void StopWatchRecordCycleToLimitPresenter::OnStop(void)\r
-    {\r
-\r
-        Presenter<StopWatchRecordCycleToLimitView>::OnStop();\r
-    }\r
-\r
-    bool StopWatchRecordCycleToLimitPresenter::OnDrag(UIView &view, const DragEvent &event)\r
-    {\r
-        UNUSED(view);\r
-        UNUSED(event);\r
-        return true;\r
-    }\r
-\r
-    bool StopWatchRecordCycleToLimitPresenter::OnClick(UIView &view, const ClickEvent &event)\r
-    {\r
-        // 根据控件id查找是哪个控件触发了点击回调\r
-        if (strcmp(view.GetViewId(), "ReturnButton") == 0)\r
-        {\r
-            NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN_STOPWATCH);\r
-        }\r
-        return true;\r
-    }\r
-}
\ No newline at end of file
index 9862deb..51c9cdd 100755 (executable)
@@ -1,6 +1,5 @@
 #include "stopwatch/include/StopWatchRecordCycleToLimitView.h"\r
-#include "stopwatch/include/StopWatchRecordCycleToLimitPresenter.h"\r
-#include "UiConfig.h"\r
+#include "stopwatch/include/MainStopWatchPresenter.h"\r
 /*弹窗视图:到达最高圈数99时弹出*/\r
 namespace OHOS\r
 {\r
@@ -27,27 +26,27 @@ namespace OHOS
 \r
         return g_pStopWatchRecordCycleToLimitView;\r
     }\r
-\r
-    void StopWatchRecordCycleToLimitView::InitView()\r
+    // 初始化秒表到达最高圈数时弹出的视图\r
+    UIScrollView *StopWatchRecordCycleToLimitView::InitStopWatchRecordCycleToLimitView()\r
     {\r
         if (scrollView1_ == nullptr)\r
         {\r
             scrollView1_ = new UIScrollView();\r
         }\r
-        scrollView1_->SetPosition(0, 0);        \r
-        scrollView1_->Resize(466, 466);         \r
-        scrollView1_->SetViewId("scrollView1"); \r
+        scrollView1_->SetPosition(0, 0);\r
+        scrollView1_->Resize(466, 466);\r
+        scrollView1_->SetViewId("scrollView1");\r
         scrollView1_->SetStyle(STYLE_BACKGROUND_OPA, 0xff);\r
-        container_->Add(scrollView1_);\r
+        // container_->Add(scrollView1_);\r
         scrollView1_->SetVisible(true);\r
         /* -------------------------------------------------------------------------- */\r
         if (label1_ == nullptr)\r
         {\r
             label1_ = new UILabel();\r
         }\r
-        label1_->SetPosition(203, 52); \r
-        label1_->Resize(60, 35);       \r
-        label1_->SetViewId("label1");  \r
+        label1_->SetPosition(203, 52);\r
+        label1_->Resize(60, 35);\r
+        label1_->SetViewId("label1");\r
         label1_->SetStyle(STYLE_TEXT_FONT, 30);\r
         label1_->SetStyle(STYLE_LINE_HEIGHT, 35);\r
         label1_->SetText("秒表");\r
@@ -62,9 +61,9 @@ namespace OHOS
         {\r
             image1_ = new UIImageView();\r
         }\r
-        image1_->SetPosition(193, 121); \r
-        image1_->Resize(100, 100);      \r
-        image1_->SetViewId("image1");   \r
+        image1_->SetPosition(193, 121);\r
+        image1_->Resize(100, 100);\r
+        image1_->SetViewId("image1");\r
         image1_->SetStyle(STYLE_BORDER_RADIUS, 100);\r
         char *image1imagesPath = "/user/res/countdown/COUNTDOWN_ATTENTION.bin";\r
         image1_->SetSrc(image1imagesPath);\r
@@ -76,9 +75,9 @@ namespace OHOS
         {\r
             label3_ = new UILabel();\r
         }\r
-        label3_->SetPosition(83, 253); \r
-        label3_->Resize(300, 35);      \r
-        label3_->SetViewId("label3");  \r
+        label3_->SetPosition(83, 253);\r
+        label3_->Resize(300, 35);\r
+        label3_->SetViewId("label3");\r
         label3_->SetStyle(STYLE_TEXT_FONT, 30);\r
         label3_->SetStyle(STYLE_LINE_HEIGHT, 35);\r
         label3_->SetText("当前已达到了最高圈数");\r
@@ -95,9 +94,9 @@ namespace OHOS
         {\r
             button1_ = new UIButton();\r
         }\r
-        button1_->SetPosition(0, 366);  \r
-        button1_->Resize(466, 100);     \r
-        button1_->SetViewId("ReturnButton"); \r
+        button1_->SetPosition(0, 366);\r
+        button1_->Resize(466, 100);\r
+        button1_->SetViewId("CycleToLimitReturnButton");\r
         button1_->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff);\r
         button1_->SetStyle(STYLE_BACKGROUND_OPA, 0x00);\r
         char *button1defaultImgSrc = "/user/res/countdown/COUNTDOWN_BUTTON.bin";\r
@@ -107,11 +106,12 @@ namespace OHOS
         button1_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);\r
 \r
         // Add the CallBack about events\r
-        UIView::OnClickListener *button1Click = static_cast<UIView::OnClickListener *>(StopWatchRecordCycleToLimitPresenter::GetInstance());\r
+        UIView::OnClickListener *button1Click = static_cast<UIView::OnClickListener *>(MainStopWatchPresenter::GetInstance());\r
         button1_->SetOnClickListener(button1Click);\r
         // Add to scrollView1\r
         scrollView1_->Add(button1_);\r
         button1_->SetVisible(true);\r
+        return scrollView1_;\r
     }\r
 \r
     void StopWatchRecordCycleToLimitView::DeInitView()\r
@@ -148,48 +148,4 @@ namespace OHOS
             button1_ = nullptr;\r
         }\r
     }\r
-    void StopWatchRecordCycleToLimitView::PreLoad(void)\r
-    {\r
-        if (!viewInitStatus)\r
-        {\r
-            InitView();\r
-            viewInitStatus = true;\r
-        }\r
-    }\r
-    void StopWatchRecordCycleToLimitView::OnStart()\r
-    {\r
-        // container_容器属性 new\r
-        container_ = new UIViewGroup();\r
-        if (container_ == nullptr)\r
-        {\r
-            return;\r
-        }\r
-        // container_容器属性 扩展\r
-        container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());\r
-        container_->SetTouchable(true);\r
-        PreLoad();\r
-        RootView::GetInstance()->Add(container_);\r
-    }\r
-\r
-    void StopWatchRecordCycleToLimitView::OnSetUpView()\r
-    {\r
-\r
-        View<StopWatchRecordCycleToLimitPresenter>::OnSetUpView();\r
-        Draw();\r
-    }\r
-\r
-    void StopWatchRecordCycleToLimitView::OnTearDownView()\r
-    {\r
-\r
-        View<StopWatchRecordCycleToLimitPresenter>::OnTearDownView();\r
-        return;\r
-    }\r
-\r
-    void StopWatchRecordCycleToLimitView::OnStop()\r
-    {\r
-\r
-        View<StopWatchRecordCycleToLimitPresenter>::OnStop();\r
-        RootView::GetInstance()->RemoveAll();\r
-        return;\r
-    }\r
 }
\ No newline at end of file
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/stopwatch/src/StopWatchRecordTimeToLimitPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/stopwatch/src/StopWatchRecordTimeToLimitPresenter.cpp
deleted file mode 100755 (executable)
index d58558f..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-#include "AppViewIDs.h"\r
-#include "NativeAbility.h"\r
-#include "stopwatch/include/StopWatchRecordTimeToLimitPresenter.h"\r
-\r
-/*弹窗视图:到达最高时间99:59.99时弹出*/\r
-namespace OHOS\r
-{\r
-\r
-    // 当前Presenter属性实例化的内存指针\r
-    static StopWatchRecordTimeToLimitPresenter *g_pStopWatchRecordTimeToLimitPresenter = nullptr;\r
-\r
-    StopWatchRecordTimeToLimitPresenter::StopWatchRecordTimeToLimitPresenter()\r
-    {\r
-\r
-        g_pStopWatchRecordTimeToLimitPresenter = this;\r
-    }\r
-\r
-    StopWatchRecordTimeToLimitPresenter::~StopWatchRecordTimeToLimitPresenter()\r
-    {\r
-\r
-        g_pStopWatchRecordTimeToLimitPresenter = nullptr;\r
-    }\r
-\r
-    StopWatchRecordTimeToLimitPresenter *StopWatchRecordTimeToLimitPresenter::GetInstance()\r
-    {\r
-\r
-        return g_pStopWatchRecordTimeToLimitPresenter;\r
-    }\r
-\r
-    void StopWatchRecordTimeToLimitPresenter::OnStart()\r
-    {\r
-\r
-        Presenter<StopWatchRecordTimeToLimitView>::OnStart();\r
-    }\r
-\r
-    void StopWatchRecordTimeToLimitPresenter::OnPause(void)\r
-    {\r
-\r
-        Presenter<StopWatchRecordTimeToLimitView>::OnPause();\r
-    }\r
-\r
-    void StopWatchRecordTimeToLimitPresenter::OnResume(void)\r
-    {\r
-\r
-        Presenter<StopWatchRecordTimeToLimitView>::OnResume();\r
-    }\r
-\r
-    void StopWatchRecordTimeToLimitPresenter::OnStop(void)\r
-    {\r
-\r
-        Presenter<StopWatchRecordTimeToLimitView>::OnStop();\r
-    }\r
-\r
-    bool StopWatchRecordTimeToLimitPresenter::OnDrag(UIView &view, const DragEvent &event)\r
-    {\r
-        UNUSED(view);\r
-        UNUSED(event);\r
-        return true;\r
-    }\r
-\r
-    bool StopWatchRecordTimeToLimitPresenter::OnClick(UIView &view, const ClickEvent &event)\r
-    {\r
-        // 根据控件id查找是哪个控件触发了点击回调\r
-        if (strcmp(view.GetViewId(), "ReturnButton") == 0)\r
-        {\r
-            NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN_STOPWATCH);\r
-        }\r
-        return true;\r
-    }\r
-}
\ No newline at end of file
index 2fb5b96..a9ce7de 100755 (executable)
@@ -1,6 +1,5 @@
 #include "stopwatch/include/StopWatchRecordTimeToLimitView.h"\r
-#include "stopwatch/include/StopWatchRecordTimeToLimitPresenter.h"\r
-\r
+#include "stopwatch/include/MainStopWatchPresenter.h"\r
 #include "UiConfig.h"\r
 \r
 /*弹窗视图:到达最高时间99:59.99时弹出*/\r
@@ -30,7 +29,7 @@ namespace OHOS
         return g_pStopWatchRecordTimeToLimitView;\r
     }\r
 \r
-    void StopWatchRecordTimeToLimitView::InitView()\r
+    UIScrollView *StopWatchRecordTimeToLimitView::InitStopWatchRecordTimeToLimitView()\r
     {\r
         if (scrollView1_ == nullptr)\r
         {\r
@@ -40,7 +39,6 @@ namespace OHOS
         scrollView1_->Resize(466, 466);\r
         scrollView1_->SetViewId("scrollView1");\r
         scrollView1_->SetStyle(STYLE_BACKGROUND_OPA, 0xff);\r
-        container_->Add(scrollView1_);\r
         scrollView1_->SetVisible(true);\r
         /* -------------------------------------------------------------------------- */\r
         if (label1_ == nullptr)\r
@@ -99,7 +97,7 @@ namespace OHOS
         }\r
         button1_->SetPosition(0, 366);\r
         button1_->Resize(466, 100);\r
-        button1_->SetViewId("ReturnButton");\r
+        button1_->SetViewId("TimeToLimitReturnButton");\r
         button1_->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff);\r
         button1_->SetStyle(STYLE_BACKGROUND_OPA, 0x00);\r
         char *button1defaultImgSrc = "/user/res/countdown/COUNTDOWN_BUTTON.bin";\r
@@ -108,58 +106,16 @@ namespace OHOS
         button1_->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED);\r
         button1_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);\r
         // Add the CallBack about events\r
-        UIView::OnClickListener *button1Click = static_cast<UIView::OnClickListener *>(StopWatchRecordTimeToLimitPresenter::GetInstance());\r
+        UIView::OnClickListener *button1Click = static_cast<UIView::OnClickListener *>(MainStopWatchPresenter::GetInstance());\r
         button1_->SetOnClickListener(button1Click);\r
         // Add to scrollView1\r
         scrollView1_->Add(button1_);\r
         button1_->SetVisible(true);\r
+        viewInitStatus = true;\r
+        return scrollView1_;\r
     }\r
 \r
     void StopWatchRecordTimeToLimitView::DeInitView()\r
     {\r
     }\r
-    void StopWatchRecordTimeToLimitView::PreLoad(void)\r
-    {\r
-        if (!viewInitStatus)\r
-        {\r
-            InitView();\r
-            viewInitStatus = true;\r
-        }\r
-    }\r
-    void StopWatchRecordTimeToLimitView::OnStart()\r
-    {\r
-        // container_容器属性 new\r
-        container_ = new UIViewGroup();\r
-        if (container_ == nullptr)\r
-        {\r
-            return;\r
-        }\r
-        // container_容器属性 扩展\r
-        container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());\r
-        container_->SetTouchable(true);\r
-        PreLoad();\r
-        RootView::GetInstance()->Add(container_);\r
-    }\r
-\r
-    void StopWatchRecordTimeToLimitView::OnSetUpView()\r
-    {\r
-\r
-        View<StopWatchRecordTimeToLimitPresenter>::OnSetUpView();\r
-        Draw();\r
-    }\r
-\r
-    void StopWatchRecordTimeToLimitView::OnTearDownView()\r
-    {\r
-\r
-        View<StopWatchRecordTimeToLimitPresenter>::OnTearDownView();\r
-        return;\r
-    }\r
-\r
-    void StopWatchRecordTimeToLimitView::OnStop()\r
-    {\r
-\r
-        View<StopWatchRecordTimeToLimitPresenter>::OnStop();\r
-        RootView::GetInstance()->RemoveAll();\r
-        return;\r
-    }\r
 }
\ No newline at end of file
index b6f4090..e308f60 100755 (executable)
@@ -221,7 +221,7 @@ static uart_config_t g_uart_config[UART_BUS_MAX_NUMBER] = {
         log_factory_at_callback,
 #endif
         {
-            .baud_rate = 500000,
+            .baud_rate = 2000000,
             .data_bits = UART_DATA_BIT_8,
             .parity = UART_PARITY_NONE,
             .stop_bits = UART_STOP_BIT_1,