修改训练进入界面
authorCaisking <3449750381@qq.com>
Thu, 21 Mar 2024 09:44:48 +0000 (17:44 +0800)
committerCaisking <3449750381@qq.com>
Thu, 21 Mar 2024 09:44:48 +0000 (17:44 +0800)
code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp
code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartModel.cpp
code/sdk/application/wearable/fd230app/nativeui/traing/Training_UiConfig.h
code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingModel.h
code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingView.h
code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingModel.cpp
code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingPresenter.cpp
code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingView.cpp
code/sdk/drivers/peripheral/cywee/service/cywee_at_cmd.c

index e64e691..a210309 100644 (file)
@@ -330,11 +330,6 @@ namespace OHOS
 #endif
         /* ------------------------------- ConfigModel ------------------------------ */
         ConfigModel::GetInstance()->Init();
-        // 开机检测充电状态
-        if (get_charge_stat() == 1)
-        {
-            DialModelCharge::GetInstance()->UpdateChargeStuaut(1);
-        }
         /* -------------------------------------------------------------------------- */
 
         // 初始化所有预加载slice
@@ -353,6 +348,14 @@ namespace OHOS
         NativeAbility::GetInstance().SetDefaultSliceId(VIEW_MAIN);
         // 注册长按重启或关机事件
         RebootModel::GetInstance()->RegisterLongPressEvents();
+
+        // 开机检测充电状态
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Power is %d",get_charge_stat());
+        if (get_charge_stat())
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Power is Charging!");
+            DialModelCharge::GetInstance()->UpdateChargeStuaut(1);
+        }
     }
 
     void NativeLauncher::InitAllNativeSlices(void)
index c0ebb22..167ef38 100644 (file)
@@ -136,7 +136,8 @@ extern "C"
             OHOS::HeartModel::GetInstance()->ClearHeartData();\r
         }\r
         if (request->msgId == TOPIC_EVENT_WEARSTATE_UPDATE)\r
-        {}\r
+        {\r
+        }\r
     }\r
 \r
 #ifdef __cplusplus\r
index 6883e6c..0016809 100644 (file)
@@ -4,10 +4,10 @@
 #include <cstdint>
 #include "ohos_types.h"
 #include "graphic_config.h"
+#include "traing/Training_UiConfig.h"
 
 namespace OHOS
 {
-
 // 定义按键颜色宏
 #define DEFAULT_BACKGROUND_COLOR 0xff191919
 #define PRESSED_BACKGROUND_COLOR 0xff249115
@@ -39,7 +39,7 @@ namespace OHOS
     // Icons in the icon_60x60 folder
     static constexpr const char *RIDING_60_IMAGE = ICON60 "/Riding_60.bin";
     static constexpr const char *RUNNING_60_IMAGE = ICON60 "/Running_60.bin";
-    static constexpr const char *WALKING_60_IMAGE = ICON60 "/Walking_60.bin";
+    static constexpr const char *WALKING_60_IMAGE = ICON60 "/walking_60.bin";
 
     // Icons in the icon_80x80 folder
     static constexpr const char *JUMPROPE_80_IMAGE = ICON80 "/Jumprope_80.bin";
index df259f2..379695c 100644 (file)
@@ -1,3 +1,4 @@
+
 #ifndef Traing_MODEL_H
 #define Traing_MODEL_H
 
 #include "traing/include/TraingModel.h"
 #include "traing/Training_UiConfig.h"
 
+#include <string>
+
 struct QuickTraining
 {
-    char *training1_Text;
-    char *training1_Image;
-    char *training2_Text;
-    char *training2_Image;
-    char *training3_Text;
-    char *training3_Image;
-
-    //QuickTraining() : training1_Text("健走"), training2_Text("骑行"), training3_Text("跑步"), training1_Image(WALKING_60_IMAGE), training2_Image(RUNNING_60_IMAGE), training3_Image(RIDING_60_IMAGE) {} // 初始化默认值
+    std::string training1_Text;
+    std::string training1_Image;
+    std::string training2_Text;
+    std::string training2_Image;
+    std::string training3_Text;
+    std::string training3_Image;
+
+    QuickTraining()
+        : training1_Text("健走"),
+          training2_Text("骑行"),
+          training3_Text("跑步"),
+          training1_Image(OHOS::WALKING_60_IMAGE),
+          training2_Image(OHOS::RIDING_60_IMAGE),
+          training3_Image(OHOS::RUNNING_60_IMAGE) {}
 };
 
 namespace OHOS
@@ -52,7 +61,6 @@ namespace OHOS
     private:
         TraingModel(const TraingModel &) = delete;
         TraingModel &operator=(const TraingModel &) = delete;
-
         QuickTraining *quickTraining_;
     };
 }
