From: Caisking <3449750381@qq.com> Date: Thu, 21 Mar 2024 09:44:48 +0000 (+0800) Subject: 修改训练进入界面 X-Git-Tag: release_V1.2.70_20241020_135402~1280 X-Git-Url: http://git.snicker.com.cn/Users/apple/Desktop/static/gitweb.css?a=commitdiff_plain;h=f427d879d81ce68d0485fd4b80e5495af246aa25;p=mirrors%2FFD230.git 修改训练进入界面 --- diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp b/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp index e64e691a0..a21030900 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp +++ b/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp @@ -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) diff --git a/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartModel.cpp index c0ebb22cd..167ef3878 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartModel.cpp @@ -136,7 +136,8 @@ extern "C" OHOS::HeartModel::GetInstance()->ClearHeartData(); } if (request->msgId == TOPIC_EVENT_WEARSTATE_UPDATE) - {} + { + } } #ifdef __cplusplus diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/Training_UiConfig.h b/code/sdk/application/wearable/fd230app/nativeui/traing/Training_UiConfig.h index 6883e6c51..00168090e 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/Training_UiConfig.h +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/Training_UiConfig.h @@ -4,10 +4,10 @@ #include #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"; diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingModel.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingModel.h index df259f25f..379695cd2 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingModel.h @@ -1,3 +1,4 @@ + #ifndef Traing_MODEL_H #define Traing_MODEL_H @@ -21,16 +22,24 @@ #include "traing/include/TraingModel.h" #include "traing/Training_UiConfig.h" +#include + 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_; }; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingView.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingView.h index a751d0c19..1fcea8104 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingView.h @@ -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 diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingModel.cpp index 633fbc2a7..72d54ae93 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingModel.cpp @@ -1,16 +1,27 @@ #include "traing/include/TraingModel.h" #include "wearable_log.h" +#include +#include 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; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingPresenter.cpp index 8cdefa245..017fbbf0e 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingPresenter.cpp @@ -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::OnStart(); } void TraingPresenter::OnPause(void) { - Presenter::OnPause(); } void TraingPresenter::OnResume(void) { - Presenter::OnResume(); } void TraingPresenter::OnStop(void) { - Presenter::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; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingView.cpp index b8c360d2a..875792e68 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingView.cpp @@ -1,26 +1,27 @@ #include "traing/include/TraingView.h" - +#include +#include namespace OHOS { // 按钮设置 - static constexpr uint16_t BUTTON_WIDHT = 230; - static constexpr uint16_t BUTTON_HEIGHT = 80; - static constexpr uint16_t BUTTON1_X = 118; - static constexpr uint16_t BUTTON1_Y = 336; - static constexpr uint16_t BUTTON2_X = 118; - static constexpr uint16_t BUTTON2_Y = 336; - static constexpr uint16_t BUTTON3_X = 118; - static constexpr uint16_t BUTTON3_Y = 336; - static constexpr uint16_t BUTTONMORE_X = 118; - static constexpr uint16_t BUTTONMORE_Y = 336; + static constexpr uint16_t BUTTON_WIDHT = 140; + static constexpr uint16_t BUTTON_HEIGHT = 140; + static constexpr uint16_t BUTTON1_X = 86; + static constexpr uint16_t BUTTON1_Y = 118; + static constexpr uint16_t BUTTON2_X = 236; + static constexpr uint16_t BUTTON2_Y = 118; + static constexpr uint16_t BUTTON3_X = 86; + static constexpr uint16_t BUTTON3_Y = 268; + static constexpr uint16_t BUTTONMORE_X = 236; + static constexpr uint16_t BUTTONMORE_Y = 268; // 标签设置 static constexpr uint16_t LABEL_FONT_SIZE = 30; static constexpr uint16_t LABEL_X_SIZE = 200; static constexpr uint16_t LABEL_Y_SIZE = 60; - static constexpr uint16_t TITLE_LABEL_X = 83; - static constexpr uint16_t TITLE_LABEL_Y = 103; + static constexpr uint16_t TITLE_LABEL_X = 181; + static constexpr uint16_t TITLE_LABEL_Y = 52; static constexpr uint16_t BTN1_LABEL_X = 135; static constexpr uint16_t BTN1_LABEL_Y = 210; @@ -31,15 +32,18 @@ namespace OHOS // 图片设置 static constexpr uint16_t BTN_IMAGE_SIZE = 100; + static constexpr uint16_t BTN1_IMAGE_X = 126; static constexpr uint16_t BTN1_IMAGE_Y = 148; + static constexpr uint16_t BTN2_IMAGE_X = 276; static constexpr uint16_t BTN2_IMAGE_Y = 148; - static constexpr uint16_t BTNMORE_IMAGE_X = 129; - static constexpr uint16_t BTNMORE_IMAGE_Y = 298; + + static constexpr uint16_t BTN3_IMAGE_X = 129; + static constexpr uint16_t BTN3_IMAGE_Y = 298; static TraingView *g_pTraingView{nullptr}; - QuickTraining *data = new QuickTraining; + static QuickTraining *data = new QuickTraining; TraingView::TraingView() { @@ -65,11 +69,12 @@ namespace OHOS */ bool TraingView::AddLabel() { - // 初始化标签 + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TraingModel::AddLabel"); + // 初始化标签 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); - const char *dataStr1 = data->training1_Text; - const char *dataStr2 = data->training2_Text; - const char *dataStr3 = data->training3_Text; + const char *dataStr1 = (data->training1_Text).c_str(); + const char *dataStr2 = (data->training2_Text).c_str(); + const char *dataStr3 = (data->training3_Text).c_str(); 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); 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); 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); @@ -78,6 +83,27 @@ namespace OHOS bool TraingView::AddButton() { + TraingModel::GetInstance()->InitButton(button1_, BUTTON1_X, BUTTON1_Y, BUTTON_WIDHT, BUTTON_HEIGHT, BUTTON1); + button1_->SetImageSrc(BUTTONGROUND2_IMAGE, nullptr); + UIView::OnClickListener *button1Click = static_cast(TraingPresenter::GetInstance()); + button1_->SetOnClickListener(button1Click); + + TraingModel::GetInstance()->InitButton(button2_, BUTTON2_X, BUTTON2_Y, BUTTON_WIDHT, BUTTON_HEIGHT, BUTTON2); + button2_->SetImageSrc(BOUTTONGROUND_IMAGE, nullptr); + UIView::OnClickListener *button2Click = static_cast(TraingPresenter::GetInstance()); + button2_->SetOnClickListener(button2Click); + + TraingModel::GetInstance()->InitButton(button3_, BUTTON3_X, BUTTON3_Y, BUTTON_WIDHT, BUTTON_HEIGHT, BUTTON3); + button3_->SetImageSrc(BUTTONGROUND2_IMAGE, nullptr); + UIView::OnClickListener *button3Click = static_cast(TraingPresenter::GetInstance()); + button3_->SetOnClickListener(button3Click); + + TraingModel::GetInstance()->InitButton(buttonmore_, BUTTONMORE_X, BUTTONMORE_Y, BUTTON_WIDHT, BUTTON_HEIGHT, BUTTONMORE); + buttonmore_->SetImageSrc(MORE_IMAGE, nullptr); + UIView::OnClickListener *button4Click = static_cast(TraingPresenter::GetInstance()); + buttonmore_->SetOnClickListener(button4Click); + + return true; } /*** * @description: @@ -86,12 +112,15 @@ namespace OHOS */ bool TraingView::AddImageView() { - const char *dataStr1 = data->training1_Image; - const char *dataStr2 = data->training2_Image; - const char *dataStr3 = data->training3_Image; + const char *dataStr1 = (data->training1_Image).c_str(); + const char *dataStr2 = (data->training2_Image).c_str(); + const char *dataStr3 = (data->training3_Image).c_str(); + // const char *dataStr1 = WALKING_60_IMAGE; + // const char *dataStr2 = RUNNING_60_IMAGE; + // const char *dataStr3 = RIDING_60_IMAGE; TraingModel::GetInstance()->InitImageView(btn1_image, BTN1_IMAGE_X, BTN1_IMAGE_Y, BTN_IMAGE_SIZE, BTN_IMAGE_SIZE, "btn1_image", dataStr1); TraingModel::GetInstance()->InitImageView(btn2_image, BTN2_IMAGE_X, BTN2_IMAGE_Y, BTN_IMAGE_SIZE, BTN_IMAGE_SIZE, "btn2_image", dataStr2); - TraingModel::GetInstance()->InitImageView(btn3_image, BTN3_LABEL_X, BTN3_LABEL_Y, BTN_IMAGE_SIZE, BTN_IMAGE_SIZE, "btn3_image", dataStr3); + TraingModel::GetInstance()->InitImageView(btn3_image, BTN3_IMAGE_X, BTN3_IMAGE_Y, BTN_IMAGE_SIZE, BTN_IMAGE_SIZE, "btn3_image", dataStr3); return true; } void TraingView::InitView() @@ -104,112 +133,89 @@ namespace OHOS } // 初始化按键 - + AddButton(); // 初始化标签 + AddLabel(); + // 初始化图片 + AddImageView(); + + container_->Add(button1_); + container_->Add(button2_); + container_->Add(button3_); + container_->Add(buttonmore_); + container_->Add(title_label); + container_->Add(btn1_label); + container_->Add(btn2_label); + container_->Add(btn3_label); + container_->Add(btn1_image); + container_->Add(btn2_image); + container_->Add(btn3_image); + + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TraingModel::InitView"); + } -#if 0 - // Add Button to App - if (button3_ == nullptr) + void TraingView::DeInitView() + { + container_->RemoveAll(); + if (buttonmore_ != nullptr) { - button3_ = new UIButton(); + delete buttonmore_; + buttonmore_ = nullptr; } - button3_->SetPosition(236, 268); // widget's left position and top position - button3_->Resize(140, 140); // widget's width and height - button3_->SetViewId(BUTTONMORE); // Set style - button3_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); - button3_->SetStyle(STYLE_BACKGROUND_OPA, 0x00); - const char *button3defaultImgSrc = PNG_TRAING_BOUTTONMORE_IMAGE; - char *button3triggeredImgSrc = nullptr; - button3_->SetImageSrc(button3defaultImgSrc, button3triggeredImgSrc); - button3_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff33df1c, UIButton::PRESSED); - button3_->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED); - button3_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); - // Add the CallBack about events - UIView::OnClickListener *button3Click = static_cast(TraingPresenter::GetInstance()); - button3_->SetOnClickListener(button3Click); - // Add to rootView - container_->Add(button3_); - button3_->SetVisible(true); - // Add Button to App - if (button4_ == nullptr) + if (button1_ != nullptr) { - button4_ = new UIButton(); + delete button1_; + button1_ = nullptr; } - button4_->SetPosition(86, 118); // widget's left position and top position - button4_->Resize(140, 140); // widget's width and height - button4_->SetViewId(BUTTON2); // Set style - button4_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); - button4_->SetStyle(STYLE_BACKGROUND_OPA, 0x00); - const char *button4defaultImgSrc = PNG_TRAING_BUTTONGRONG2_IMAGE; - char *button4triggeredImgSrc = nullptr; - button4_->SetImageSrc(button4defaultImgSrc, button4triggeredImgSrc); - button4_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff33df1c, UIButton::PRESSED); - button4_->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED); - button4_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); - - UIView::OnClickListener *button4Click = static_cast(TraingPresenter::GetInstance()); - button4_->SetOnClickListener(button4Click); - // Add to rootView - container_->Add(button4_); - button4_->SetVisible(true); - - // Add Button to App - if (button1_ == nullptr) + if (button2_ != nullptr) { - button1_ = new UIButton(); + delete button2_; + button2_ = nullptr; } - button1_->SetPosition(86, 268); // widget's left position and top position - button1_->Resize(140, 140); // widget's width and height - button1_->SetViewId(BUTTON3); // Set style - button1_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); - button1_->SetStyle(STYLE_BACKGROUND_OPA, 0x00); - - const char *button1defaultImgSrc = PNG_TRAING_BUTTONGRONG_IMAGE; - char *button1triggeredImgSrc = nullptr; - button1_->SetImageSrc(button1defaultImgSrc, button1triggeredImgSrc); - button1_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff33df1c, UIButton::PRESSED); - button1_->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED); - button1_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); - - // Add the CallBack about events - UIView::OnClickListener *button1Click = static_cast(TraingPresenter::GetInstance()); - button1_->SetOnClickListener(button1Click); - // Add to rootView - container_->Add(button1_); - button1_->SetVisible(true); - - // Add Button to App - if (button2_ == nullptr) + if (button3_ != nullptr) { - button2_ = new UIButton(); + delete button3_; + button3_ = nullptr; } - button2_->SetPosition(236, 118); // widget's left position and top position - button2_->Resize(140, 140); // widget's width and height - button2_->SetViewId(BUTTON1); // Set style - button2_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); - button2_->SetStyle(STYLE_BACKGROUND_OPA, 0x00); - - const char *button2defaultImgSrc = PNG_TRAING_BUTTONGRONG_IMAGE; - char *button2triggeredImgSrc = nullptr; - button2_->SetImageSrc(button2defaultImgSrc, button2triggeredImgSrc); - button2_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff33df1c, UIButton::PRESSED); - button2_->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED); - button2_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); - - // Add the CallBack about events - UIView::OnClickListener *button2Click = static_cast(TraingPresenter::GetInstance()); - button2_->SetOnClickListener(button2Click); - // Add to rootView - container_->Add(button2_); - button2_->SetVisible(true); -#endif - } - - void TraingView::DeInitView() - { + if (title_label != nullptr) + { + delete title_label; + title_label = nullptr; + } + if (btn1_label != nullptr) + { + delete btn1_label; + btn1_label = nullptr; + } + if (btn2_label != nullptr) + { + delete btn2_label; + btn2_label = nullptr; + } + if (btn3_label != nullptr) + { + delete btn3_label; + btn3_label = nullptr; + } + if (btn1_image != nullptr) + { + delete btn1_image; + btn1_image = nullptr; + } + if (btn2_image != nullptr) + { + delete btn2_image; + btn2_image = nullptr; + } + if (btn3_image != nullptr) + { + delete btn3_image; + btn3_image = nullptr; + } + // 删除容器 if (container_ != nullptr) { - container_->RemoveAll(); + container_->RemoveAll(); // 移除容器中的所有组件 delete container_; container_ = nullptr; } @@ -223,6 +229,12 @@ namespace OHOS void TraingView::OnStart() { + printf(" data--training1_Text: %s\n", data->training1_Text.c_str()); + printf(" data--training1_Image: %s\n", data->training1_Image.c_str()); + printf(" data--training2_Text: %s\n", data->training2_Text.c_str()); + printf(" data--training2_Image: %s\n", data->training2_Image.c_str()); + printf(" data--training3_Text: %s\n", data->training3_Text.c_str()); + printf(" data--training3_Image: %s\n", data->training3_Image.c_str()); container_ = new UIViewGroup(); if (container_ == nullptr) { @@ -244,19 +256,18 @@ namespace OHOS container_->SetDraggable(true); GetView(); + RootView::GetInstance()->Add(container_); } void TraingView::OnSetUpView() { - View::OnSetUpView(); Draw(); } void TraingView::OnTearDownView() { - View::OnTearDownView(); return; } diff --git a/code/sdk/drivers/peripheral/cywee/service/cywee_at_cmd.c b/code/sdk/drivers/peripheral/cywee/service/cywee_at_cmd.c index 89489f84a..b53a177db 100644 --- a/code/sdk/drivers/peripheral/cywee/service/cywee_at_cmd.c +++ b/code/sdk/drivers/peripheral/cywee/service/cywee_at_cmd.c @@ -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;