From: 罗正yun <1732036298@qq.com> Date: Sat, 6 Jan 2024 08:17:52 +0000 (+0800) Subject: 设置选项按钮的图片样式,通过点击音乐来源中的三种模式来改变 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=04e72e7c2c895d31043b3d1b923db45595271943;p=mirrors%2FFD230.git 设置选项按钮的图片样式,通过点击音乐来源中的三种模式来改变 --- diff --git a/code/sdk/application/wearable/nativeapp/nativeui/player/include/PlayersPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/player/include/PlayersPresenter.h index c98141297..9a6b473f3 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/player/include/PlayersPresenter.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/player/include/PlayersPresenter.h @@ -239,6 +239,7 @@ public: void SetPhoneMusicConnectStatusSetText(const char *text); void SetPhoneMusicConnectStatusLabelIsVisible(bool status); void SetMusicListButtonIsVisible(bool status); + void SetOptionsButtonImageStyle(ImageInfo *image); void SetPlaybackProgress(int64_t value); void SetPlayerState(bool value); void PlayerbackReset(void); diff --git a/code/sdk/application/wearable/nativeapp/nativeui/player/include/PlayersView.h b/code/sdk/application/wearable/nativeapp/nativeui/player/include/PlayersView.h index 14583b141..27d3b877f 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/player/include/PlayersView.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/player/include/PlayersView.h @@ -27,6 +27,7 @@ #include "PlayersPresenter.h" #include "components/ui_scroll_view.h" #include "PlayerListDelSongView.h" +#include "common/image_cache_manager.h" namespace OHOS { #define PLAY_PROGRESS_MIN 0 #define PLAY_PROGRESS_MAX 100 @@ -53,6 +54,7 @@ public: void PhoneMusicConnectStatusLabelSetText(const char *text); void PhoneMusicConnectStatusLabelIsSetVisible(bool status); void MusicListButtonIsSetVisible(bool status); + void OptionsButtonSetImageStyle(ImageInfo *image); int16_t GetVolumeRank(void); void SetVolumeRank(int16_t value); void SetVolumeAddOne(void); diff --git a/code/sdk/application/wearable/nativeapp/nativeui/player/src/BluetoothView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/player/src/BluetoothView.cpp index abd642798..1d54461bc 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/player/src/BluetoothView.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/player/src/BluetoothView.cpp @@ -126,17 +126,22 @@ public: WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothOnClickListener OnClick"); BluetoothView *bluetoothView = BluetoothView::GetInstance(); PlayersPresenter *playersPresenter = PlayersPresenter::GetInstance(); + ImageInfo *image; if (bluetoothView == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bluetoothView is nullptr"); return false; } if (view_ == (UIView *)bluetoothView->GetWatchButton()) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "watchButton OnClick");//手表音乐 + image = ImageCacheManager::GetInstance().LoadOneInMultiRes(PLAYER_LOCAL_MUSIC_COLOR, PLAYER_IAMGES); + playersPresenter->SetOptionsButtonImageStyle(image); playersPresenter->SetPhoneMusicConnectStatusLabelIsVisible(false); playersPresenter->SetMusicListButtonIsVisible(true); playersPresenter->SetMusicSourceSetText("本地音乐"); } else if (view_ == (UIView *)bluetoothView->GetPhoneButton()) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "phoneButton OnClick");//手机音乐 + image = ImageCacheManager::GetInstance().LoadOneInMultiRes(PLAYER_PHONE_COLOR, PLAYER_IAMGES); + playersPresenter->SetOptionsButtonImageStyle(image); playersPresenter->SetPhoneMusicConnectStatusLabelIsVisible(true); playersPresenter->SetMusicListButtonIsVisible(false); /* -------------------------------------------------------------------------- */ @@ -158,6 +163,8 @@ public: playersPresenter->SetMusicSourceSetText("手机音乐");//还有小bug,切换到其他界面时标签内容为“手机音乐”,会被还原成本地音乐 } else if (view_ == (UIView *)bluetoothView->GetSettingButton()) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "settingButton OnClick"); + image = ImageCacheManager::GetInstance().LoadOneInMultiRes(PLAYER_EARPHONE_COLOR, PLAYER_IAMGES); + playersPresenter->SetOptionsButtonImageStyle(image); JumpView *jumpView = JumpView::GetInstance(); if (jumpView == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "jumpView GetInstance fail"); diff --git a/code/sdk/application/wearable/nativeapp/nativeui/player/src/PlayersPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/player/src/PlayersPresenter.cpp index 6940a6dbc..9f3c9c07e 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/player/src/PlayersPresenter.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/player/src/PlayersPresenter.cpp @@ -1422,6 +1422,22 @@ void PlayersPresenter::SetMusicListButtonIsVisible(bool status) playersView->MusicListButtonIsSetVisible(status); } +/// @brief 设置选项按钮的图片样式:点击该按钮后进入音乐来源视图,点击里面的按钮,改选项按钮会被替换相应图片 +/// @param image 图片信息 +void PlayersPresenter::SetOptionsButtonImageStyle(ImageInfo *image) +{ + PlayersView *playersView = PlayersView::GetInstance(); + if (playersView == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetOptionsButtonImageStyle playersView GetInstance fail"); + return; + } + if (playersView->GetOptionsButton() == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetOptionsButtonImageStyle optionsButton nullptr"); + return; + } + playersView->OptionsButtonSetImageStyle(image); +} + void PlayersPresenter::SetPlaybackProgress(int64_t value) { PlayersView *playersView = PlayersView::GetInstance(); diff --git a/code/sdk/application/wearable/nativeapp/nativeui/player/src/PlayersView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/player/src/PlayersView.cpp index 7f49600db..73d0eb79c 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/player/src/PlayersView.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/player/src/PlayersView.cpp @@ -781,6 +781,13 @@ void PlayersView::MusicListButtonIsSetVisible(bool status) music_list_button->SetVisible(status); } +/// @brief 设置选项按钮的图片样式:点击该按钮后进入音乐来源视图,点击里面的按钮,改选项按钮会被替换相应图片 +/// @param image 图片信息 +void PlayersView::OptionsButtonSetImageStyle(ImageInfo *image) +{ + optionsButton->SetImageSrc(image, image); + optionsButton->Invalidate(); +} //初始化音乐播放器主视图 bool PlayersView::InitView(void) {