index a751d0c..1fcea81 100644 (file)
@@ -1,3 +1,11 @@
+/*** 
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-03-19 17:37:18
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-03-21 15:03:14
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingView.h
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
 #ifndef _Traing_VIEW_H
 #define _Traing_VIEW_H
 
index 633fbc2..72d54ae 100644 (file)
@@ -1,16 +1,27 @@
 #include "traing/include/TraingModel.h"
 #include "wearable_log.h"
+#include <iostream>
+#include <string>
 
 namespace OHOS
 {
     TraingModel ::TraingModel()
     {
-        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TraingModel::TraingModel()");
-        //quickTraining_ = &QuickTraining(); // 为quickTraining_赋初值
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TraingModel::TraingModel()");
+        quickTraining_ = new QuickTraining(); // 为quickTraining_赋初值
+#if 1
+        printf(" quickTraining_--training1_Text: %s\n", quickTraining_->training1_Text.c_str());
+        printf(" quickTraining_--training1_Image: %s\n", quickTraining_->training1_Image.c_str());
+        printf(" quickTraining_--training2_Text: %s\n", quickTraining_->training2_Text.c_str());
+        printf(" quickTraining_--training2_Image: %s\n", quickTraining_->training2_Image.c_str());
+        printf(" quickTraining_--training3_Text: %s\n", quickTraining_->training3_Text.c_str());
+        printf(" quickTraining_--training3_Image: %s\n", quickTraining_->training3_Image.c_str());
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TraingModel::TraingModel()");
+#endif
     }
     TraingModel ::~TraingModel()
     {
-        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TraingModel::~TraingModel()");
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TraingModel::~TraingModel()");
     }
     TraingModel *TraingModel::GetInstance(void)
     {
@@ -22,7 +33,7 @@ namespace OHOS
      * @param {QuickTraining} *quickTraining
      * @brief 设置快捷训练
      */
-    void TraingModel::SetQuickTraining( QuickTraining *quickTraining)
+    void TraingModel::SetQuickTraining(QuickTraining *quickTraining)
     {
         quickTraining_ = quickTraining;
     }
@@ -75,7 +86,7 @@ namespace OHOS
         label->SetRollSpeed(0);
         // 设置标签可见
         label->SetVisible(true);
-
+        // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TraingModel::InitLabel is succeed");
         return true;
     }
 
@@ -108,6 +119,7 @@ namespace OHOS
         button->SetStyleForState(STYLE_BACKGROUND_COLOR, DEFAULT_BACKGROUND_COLOR, UIButton::PRESSED);
         button->SetStyleForState(STYLE_BORDER_COLOR, PRESSED_BORDER_COLOR, UIButton::PRESSED);
         button->SetVisible(true);
+        // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TraingModel::InitButton is succeed");
         return true;
     }
 
@@ -138,6 +150,7 @@ namespace OHOS
         imageView->SetViewId(viewId);
         imageView->SetSrc(imagePath);
         imageView->SetVisible(true);
+        // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TraingModel::InitImageView is succeed");
         return true;
     }
 
index 8cdefa2..017fbbf 100644 (file)
@@ -1,3 +1,4 @@
+
 #include "AppViewIDs.h"
 #include "NativeAbility.h"
 
