From: luozheng <1732036298@qq.com> Date: Thu, 27 Jun 2024 12:37:38 +0000 (+0800) Subject: 优化下拉,指南针,音乐,Load和Unload X-Git-Tag: release_V1.2.70_20241020_135402~928^2~8 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=120e2426094d01ce466844d8a2491656b4ce4c25;p=mirrors%2FFD230.git 优化下拉,指南针,音乐,Load和Unload --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/activity/src/ActivityWeekView.cpp b/code/sdk/application/wearable/fd230app/nativeui/activity/src/ActivityWeekView.cpp index 54a62e3e6..abf06b5a6 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/activity/src/ActivityWeekView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/activity/src/ActivityWeekView.cpp @@ -381,6 +381,7 @@ bool ActivityWeekView::InitView() void ActivityWeekView::PreLoad(void) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ActivityWeekView::PreLoad"); if (!viewiInitStatus) { if (InitView()) { viewiInitStatus = true; @@ -398,6 +399,7 @@ void ActivityWeekView::PreLoad(void) void ActivityWeekView::UnLoad(void) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ActivityWeekView::UnLoad"); if (resLoadStatus) { ImageInfo* img = nullptr; imageViewShoe->SetSrc(img); diff --git a/code/sdk/application/wearable/fd230app/nativeui/compass/src/CompassView.cpp b/code/sdk/application/wearable/fd230app/nativeui/compass/src/CompassView.cpp index b8f32b702..96cb297fb 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/compass/src/CompassView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/compass/src/CompassView.cpp @@ -130,7 +130,9 @@ void CompassView::UnLoadCompassImageRes(void) backGround->SetSrc(image); PlaceMarkerImage->SetSrc(image); triangulation->SetSrc(image); - ImageCacheManager::GetInstance().UnloadAllInMultiRes(COMPASS_IAMGES); + ImageCacheManager::GetInstance().UnloadOneInMultiRes(COMPASS_COMPASS0,COMPASS_IAMGES); + ImageCacheManager::GetInstance().UnloadOneInMultiRes(COMPASS_COMPASS1,COMPASS_IAMGES); + ImageCacheManager::GetInstance().UnloadOneInMultiRes(COMPASS_COMPASS2,COMPASS_IAMGES); SetResLoadStatus(false); } } diff --git a/code/sdk/application/wearable/fd230app/nativeui/goal/src/goalControlView.cpp b/code/sdk/application/wearable/fd230app/nativeui/goal/src/goalControlView.cpp index 78d8b438c..86fad0920 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/goal/src/goalControlView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/goal/src/goalControlView.cpp @@ -79,6 +79,7 @@ namespace OHOS void goalControlView::UnLoad(void) { // Weather's usage scenes is complicated, so we do not release it's resources inner slice. + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "goalControlView::UnLoad"); } } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/heart_blood/BloodCardView.cpp b/code/sdk/application/wearable/fd230app/nativeui/heart_blood/BloodCardView.cpp index 4d51fde35..42fe44b96 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/heart_blood/BloodCardView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/heart_blood/BloodCardView.cpp @@ -239,6 +239,7 @@ namespace OHOS /* -------------------------------------------------------------------------- */ void BloodCardView::PreLoad(void) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodCardView::PreLoad"); if (!viewiInitStatus) { InitView(); @@ -259,6 +260,7 @@ namespace OHOS void BloodCardView::UnLoad(void) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodCardView::UnLoad"); if (resLoadStatus) { ImageInfo *img = nullptr; diff --git a/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartRateView.cpp b/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartRateView.cpp index 422e5243e..63e4db13d 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartRateView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartRateView.cpp @@ -605,6 +605,7 @@ namespace OHOS void HeartRateView::PreLoad(void) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HeartRateView::PreLoad"); if (!viewiInitStatus) { if (InitView()) @@ -623,6 +624,7 @@ namespace OHOS void HeartRateView::UnLoad(void) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HeartRateView::UnLoad"); if (resLoadStatus) { ImageInfo *img = nullptr; diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/src/PullUpDownView.cpp b/code/sdk/application/wearable/fd230app/nativeui/main/src/PullUpDownView.cpp index 478b57de3..e55e70ac0 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/src/PullUpDownView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/main/src/PullUpDownView.cpp @@ -950,32 +950,13 @@ namespace OHOS ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, drofindPhone, DROPDOWN_FINDPHONE); ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, dropLine, DROPDOWN_LINE); /* -------------------------------------------------------------------------- */ - if (GetPhoneConnectedStatus()) // 获取手机连接状态 - { - ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, showPhoneConnectedStatus, DROPDOWN_PHONECONNECTED); - } - else - { - ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, showPhoneConnectedStatus, DROPDOWN_PHONEDISCONNECTED); - } - - if (GetEarPhoneConnectedStatus()) // 获取耳机连接状态 - { - ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, showEarPhoneConnectedStatus, DROPDOWN_EARPHONESCONNECTED); - } - else - { - ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, showEarPhoneConnectedStatus, DROPDOWN_EARPHONESDISCONNECTED); - } + bool phoneStatus = GetPhoneConnectedStatus(); // 获取手机连接状态 + bool EarPhoneStatus = GetEarPhoneConnectedStatus(); // 获取耳机连接状态 + bool blueToothStatus = GetBlueToothConnectedStatus(); // 获取蓝牙连接状态 + ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, showPhoneConnectedStatus, phoneStatus ? DROPDOWN_PHONECONNECTED : DROPDOWN_PHONEDISCONNECTED); + ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, showEarPhoneConnectedStatus, EarPhoneStatus ? DROPDOWN_EARPHONESCONNECTED : DROPDOWN_EARPHONESDISCONNECTED); + ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, showBluetoothConnectedStatus, blueToothStatus ? DROPDOWN_BLUETOOTHCONNECTED : DROPDOWN_BLUETOOTHDISCONNECTED); - if (GetBlueToothConnectedStatus()) // 获取蓝牙连接状态 - { - ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, showBluetoothConnectedStatus, DROPDOWN_BLUETOOTHCONNECTED); - } - else - { - ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, showBluetoothConnectedStatus, DROPDOWN_BLUETOOTHDISCONNECTED); - } /* -------------------------------------------------------------------------- */ ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, NoSignal, DROPDOWN_NOSIGNAL); /* -------------------------------------------------------------------------- */ @@ -988,22 +969,44 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PullUpDownView::UnLoad"); if (resLoadStatus) { - ImageInfo *img =nullptr; + ImageInfo *img = nullptr; for (int i = 0; i < MAX_INDEX; i++) { dropIconBackground[i]->SetSrc(img); } + /* -------------------------------------------------------------------------- */ dropSetting->SetSrc(img); dropLighting->SetSrc(img); dropDnotDisturb->SetSrc(img); dropSavePower->SetSrc(img); drofindPhone->SetSrc(img); dropLine->SetSrc(img); + /* -------------------------------------------------------------------------- */ showPhoneConnectedStatus->SetSrc(img); showEarPhoneConnectedStatus->SetSrc(img); showBluetoothConnectedStatus->SetSrc(img); + /* -------------------------------------------------------------------------- */ NoSignal->SetSrc(img); - ImageCacheManager::GetInstance().UnloadAllInMultiRes(DROPDOWN_IAMGES); + /* -------------------------------------------------------------------------- */ + bool isDoNotDisturbOpen = DnotDisturbModel::GetInstance().GetDoNotDisturbModeEnabled(); // 勿扰是否开启 + ImageCacheManager::GetInstance().UnloadOneInMultiRes(isDoNotDisturbOpen ? DROPDOWN_ICONELLIPSEPURPLE : DROPDOWN_ICONELLIPSEBLACK, DROPDOWN_IAMGES); + /* -------------------------------------------------------------------------- */ + ImageCacheManager::GetInstance().UnloadOneInMultiRes(DROPDOWN_SETTING, DROPDOWN_IAMGES); + ImageCacheManager::GetInstance().UnloadOneInMultiRes(DROPDOWN_BLUETOOTH, DROPDOWN_IAMGES); + ImageCacheManager::GetInstance().UnloadOneInMultiRes(DROPDOWN_DNOTDISTURB, DROPDOWN_IAMGES); + ImageCacheManager::GetInstance().UnloadOneInMultiRes(DROPDOWN_SAVEPOWER, DROPDOWN_IAMGES); + ImageCacheManager::GetInstance().UnloadOneInMultiRes(DROPDOWN_FINDPHONE, DROPDOWN_IAMGES); + ImageCacheManager::GetInstance().UnloadOneInMultiRes(DROPDOWN_LINE, DROPDOWN_IAMGES); + /* -------------------------------------------------------------------------- */ + bool phoneStatus = GetPhoneConnectedStatus(); // 获取手机连接状态 + bool EarPhoneStatus = GetEarPhoneConnectedStatus(); // 获取耳机连接状态 + bool blueToothStatus = GetBlueToothConnectedStatus(); // 获取蓝牙连接状态 + ImageCacheManager::GetInstance().UnloadOneInMultiRes(phoneStatus ? DROPDOWN_PHONECONNECTED : DROPDOWN_PHONEDISCONNECTED, DROPDOWN_IAMGES); + ImageCacheManager::GetInstance().UnloadOneInMultiRes(EarPhoneStatus ? DROPDOWN_EARPHONESCONNECTED : DROPDOWN_EARPHONESDISCONNECTED, DROPDOWN_IAMGES); + ImageCacheManager::GetInstance().UnloadOneInMultiRes(blueToothStatus ? DROPDOWN_BLUETOOTHCONNECTED : DROPDOWN_BLUETOOTHDISCONNECTED, DROPDOWN_IAMGES); + /* -------------------------------------------------------------------------- */ + ImageCacheManager::GetInstance().UnloadOneInMultiRes(DROPDOWN_NOSIGNAL, DROPDOWN_IAMGES); + /* -------------------------------------------------------------------------- */ resLoadStatus = false; } } diff --git a/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageControlView.cpp b/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageControlView.cpp index 861c2ea3e..068539ca1 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageControlView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageControlView.cpp @@ -111,6 +111,7 @@ namespace OHOS void MessageControlView::PreLoad(void) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MessageControlView::PreLoad"); if (!viewiInitStatus) { InitView(); @@ -121,5 +122,6 @@ namespace OHOS void MessageControlView::UnLoad(void) { // Message's usage scenes is complicated, so we do not release it's resources inner slice. + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MessageControlView::UnLoad"); } } diff --git a/code/sdk/application/wearable/fd230app/nativeui/player/include/PlayerListDelSongView.h b/code/sdk/application/wearable/fd230app/nativeui/player/include/PlayerListDelSongView.h index 41f95bae1..7e6b3ddfa 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/player/include/PlayerListDelSongView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/player/include/PlayerListDelSongView.h @@ -1,35 +1,63 @@ #ifndef PLAYER_LIST_DEL_SONG_VIEW_H #define PLAYER_LIST_DEL_SONG_VIEW_H -#include "BaseView.h" #include "string" -#include "View.h" +#include "iostream" #include "components/ui_scroll_view.h" -#include "components/ui_label.h" #include "components/ui_label_ext.h" #include "components/ui_button.h" namespace OHOS { + static constexpr const char *ENSURE_DELETE_BUTTON = "ensureDeleteButton"; + static constexpr const char *CANCEL_DELETE_BUTTON = "cancelDeleteButton"; class PlayerListDelSongView { - public: + struct LabelConfig + { + int16_t left; + int16_t top; + int16_t width; + int16_t height; + int16_t fontSize; + int16_t lineHeigh; + uint16_t textId; + uint8_t lineBreakMode; + }; + struct ButtonConfig + { + int16_t x; + int16_t y; + int16_t w; + int16_t h; + const char *ViewId; + const char *src; + }; + PlayerListDelSongView(); virtual ~PlayerListDelSongView(); static PlayerListDelSongView *GetInstance(void); - UIScrollView * InitDelSongView(); - void DeInitView(void); - void SetTheSongLabelStyle(const char * songName); + UIScrollView *InitDelSongView(); + void SetTheSongLabelStyle(const char *songName); + void DeleteSongNameFile(void); + private: - UIScrollView *scrollView1_ = nullptr; - UILabel *label1_ = nullptr; - UILabel *songNameLabel = nullptr; - UIButton *button3_ = nullptr; - UILabel *label2_ = nullptr; - UIButton *button1_ = nullptr; - UIButton *button2_ = nullptr; - bool viewInitStatus{false}; -}; + void ClearAll(void); + UILabelExt *PlayerListDelSongViewLabelInit(LabelConfig &labelconfig); + UIButton *PlayerListDelSongViewButtonInit(ButtonConfig &buttonconfig); + bool CreatePlayerListDelSongViewLabel(void); + bool CreatPlayerListDelSongViewButton(void); + bool CreatePlayerListDelSongViewScrollView(void); + UIScrollView *scrollView{nullptr}; + UILabelExt *title{nullptr}; + UILabelExt *deleteNotelabel{nullptr}; + UILabelExt *songNameLabel{nullptr}; + UIButton *ensureDeleteButton{nullptr}; + UIButton *cancelDeleteButton{nullptr}; + + std::string delSongName; + + }; } #endif diff --git a/code/sdk/application/wearable/fd230app/nativeui/player/include/PlayersView.h b/code/sdk/application/wearable/fd230app/nativeui/player/include/PlayersView.h index bf208e8c4..f7c4e627c 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/player/include/PlayersView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/player/include/PlayersView.h @@ -86,6 +86,9 @@ public: { return p_PlayerListDelSongView; } +private: + void playerResPreLoad(void); + void playerResUnLoad(void); private: bool InitBackGround(void); void TearDownView(); @@ -137,6 +140,7 @@ private: UIView::OnClickListener *optionslistener{nullptr}; UIView::OnClickListener *music_list_button_listener{nullptr}; bool viewiInitStatus{false}; + bool resLoadStatus{false}; }; } // namespace OHOS #endif // MAIN_VIEW_H diff --git a/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayerListDelSongView.cpp b/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayerListDelSongView.cpp index 03d6d6ae8..d13d41b37 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayerListDelSongView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayerListDelSongView.cpp @@ -1,169 +1,250 @@ -#include "PlayerListDelSongView.h" -#include "PlayersPresenter.h" +#include "player/include/PlayerListDelSongView.h" +#include "player/include/PlayersPresenter.h" +#include "wearable_log.h" +#include "language/font/ui_resource_string.h" +#include "UiConfig.h" +#include "custom_utils.h" namespace OHOS { - - static PlayerListDelSongView *g_pPlayerListDelSongView{nullptr}; - PlayerListDelSongView::PlayerListDelSongView() { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PlayerListDelSongView::PlayerListDelSongView"); g_pPlayerListDelSongView = this; } PlayerListDelSongView::~PlayerListDelSongView() { - if (viewInitStatus == true) - { - DeInitView(); - } + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PlayerListDelSongView::PlayerListDelSongView"); + ClearAll(); g_pPlayerListDelSongView = nullptr; } PlayerListDelSongView *PlayerListDelSongView::GetInstance() { - return g_pPlayerListDelSongView; } + void PlayerListDelSongView::ClearAll(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PlayerListDelSongView::ClearAll"); + if (scrollView != nullptr) + { + scrollView->RemoveAll(); + + if (title != nullptr) + { + delete title; + title = nullptr; + } + + if (deleteNotelabel != nullptr) + { + delete deleteNotelabel; + deleteNotelabel = nullptr; + } + if (songNameLabel != nullptr) + { + delete songNameLabel; + songNameLabel = nullptr; + } + if (ensureDeleteButton != nullptr) + { + delete ensureDeleteButton; + ensureDeleteButton = nullptr; + } + if (cancelDeleteButton != nullptr) + { + delete cancelDeleteButton; + cancelDeleteButton = nullptr; + } + + delete scrollView; + scrollView = nullptr; + } + } + /// @brief 设置歌曲名标签样式 /// @param songName 歌曲名 - void PlayerListDelSongView::SetTheSongLabelStyle(const char * songName) + void PlayerListDelSongView::SetTheSongLabelStyle(const char *songName) { + delSongName = songName; songNameLabel->SetText(songName); songNameLabel->Invalidate(); } - UIScrollView * PlayerListDelSongView::InitDelSongView() + void PlayerListDelSongView::DeleteSongNameFile(void) { - if (scrollView1_ == nullptr) + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " whill Deleted file:", delSongName.c_str()); + std::string path = "/user/music/" + delSongName; + + if (uapi_delete_files(path.c_str())) { - scrollView1_ = new UIScrollView(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Deleted file: %s successed!", path.c_str()); } - scrollView1_->SetPosition(0, 0,466,466); - scrollView1_->SetStyle(STYLE_BACKGROUND_OPA, 0xff); - scrollView1_->SetDirection(1); - scrollView1_->SetVisible(true); - /* -------------------------------------------------------------------------- */ - if (label1_ == nullptr) + else { - label1_ = new UILabel(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to delete file!"); } - label1_->SetPosition(172, 160); - label1_->SetStyle(STYLE_TEXT_FONT, 30); - label1_->SetStyle(STYLE_LINE_HEIGHT, 35); - label1_->SetText("是否删除"); - label1_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - label1_->SetTextColor(Color::GetColorFromRGBA(0x66, 0x66, 0x66, 0xff)); - label1_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - label1_->SetRollSpeed(0); - label1_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); - scrollView1_->Add(label1_); - label1_->SetVisible(true); - /* -------------------------------------------------------------------------- */ - if (songNameLabel == nullptr) + } + + UILabelExt *PlayerListDelSongView::PlayerListDelSongViewLabelInit(LabelConfig &labelconfig) + { + UILabelExt *label = new UILabelExt(); + if (label == nullptr) { - songNameLabel = new UILabel(); + return nullptr; } - songNameLabel->SetPosition(83, 220,300,35); - songNameLabel->SetStyle(STYLE_TEXT_FONT, 30); - songNameLabel->SetStyle(STYLE_LINE_HEIGHT, 35); - songNameLabel->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); - songNameLabel->SetTextColor(Color::GetColorFromRGBA(0x4f, 0xc3, 0x4c, 0xff)); - songNameLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - songNameLabel->SetRollSpeed(0); - songNameLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); - scrollView1_->Add(songNameLabel); - songNameLabel->SetVisible(true); - /* -------------------------------------------------------------------------- */ - if (label2_ == nullptr) + label->SetPosition(labelconfig.left, labelconfig.top, labelconfig.width, labelconfig.height); + label->SetStyle(STYLE_TEXT_FONT, labelconfig.fontSize); + label->SetStyle(STYLE_LINE_HEIGHT, labelconfig.lineHeigh); + label->SetTextId(labelconfig.textId); + label->SetLineBreakMode(labelconfig.lineBreakMode); + label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, labelconfig.fontSize); + return label; + } + + UIButton *PlayerListDelSongView::PlayerListDelSongViewButtonInit(ButtonConfig &buttonconfig) + { + UIButton *button = new UIButton(); + if (button == nullptr) + { + return nullptr; + } + button->SetPosition(buttonconfig.x, buttonconfig.y, buttonconfig.w, buttonconfig.h); + button->SetViewId(buttonconfig.ViewId); + button->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + button->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + button->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff383838, UIButton::PRESSED); + button->SetImageSrc(buttonconfig.src, buttonconfig.src); + + return button; + } + + bool PlayerListDelSongView::CreatePlayerListDelSongViewLabel(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PlayerListDelSongView::CreatePlayerListDelSongViewLabel"); + LabelConfig labelConfig = { + .left = 83, + .top = 52, + .width = 300, + .height = 35, + .fontSize = 30, + .lineHeigh = 35, + .textId = STR_MUSIC_LIST, + .lineBreakMode = UILabel::LINE_BREAK_MARQUEE, + }; + title = PlayerListDelSongViewLabelInit(labelConfig); + if (title == nullptr) { - label2_ = new UILabel(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "title new fail!"); + return false; } - label2_->SetPosition(173, 52); - label2_->Resize(120, 35); - label2_->SetViewId("label1"); - label2_->SetStyle(STYLE_TEXT_FONT, 30); - label2_->SetStyle(STYLE_LINE_HEIGHT, 36); - label2_->SetText("删除歌曲"); - label2_->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS); - label2_->SetRollSpeed(0); - label2_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); - scrollView1_->Add(label2_); - label2_->SetVisible(true); /* -------------------------------------------------------------------------- */ - if (button1_ == nullptr) + labelConfig.left = 53; + labelConfig.top = 160; + labelConfig.width = 360; + deleteNotelabel = PlayerListDelSongViewLabelInit(labelConfig); + if (deleteNotelabel == nullptr) { - button1_ = new UIButton(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "deleteNotelabel new fail!"); + return false; } - button1_->SetPosition(256, 299); - button1_->Resize(100, 100); - button1_->SetViewId("Delbutton"); - button1_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); - char *button1defaultImgSrc = "/user/res/SYSTEM_CheckOn.bin"; - button1_->SetImageSrc(button1defaultImgSrc, nullptr); - button1_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); - scrollView1_->Add(button1_); - button1_->SetVisible(true); + deleteNotelabel->SetText("是否删除"); + deleteNotelabel->SetTextColor(Color::GetColorFromRGBA(0x66, 0x66, 0x66, 0xff)); /* -------------------------------------------------------------------------- */ - if (button2_ == nullptr) + labelConfig.top = 220; + songNameLabel = PlayerListDelSongViewLabelInit(labelConfig); + if (songNameLabel == nullptr) { - button2_ = new UIButton(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "songNameLabel new fail!"); + return false; } - button2_->SetPosition(111, 299); - button2_->Resize(100, 100); - button2_->SetViewId("returnbutton"); - button2_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); - char *button2defaultImgSrc = "/user/res/SYSTEM_CheckOff.bin"; - button2_->SetImageSrc(button2defaultImgSrc, nullptr); - button2_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); - scrollView1_->Add(button2_); - button2_->SetVisible(true); - - UIView::OnClickListener *buttonClickListener = static_cast(new ButtonOnClickListener()); - button1_->SetOnClickListener(buttonClickListener); - button2_->SetOnClickListener(buttonClickListener); - viewInitStatus = true; - return scrollView1_; + songNameLabel->SetText(""); + songNameLabel->SetTextColor(Color::GetColorFromRGBA(0x4f, 0xc3, 0x4c, 0xff)); + + return true; } - void PlayerListDelSongView::DeInitView() + bool PlayerListDelSongView::CreatPlayerListDelSongViewButton(void) { - if (scrollView1_ != nullptr) - { - delete scrollView1_; - scrollView1_ = nullptr; - } - if (label1_ != nullptr) + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PlayerListDelSongView::CreatPlayerListDelSongViewButton"); + ButtonConfig buttonconfig = { + .x = 111, + .y = 299, + .w = 100, + .h = 100, + .ViewId = CANCEL_DELETE_BUTTON, + .src = PNG_SYSTEM_CHECK_OFF_IMAGE, + }; + ensureDeleteButton = PlayerListDelSongViewButtonInit(buttonconfig); + if (ensureDeleteButton == nullptr) { - delete label1_; - label1_ = nullptr; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ensureDeleteButton new fail!"); + return false; } - if (songNameLabel != nullptr) - { - delete songNameLabel; - songNameLabel = nullptr; - } - if (button3_ != nullptr) + /* -------------------------------------------------------------------------- */ + buttonconfig.x = 256; + buttonconfig.src = PNG_SYSTEM_CHECK_ON_IMAGE; + cancelDeleteButton = PlayerListDelSongViewButtonInit(buttonconfig); + if (cancelDeleteButton == nullptr) { - delete button3_; - button3_ = nullptr; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "cancelDeleteButton new fail!"); + return false; } - if (label2_ != nullptr) + UIView::OnClickListener *buttonClickListener = static_cast(ButtonOnClickListener::GetInstance()); + if (buttonClickListener == nullptr) { - delete label2_; - label2_ = nullptr; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ButtonOnClickListener::GetInstance fail"); + return false; } - if (button1_ != nullptr) + ensureDeleteButton->SetOnClickListener(buttonClickListener); + cancelDeleteButton->SetOnClickListener(buttonClickListener); + + return true; + } + + bool PlayerListDelSongView::CreatePlayerListDelSongViewScrollView(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PlayerListDelSongView::CreatePlayerListDelSongViewScrollView"); + if (scrollView == nullptr) { - delete button1_; - button1_ = nullptr; + scrollView = new UIScrollView(); + if (scrollView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AivoiceThinkingView::scrollView new fail!"); + return false; + } + scrollView->SetPosition(0, 0, 466, 466); + // UIView::OnDragListener *dragListener = static_cast(AiVoicePresenter::GetInstance()); + // if (dragListener == nullptr) + // { + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AivoiceThinkingView::dragListener new fail!"); + // return false; + // } + // scrollView->SetOnDragListener(dragListener); + scrollView->SetTouchable(true); + scrollView->SetDraggable(true); } - if (button2_ != nullptr) + return true; + } + + UIScrollView *PlayerListDelSongView::InitDelSongView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PlayerListDelSongView::InitDelSongView"); + if (!CreatePlayerListDelSongViewScrollView() || !CreatePlayerListDelSongViewLabel() || !CreatPlayerListDelSongViewButton()) { - delete button2_; - button2_ = nullptr; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PlayerListDelSongView::InitDelSongView fail!!"); } + scrollView->Add(title); + scrollView->Add(deleteNotelabel); + scrollView->Add(songNameLabel); + scrollView->Add(ensureDeleteButton); + scrollView->Add(cancelDeleteButton); + + return scrollView; } -} \ No newline at end of file + +} diff --git a/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersPresenter.cpp index 1191eb5b5..c2d12cc25 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersPresenter.cpp @@ -22,6 +22,7 @@ #include "bts_avrcp_controller.h" #include "bts_avrcp_target.h" +#include namespace OHOS { static PlayerOnDragListener *g_pPlayerOnDragListener = nullptr; @@ -668,16 +669,14 @@ bool ButtonOnClickListener::OnClick(UIView& view, const ClickEvent& event) { PlayersPresenter::GetInstance()->ShowPlayerListGroup(); } - else if(strcmp(view.GetViewId(),"Delbutton") == 0) + else if(strcmp(view.GetViewId(),ENSURE_DELETE_BUTTON) == 0) //删除音乐 { - printf("Delbutton %s %d\n",__func__,__LINE__); + //playersView->GetDelSongView()->DeleteSongNameFile(); } - else if(strcmp(view.GetViewId(),"returnbutton") == 0) + else if(strcmp(view.GetViewId(),CANCEL_DELETE_BUTTON) == 0) //不删除音乐 { - PlayersView *playersView = PlayersView::GetInstance(); playersView->SetPlayerDelSongViewStatus(false); playersView->SetPlayerListGroupStatus(true); - RootView::GetInstance()->Invalidate(); } return true; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersView.cpp b/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersView.cpp index dd9acce0a..f54088d30 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersView.cpp @@ -425,11 +425,11 @@ namespace OHOS soundButton->SetTouchable(true); soundButton->SetPosition(321, 321, 60, 60); soundButton->SetOnClickListener(soundlistener); - if (LoadPlayerImage(soundButton, PLAYER_MUSIC_VOICE) == false) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "playerModelButton LoadPlayerImage fail"); - return false; - } + // if (LoadPlayerImage(soundButton, PLAYER_MUSIC_VOICE) == false) + // { + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "playerModelButton LoadPlayerImage fail"); + // return false; + // } Add(soundButton); return OHOS_SUCCESS; } @@ -481,10 +481,10 @@ namespace OHOS playerModelButton->SetTouchable(true); playerModelButton->SetPosition(pointBtn.x, pointBtn.y, 60, 60); playerModelButton->SetOnClickListener(modellistener); - if (ShowUpPlayerMode() == false) - { - return OHOS_FAILURE; - } + // if (ShowUpPlayerMode() == false) + // { + // return OHOS_FAILURE; + // } WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "playerModel %d", PlayersModel::GetInstance()->GetPlayerModel()); Add(playerModelButton); @@ -728,11 +728,11 @@ namespace OHOS } } backGround->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); - if (LoadPlayerImage(backGround, PLAYER_BACKGROUND) == false) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "backGround LoadPlayerImage fail"); - return false; - } + // if (LoadPlayerImage(backGround, PLAYER_BACKGROUND) == false) + // { + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "backGround LoadPlayerImage fail"); + // return false; + // } /* -------------------------------------------------------------------------- */ if (elipse == nullptr) { @@ -744,11 +744,11 @@ namespace OHOS } } elipse->SetPosition(173, 173, 120, 120); - if (LoadPlayerImage(elipse, PLAYER_ELLIPSE) == false) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "elipse LoadPlayerImage fail"); - return false; - } + // if (LoadPlayerImage(elipse, PLAYER_ELLIPSE) == false) + // { + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "elipse LoadPlayerImage fail"); + // return false; + // } Add(backGround); Add(elipse); return true; @@ -923,6 +923,7 @@ namespace OHOS void PlayersView::PreLoad(void) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PlayersView::PreLoad"); if (!viewiInitStatus) { if (InitView()) @@ -930,11 +931,13 @@ namespace OHOS viewiInitStatus = true; } } + playerResPreLoad(); } void PlayersView::UnLoad(void) { - // Players's usage scenes is complicated, so we do not release it's resources inner slice. + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PlayersView::UnLoad"); + playerResUnLoad(); } // 加载音乐图片 bool PlayersView::LoadPlayerImage(UIImageView *view, uint32_t resId) @@ -949,4 +952,49 @@ namespace OHOS view->SetSrc(image); return true; } + + void PlayersView::playerResPreLoad(void) + { + if(!resLoadStatus) + { + if (LoadPlayerImage(soundButton, PLAYER_MUSIC_VOICE) == false) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "playerModelButton LoadPlayerImage fail"); + return ; + } + // if (ShowUpPlayerMode() == false) + // { + // return; + // } + if (LoadPlayerImage(backGround, PLAYER_BACKGROUND) == false) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "backGround LoadPlayerImage fail"); + return ; + } + + if (LoadPlayerImage(elipse, PLAYER_ELLIPSE) == false) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "elipse LoadPlayerImage fail"); + return ; + } + + resLoadStatus = true; + } + } + + void PlayersView::playerResUnLoad(void) + { + if(resLoadStatus) + { + ImageInfo *image = nullptr; + soundButton->SetSrc(image); + //playerModelButton->SetSrc(image); + backGround->SetSrc(image); + elipse->SetSrc(image); + ImageCacheManager::GetInstance().UnloadOneInMultiRes(PLAYER_MUSIC_VOICE,PLAYER_IAMGES); + ImageCacheManager::GetInstance().UnloadOneInMultiRes(PLAYER_BACKGROUND,PLAYER_IAMGES); + ImageCacheManager::GetInstance().UnloadOneInMultiRes(PLAYER_ELLIPSE,PLAYER_IAMGES); + resLoadStatus = false; + } + } } diff --git a/code/sdk/application/wearable/fd230app/nativeui/set_card/src/SetMainView.cpp b/code/sdk/application/wearable/fd230app/nativeui/set_card/src/SetMainView.cpp index 3e5b12ef0..831835aad 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/set_card/src/SetMainView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/set_card/src/SetMainView.cpp @@ -84,6 +84,7 @@ namespace OHOS /* -------------------------------------------------------------------------- */ void SetMainView::PreLoad(void) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetMainView::PreLoad"); if (!viewiInitStatus) { InitView(); @@ -92,6 +93,7 @@ namespace OHOS } void SetMainView::UnLoad(void) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetMainView::UnLoad"); } /* -------------------------------------------------------------------------- */ } diff --git a/code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepCardView.cpp b/code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepCardView.cpp index 62bb9a11e..2164e2ec5 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepCardView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepCardView.cpp @@ -84,6 +84,7 @@ namespace OHOS void SleepCardView::UnLoad(void) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SleepCardView::UnLoad"); } } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/Training_CardView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/Training_CardView.cpp index 7a3bc15c8..8055e1b8f 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/Training_CardView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/Training_CardView.cpp @@ -247,6 +247,8 @@ namespace OHOS void Training_CardView::PreLoad(void) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Training_CardView::PreLoad"); + if (!viewiInitStatus) { // 加载组件 ,加载imagecache @@ -269,7 +271,7 @@ namespace OHOS void Training_CardView::UnLoad(void) { - + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Training_CardView::UnLoad"); if (resLoadStatus) { ImageInfo *img = nullptr;