From: Caisking Date: Mon, 21 Jul 2025 09:48:47 +0000 (+0800) Subject: 修复applist训练图标消失 X-Git-Tag: leiniao_debug_1.0.0_20250922_020716~210^2~17 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.js?a=commitdiff_plain;h=ab41d82c60b4b89f476c201973478d34101859bb;p=mirrors%2FFD230.git 修复applist训练图标消失 --- diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/src/TraingPresenter.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/src/TraingPresenter.cpp index 7c5dafa59..a98635fe4 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/src/TraingPresenter.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/src/TraingPresenter.cpp @@ -2,124 +2,104 @@ * @Date: 2024-04-15 10:55:58 * @LastEditors: Caisking 3449750381@qq.com * @LastEditTime: 2024-04-16 17:33:11 - * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingPresenter.cpp + * @FilePath: + * /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingPresenter.cpp */ #include "AppViewIDs.h" -#include "components/ui_label_ext.h" -#include "ui_resource_string.h" -#include "NativeAbility.h" #include "KeyInputListener.h" -#include "custom_utils.h" +#include "NativeAbility.h" #include "common/key_code.h" +#include "components/ui_label_ext.h" +#include "custom_utils.h" +#include "ui_resource_string.h" -#include -#include -#include -#include "traing/include/TraingPresenter.h" #include "traing/include/TraingModel.h" +#include "traing/include/TraingPresenter.h" #include "uicomponents/UIComponents.h" +#include +#include +#include // #include "TraingView.h" +#include "NativeRegisterManager.h" #include "gfx_utils/mem_check.h" -namespace OHOS -{ +namespace OHOS { +REGIST_MENU_PRO(VIEW_TRAINING, TraingView, TraingPresenter, + PNG_APPLIST_TRAINING_IMAGE_BIG, PNG_APPLIST_TRAINING_IMAGE, + PNG_APPLIST_TRAINING_IMAGE, "运动", STR_TRAINING); - // 当前Presenter属性实例化的内存指针 - static TraingPresenter *g_pTraingPresenter = nullptr; +// 当前Presenter属性实例化的内存指针 +static TraingPresenter *g_pTraingPresenter = nullptr; - TraingPresenter::TraingPresenter() - { - g_pTraingPresenter = this; +TraingPresenter::TraingPresenter() { + g_pTraingPresenter = this; #ifdef MEM_CHECK - MemCheck::GetInstance()->EnableLeakCheck(true); + MemCheck::GetInstance()->EnableLeakCheck(true); #endif - } +} - TraingPresenter::~TraingPresenter() - { - g_pTraingPresenter = nullptr; +TraingPresenter::~TraingPresenter() { + g_pTraingPresenter = nullptr; #ifdef MEM_CHECK - MemCheck::GetInstance()->EnableLeakCheck(false); + MemCheck::GetInstance()->EnableLeakCheck(false); #endif - } +} - TraingPresenter *TraingPresenter::GetInstance() - { - return g_pTraingPresenter; - } +TraingPresenter *TraingPresenter::GetInstance() { return g_pTraingPresenter; } - void TraingPresenter::OnStart() - { - Presenter::OnStart(); - } +void TraingPresenter::OnStart() { Presenter::OnStart(); } - void TraingPresenter::OnPause(void) - { - Presenter::OnPause(); - } +void TraingPresenter::OnPause(void) { Presenter::OnPause(); } - void TraingPresenter::OnResume(void) - { - Presenter::OnResume(); - } +void TraingPresenter::OnResume(void) { Presenter::OnResume(); } - void TraingPresenter::OnStop(void) - { - Presenter::OnStop(); - } - // 回退函数 [ Slice 的 traingview {右滑只能回到applist}] - void TraingPresenter::NavigateBack() - { - NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST, TransitionType::TRANSITION_BACK_TO_HEXAGONS); - NativeAbility::GetInstance().ClearSliceIdStack(); // 清空所有SLiceId栈元素 - } - bool TraingPresenter::OnDrag(UIView &view, const DragEvent &event) - { - return true; - } - bool TraingPresenter::OnDragEnd(UIView &view, const DragEvent &event) - { - UNUSED(view); - if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) - NavigateBack(); - return true; - } +void TraingPresenter::OnStop(void) { Presenter::OnStop(); } +// 回退函数 [ Slice 的 traingview {右滑只能回到applist}] +void TraingPresenter::NavigateBack() { + NativeAbility::GetInstance().ChangeSlice( + VIEW_APPLIST, TransitionType::TRANSITION_BACK_TO_HEXAGONS); + NativeAbility::GetInstance().ClearSliceIdStack(); // 清空所有SLiceId栈元素 +} +bool TraingPresenter::OnDrag(UIView &view, const DragEvent &event) { + return true; +} +bool TraingPresenter::OnDragEnd(UIView &view, const DragEvent &event) { + UNUSED(view); + if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) + NavigateBack(); + return true; +} - bool TraingPresenter::OnClick(UIView &view, const ClickEvent &event) - { - if (strcmp(view.GetViewId(), BUTTON1) == 0) - { - NativeAbility::GetInstance().EnterSlice(VIEW_TRAININGNOMAL); - TraingModel::GetInstance()->SetSportEvent(STR_EXERCISE_OUTDOORWALKING); - } - if (strcmp(view.GetViewId(), BUTTON3) == 0) - { - NativeAbility::GetInstance().EnterSlice(VIEW_TRAININGNOMAL); - TraingModel::GetInstance()->SetSportEvent(STR_EXERCISE_OUTDOORRUNNING); - } - if (strcmp(view.GetViewId(), BUTTONMORE) == 0) - { - NativeAbility::GetInstance().EnterSlice(VIEW_TRAININGMORE); - } - if (strcmp(view.GetViewId(), BUTTON2) == 0) { - NativeAbility::GetInstance().EnterSlice(VIEW_TRAININGNOMAL); - TraingModel::GetInstance()->SetSportEvent( - STR_EXERCISE_FREETRAINING); //修改为自由训练 - } - TraingModel::GetInstance()->SetSportType(Exercisetype::FITNESS); - return true; - } +bool TraingPresenter::OnClick(UIView &view, const ClickEvent &event) { + if (strcmp(view.GetViewId(), BUTTON1) == 0) { + NativeAbility::GetInstance().EnterSlice(VIEW_TRAININGNOMAL); + TraingModel::GetInstance()->SetSportEvent(STR_EXERCISE_OUTDOORWALKING); + } + if (strcmp(view.GetViewId(), BUTTON3) == 0) { + NativeAbility::GetInstance().EnterSlice(VIEW_TRAININGNOMAL); + TraingModel::GetInstance()->SetSportEvent(STR_EXERCISE_OUTDOORRUNNING); + } + if (strcmp(view.GetViewId(), BUTTONMORE) == 0) { + NativeAbility::GetInstance().EnterSlice(VIEW_TRAININGMORE); + } + if (strcmp(view.GetViewId(), BUTTON2) == 0) { + NativeAbility::GetInstance().EnterSlice(VIEW_TRAININGNOMAL); + TraingModel::GetInstance()->SetSportEvent( + STR_EXERCISE_FREETRAINING); //修改为自由训练 + } + TraingModel::GetInstance()->SetSportType(Exercisetype::FITNESS); + return true; +} - // 增加按键事件 - bool TraingPresenter::OnKeyAct(UIView &view, const KeyEvent &event) - { - unsigned short keyID = event.GetKeyId(); - unsigned short keyState = event.GetState(); - // 如果是power键,且是亮屏状态,按键释放就返回上一级 - if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER) && - keyState == 1 && uapi_get_screen_state() == 0) - NavigateBack(); +// 增加按键事件 +bool TraingPresenter::OnKeyAct(UIView &view, const KeyEvent &event) { + unsigned short keyID = event.GetKeyId(); + unsigned short keyState = event.GetState(); + // 如果是power键,且是亮屏状态,按键释放就返回上一级 + if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER) && + keyState == 1 && uapi_get_screen_state() == 0) + NavigateBack(); - return true; - } + return true; } +} // namespace OHOS diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_card/src/TraingCardPresenter.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_card/src/TraingCardPresenter.cpp index fd10a7990..01743235f 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_card/src/TraingCardPresenter.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_card/src/TraingCardPresenter.cpp @@ -122,7 +122,7 @@ void TraingCardPresenter::ModifiesTime() { } if (TrainingDataView::GetInstance()->GetTimeLabel() != nullptr) { TrainingDataView::GetInstance()->GetTimeLabel()->SetText(TimeStr.c_str()); - } + } } WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ModifiesTime end"); } @@ -289,7 +289,8 @@ void TraingCardPresenter::RefreshData(SportData *sportdata) { #if 1 void TraingCardPresenter::Notify(void) { // 如果未开启训练,直接退出 - if (TraingModel::GetInstance()->GetSportState() == ExerciseState::General || view_ == nullptr) { + if (TraingModel::GetInstance()->GetSportState() == ExerciseState::General || + view_ == nullptr) { return; }