@@ -15,54 +16,46 @@ namespace OHOS
 
     TraingPresenter::TraingPresenter()
     {
-
         g_pTraingPresenter = this;
     }
 
     TraingPresenter::~TraingPresenter()
     {
-
         g_pTraingPresenter = nullptr;
     }
 
     TraingPresenter *TraingPresenter::GetInstance()
     {
-
         return g_pTraingPresenter;
     }
 
     void TraingPresenter::OnStart()
     {
-
         Presenter<TraingView>::OnStart();
     }
 
     void TraingPresenter::OnPause(void)
     {
-
         Presenter<TraingView>::OnPause();
     }
 
     void TraingPresenter::OnResume(void)
     {
-
         Presenter<TraingView>::OnResume();
     }
 
     void TraingPresenter::OnStop(void)
     {
-
         Presenter<TraingView>::OnStop();
     }
 
     bool TraingPresenter::OnDrag(UIView &view, const DragEvent &event)
     {
-
-        if (event.GetDragDirection() == DragEvent::DIRECTION_RIGHT_TO_LEFT)
+        UNUSED(view);
+        if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT)
         {
             NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST);
         }
-        UNUSED(view);
         return true;
     }
 
index b8c360d..875792e 100644 (file)
@@ -1,26 +1,27 @@
 \r
 #include "traing/include/TraingView.h"\r
-\r
+#include <iostream>\r
+#include <string>\r
 namespace OHOS\r
 {\r
     // 按钮设置\r
-    static constexpr uint16_t BUTTON_WIDHT = 230;\r
-    static constexpr uint16_t BUTTON_HEIGHT = 80;\r
-    static constexpr uint16_t BUTTON1_X = 118;\r
-    static constexpr uint16_t BUTTON1_Y = 336;\r
-    static constexpr uint16_t BUTTON2_X = 118;\r
-    static constexpr uint16_t BUTTON2_Y = 336;\r
-    static constexpr uint16_t BUTTON3_X = 118;\r
-    static constexpr uint16_t BUTTON3_Y = 336;\r
-    static constexpr uint16_t BUTTONMORE_X = 118;\r
-    static constexpr uint16_t BUTTONMORE_Y = 336;\r
+    static constexpr uint16_t BUTTON_WIDHT = 140;\r
+    static constexpr uint16_t BUTTON_HEIGHT = 140;\r
+    static constexpr uint16_t BUTTON1_X = 86;\r
+    static constexpr uint16_t BUTTON1_Y = 118;\r
+    static constexpr uint16_t BUTTON2_X = 236;\r
+    static constexpr uint16_t BUTTON2_Y = 118;\r
+    static constexpr uint16_t BUTTON3_X = 86;\r
+    static constexpr uint16_t BUTTON3_Y = 268;\r
+    static constexpr uint16_t BUTTONMORE_X = 236;\r
+    static constexpr uint16_t BUTTONMORE_Y = 268;\r
 \r
     // 标签设置\r
     static constexpr uint16_t LABEL_FONT_SIZE = 30;\r
     static constexpr uint16_t LABEL_X_SIZE = 200;\r
     static constexpr uint16_t LABEL_Y_SIZE = 60;\r
-    static constexpr uint16_t TITLE_LABEL_X = 83;\r
-    static constexpr uint16_t TITLE_LABEL_Y = 103;\r
+    static constexpr uint16_t TITLE_LABEL_X = 181;\r
+    static constexpr uint16_t TITLE_LABEL_Y = 52;\r
 \r
     static constexpr uint16_t BTN1_LABEL_X = 135;\r
     static constexpr uint16_t BTN1_LABEL_Y = 210;\r
@@ -31,15 +32,18 @@ namespace OHOS
 \r
     // 图片设置\r
     static constexpr uint16_t BTN_IMAGE_SIZE = 100;\r
+\r
     static constexpr uint16_t BTN1_IMAGE_X = 126;\r
     static constexpr uint16_t BTN1_IMAGE_Y = 148;\r
+\r
     static constexpr uint16_t BTN2_IMAGE_X = 276;\r
     static constexpr uint16_t BTN2_IMAGE_Y = 148;\r
-    static constexpr uint16_t BTNMORE_IMAGE_X = 129;\r
-    static constexpr uint16_t BTNMORE_IMAGE_Y = 298;\r
+\r
+    static constexpr uint16_t BTN3_IMAGE_X = 129;\r
+    static constexpr uint16_t BTN3_IMAGE_Y = 298;\r
 \r
     static TraingView *g_pTraingView{nullptr};\r
-    QuickTraining *data = new QuickTraining;\r
+    static QuickTraining *data = new QuickTraining;\r
 \r
     TraingView::TraingView()\r
     {\r
@@ -65,11 +69,12 @@ namespace OHOS
      */\r
     bool TraingView::AddLabel()\r
     {\r
-        // 初始化标签\r
+        // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TraingModel::AddLabel");\r
+        //  初始化标签\r
         TraingModel::GetInstance()->InitLabel(title_label, TITLE_LABEL_X, TITLE_LABEL_Y, LABEL_X_SIZE, LABEL_Y_SIZE, "title_label", "快速训练", DEFAULT_VECTOR_FONT_FILENAME, LABEL_FONT_SIZE);\r
-        const char *dataStr1 = data->training1_Text;\r
-        const char *dataStr2 = data->training2_Text;\r
-        const char *dataStr3 = data->training3_Text;\r
+        const char *dataStr1 = (data->training1_Text).c_str();\r
+        const char *dataStr2 = (data->training2_Text).c_str();\r
+        const char *dataStr3 = (data->training3_Text).c_str();\r
         TraingModel::GetInstance()->InitLabel(btn1_label, BTN1_LABEL_X, BTN1_LABEL_Y, LABEL_X_SIZE, LABEL_Y_SIZE, "btu1_label", dataStr1, DEFAULT_VECTOR_FONT_FILENAME, LABEL_FONT_SIZE);\r
         TraingModel::GetInstance()->InitLabel(btn2_label, BTN2_LABEL_X, BTN2_LABEL_Y, LABEL_X_SIZE, LABEL_Y_SIZE, "btu2_label", dataStr2, DEFAULT_VECTOR_FONT_FILENAME, LABEL_FONT_SIZE);\r
         TraingModel::GetInstance()->InitLabel(btn3_label, BTN3_LABEL_X, BTN3_LABEL_Y, LABEL_X_SIZE, LABEL_Y_SIZE, "btu3_label", dataStr3, DEFAULT_VECTOR_FONT_FILENAME, LABEL_FONT_SIZE);\r
@@ -78,6 +83,27 @@ namespace OHOS
 \r
     bool TraingView::AddButton()\r
     {\r
+        TraingModel::GetInstance()->InitButton(button1_, BUTTON1_X, BUTTON1_Y, BUTTON_WIDHT, BUTTON_HEIGHT, BUTTON1);\r
+        button1_->SetImageSrc(BUTTONGROUND2_IMAGE, nullptr);\r
+        UIView::OnClickListener *button1Click = static_cast<UIView::OnClickListener *>(TraingPresenter::GetInstance());\r
+        button1_->SetOnClickListener(button1Click);\r
+\r
+        TraingModel::GetInstance()->InitButton(button2_, BUTTON2_X, BUTTON2_Y, BUTTON_WIDHT, BUTTON_HEIGHT, BUTTON2);\r
+        button2_->SetImageSrc(BOUTTONGROUND_IMAGE, nullptr);\r
+        UIView::OnClickListener *button2Click = static_cast<UIView::OnClickListener *>(TraingPresenter::GetInstance());\r
+        button2_->SetOnClickListener(button2Click);\r
+\r
+        TraingModel::GetInstance()->InitButton(button3_, BUTTON3_X, BUTTON3_Y, BUTTON_WIDHT, BUTTON_HEIGHT, BUTTON3);\r
+        button3_->SetImageSrc(BUTTONGROUND2_IMAGE, nullptr);\r
+        UIView::OnClickListener *button3Click = static_cast<UIView::OnClickListener *>(TraingPresenter::GetInstance());\r
+        button3_->SetOnClickListener(button3Click);\r
+\r
+        TraingModel::GetInstance()->InitButton(buttonmore_, BUTTONMORE_X, BUTTONMORE_Y, BUTTON_WIDHT, BUTTON_HEIGHT, BUTTONMORE);\r
+        buttonmore_->SetImageSrc(MORE_IMAGE, nullptr);\r
+        UIView::OnClickListener *button4Click = static_cast<UIView::OnClickListener *>(TraingPresenter::GetInstance());\r
+        buttonmore_->SetOnClickListener(button4Click);\r
+\r
+        return true;\r
     }\r
     /***\r
      * @description:\r
@@ -86,12 +112,15 @@ namespace OHOS
      */\r
     bool TraingView::AddImageView()\r
     {\r
-        const char *dataStr1 = data->training1_Image;\r
-        const char *dataStr2 = data->training2_Image;\r
-        const char *dataStr3 = data->training3_Image;\r
+        const char *dataStr1 = (data->training1_Image).c_str();\r
+        const char *dataStr2 = (data->training2_Image).c_str();\r
+        const char *dataStr3 = (data->training3_Image).c_str();\r
+        // const char *dataStr1 = WALKING_60_IMAGE;\r
+        // const char *dataStr2 = RUNNING_60_IMAGE;\r
+        // const char *dataStr3 = RIDING_60_IMAGE;\r
         TraingModel::GetInstance()->InitImageView(btn1_image, BTN1_IMAGE_X, BTN1_IMAGE_Y, BTN_IMAGE_SIZE, BTN_IMAGE_SIZE, "btn1_image", dataStr1);\r
         TraingModel::GetInstance()->InitImageView(btn2_image, BTN2_IMAGE_X, BTN2_IMAGE_Y, BTN_IMAGE_SIZE, BTN_IMAGE_SIZE, "btn2_image", dataStr2);\r
-        TraingModel::GetInstance()->InitImageView(btn3_image, BTN3_LABEL_X, BTN3_LABEL_Y, BTN_IMAGE_SIZE, BTN_IMAGE_SIZE, "btn3_image", dataStr3);\r
+        TraingModel::GetInstance()->InitImageView(btn3_image, BTN3_IMAGE_X, BTN3_IMAGE_Y, BTN_IMAGE_SIZE, BTN_IMAGE_SIZE, "btn3_image", dataStr3);\r
         return true;\r
     }\r
     void TraingView::InitView()\r
@@ -104,112 +133,89 @@ namespace OHOS
         }\r
 \r
         // 初始化按键\r
-\r
+        AddButton();\r
         // 初始化标签\r
+        AddLabel();\r
+        // 初始化图片\r
+        AddImageView();\r
+\r
+        container_->Add(button1_);\r
+        container_->Add(button2_);\r
+        container_->Add(button3_);\r
+        container_->Add(buttonmore_);\r
+        container_->Add(title_label);\r
+        container_->Add(btn1_label);\r
+        container_->Add(btn2_label);\r
+        container_->Add(btn3_label);\r
+        container_->Add(btn1_image);\r
+        container_->Add(btn2_image);\r
+        container_->Add(btn3_image);\r
+\r
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TraingModel::InitView");\r
+    }\r
 \r
-#if 0\r
-        // Add Button to App\r
-        if (button3_ == nullptr)\r
+    void TraingView::DeInitView()\r
+    {\r
+        container_->RemoveAll();\r
+        if (buttonmore_ != nullptr)\r
         {\r
-            button3_ = new UIButton();\r
+            delete buttonmore_;\r
+            buttonmore_ = nullptr;\r
         }\r
-        button3_->SetPosition(236, 268); // widget's left position and top position\r
-        button3_->Resize(140, 140);      // widget's width and height\r
-        button3_->SetViewId(BUTTONMORE); // Set style\r
-        button3_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000);\r
-        button3_->SetStyle(STYLE_BACKGROUND_OPA, 0x00);\r
-        const char *button3defaultImgSrc = PNG_TRAING_BOUTTONMORE_IMAGE;\r
-        char *button3triggeredImgSrc = nullptr;\r
-        button3_->SetImageSrc(button3defaultImgSrc, button3triggeredImgSrc);\r
-        button3_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff33df1c, UIButton::PRESSED);\r
-        button3_->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED);\r
-        button3_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);\r
-        // Add the CallBack about events\r
-        UIView::OnClickListener *button3Click = static_cast<UIView::OnClickListener *>(TraingPresenter::GetInstance());\r
-        button3_->SetOnClickListener(button3Click);\r
-        // Add to rootView\r
-        container_->Add(button3_);\r
-        button3_->SetVisible(true);\r
-        // Add Button to App\r
-        if (button4_ == nullptr)\r
+        if (button1_ != nullptr)\r
         {\r
-            button4_ = new UIButton();\r
+            delete button1_;\r
+            button1_ = nullptr;\r
         }\r
-        button4_->SetPosition(86, 118); // widget's left position and top position\r
-        button4_->Resize(140, 140);     // widget's width and height\r
-        button4_->SetViewId(BUTTON2);   // Set style\r
-        button4_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000);\r
-        button4_->SetStyle(STYLE_BACKGROUND_OPA, 0x00);\r
-        const char *button4defaultImgSrc = PNG_TRAING_BUTTONGRONG2_IMAGE;\r
-        char *button4triggeredImgSrc = nullptr;\r
-        button4_->SetImageSrc(button4defaultImgSrc, button4triggeredImgSrc);\r
-        button4_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff33df1c, UIButton::PRESSED);\r
-        button4_->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED);\r
-        button4_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);\r
-\r
-        UIView::OnClickListener *button4Click = static_cast<UIView::OnClickListener *>(TraingPresenter::GetInstance());\r
-        button4_->SetOnClickListener(button4Click);\r
-        // Add to rootView\r
-        container_->Add(button4_);\r
-        button4_->SetVisible(true);\r
-\r
-        // Add Button to App\r
-        if (button1_ == nullptr)\r
+        if (button2_ != nullptr)\r
         {\r
-            button1_ = new UIButton();\r
+            delete button2_;\r
+            button2_ = nullptr;\r
         }\r
-        button1_->SetPosition(86, 268); // widget's left position and top position\r
-        button1_->Resize(140, 140);     // widget's width and height\r
-        button1_->SetViewId(BUTTON3);   // Set style\r
-        button1_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000);\r
-        button1_->SetStyle(STYLE_BACKGROUND_OPA, 0x00);\r
-\r
-        const char *button1defaultImgSrc = PNG_TRAING_BUTTONGRONG_IMAGE;\r
-        char *button1triggeredImgSrc = nullptr;\r
-        button1_->SetImageSrc(button1defaultImgSrc, button1triggeredImgSrc);\r
-        button1_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff33df1c, UIButton::PRESSED);\r
-        button1_->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED);\r
-        button1_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);\r
-\r
-        // Add the CallBack about events\r
-        UIView::OnClickListener *button1Click = static_cast<UIView::OnClickListener *>(TraingPresenter::GetInstance());\r
-        button1_->SetOnClickListener(button1Click);\r
-        // Add to rootView\r
-        container_->Add(button1_);\r
-        button1_->SetVisible(true);\r
-\r
-        // Add Button to App\r
-        if (button2_ == nullptr)\r
+        if (button3_ != nullptr)\r
         {\r
-            button2_ = new UIButton();\r
+            delete button3_;\r
+            button3_ = nullptr;\r
         }\r
-        button2_->SetPosition(236, 118); // widget's left position and top position\r
-        button2_->Resize(140, 140);      // widget's width and height\r
-        button2_->SetViewId(BUTTON1);    // Set style\r
-        button2_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000);\r
-        button2_->SetStyle(STYLE_BACKGROUND_OPA, 0x00);\r
-\r
-        const char *button2defaultImgSrc = PNG_TRAING_BUTTONGRONG_IMAGE;\r
-        char *button2triggeredImgSrc = nullptr;\r
-        button2_->SetImageSrc(button2defaultImgSrc, button2triggeredImgSrc);\r
-        button2_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff33df1c, UIButton::PRESSED);\r
-        button2_->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED);\r
-        button2_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);\r
-\r
-        // Add the CallBack about events\r
-        UIView::OnClickListener *button2Click = static_cast<UIView::OnClickListener *>(TraingPresenter::GetInstance());\r
-        button2_->SetOnClickListener(button2Click);\r
-        // Add to rootView\r
-        container_->Add(button2_);\r
-        button2_->SetVisible(true);\r
-#endif\r
-    }\r
-\r
-    void TraingView::DeInitView()\r
-    {\r
+        if (title_label != nullptr)\r
+        {\r
+            delete title_label;\r
+            title_label = nullptr;\r
+        }\r
+        if (btn1_label != nullptr)\r
+        {\r
+            delete btn1_label;\r
+            btn1_label = nullptr;\r
+        }\r
+        if (btn2_label != nullptr)\r
+        {\r
+            delete btn2_label;\r
+            btn2_label = nullptr;\r
+        }\r
+        if (btn3_label != nullptr)\r
+        {\r
+            delete btn3_label;\r
+            btn3_label = nullptr;\r
+        }\r
+        if (btn1_image != nullptr)\r
+        {\r
+            delete btn1_image;\r
+            btn1_image = nullptr;\r
+        }\r
+        if (btn2_image != nullptr)\r
+        {\r
+            delete btn2_image;\r
+            btn2_image = nullptr;\r
+        }\r
+        if (btn3_image != nullptr)\r
+        {\r
+            delete btn3_image;\r
+            btn3_image = nullptr;\r
+        }\r
+        // 删除容器\r
         if (container_ != nullptr)\r
         {\r
-            container_->RemoveAll();\r
+            container_->RemoveAll(); // 移除容器中的所有组件\r
             delete container_;\r
             container_ = nullptr;\r
         }\r
@@ -223,6 +229,12 @@ namespace OHOS
 \r
     void TraingView::OnStart()\r
     {\r
+        printf(" data--training1_Text: %s\n", data->training1_Text.c_str());\r
+        printf(" data--training1_Image: %s\n", data->training1_Image.c_str());\r
+        printf(" data--training2_Text: %s\n", data->training2_Text.c_str());\r
+        printf(" data--training2_Image: %s\n", data->training2_Image.c_str());\r
+        printf(" data--training3_Text: %s\n", data->training3_Text.c_str());\r
+        printf(" data--training3_Image: %s\n", data->training3_Image.c_str());\r
         container_ = new UIViewGroup();\r
         if (container_ == nullptr)\r
         {\r
@@ -244,19 +256,18 @@ namespace OHOS
         container_->SetDraggable(true);\r
 \r
         GetView();\r
+\r
         RootView::GetInstance()->Add(container_);\r
     }\r
 \r
     void TraingView::OnSetUpView()\r
     {\r
-\r
         View<TraingPresenter>::OnSetUpView();\r
         Draw();\r
     }\r
 \r
     void TraingView::OnTearDownView()\r
     {\r
-\r
         View<TraingPresenter>::OnTearDownView();\r
         return;\r
     }\r
index 89489f8..b53a177 100644 (file)
@@ -48,22 +48,22 @@ static uint32_t cywee_do_test(uint8_t *para, uint32_t paraLen, char *strCommonCm
 
     int ret = ConvertCmdToParam(para, paraLen, argv, &argc);
     if (ret != ERRCODE_SUCC) {
-        //PRINT("CYWEETEST ATCMD Convert Command Failed\n");
+        PRINT("CYWEETEST ATCMD Convert Command Failed\n");
         return ERRCODE_FAIL;
     }
     if (argc < 1) {
-        //PRINT("CYWEETEST ATCMD Set Parameter Failed\n");
+        PRINT("CYWEETEST ATCMD Set Parameter Failed\n");
         return ERRCODE_FAIL;
     }
     char *mode = (char*)argv[0];
     if (strcmp(mode, "start") == 0) {
-        //PRINT("cywee start\n");
+        PRINT("cywee start\n");
         do_cywee_service_check_msg(CYWEE_SERVICE_CMD_START_CHECK);
     } else if (strcmp(mode, "stop") == 0) {
-        //PRINT("cywee stop\n");
+        PRINT("cywee stop\n");
         do_cywee_service_check_msg(CYWEE_SERVICE_CMD_STOP_CHECK);
     } else if (strcmp(mode, "test") == 0) {
-        //PRINT("cywee test\n");
+        PRINT("cywee test\n");
         do_cywee_service_check_msg(CYWEE_SERVICE_CMD_TEST);
     } 
     return ERRCODE_SUCC;