From b99a1c6f856e9e2ee718805050e13b406289a709 Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Thu, 5 Dec 2024 21:19:46 +0800 Subject: [PATCH] =?utf8?q?=E8=A7=A3=E5=86=B3=E9=9F=B3=E4=B9=90=E6=92=AD?= =?utf8?q?=E6=94=BE=E5=99=A8=E4=B8=AD=E9=9F=B3=E4=B9=90=E5=88=97=E8=A1=A8?= =?utf8?q?=E6=92=AD=E6=94=BE=E7=8A=B6=E6=80=81UI=E6=98=BE=E7=A4=BA?= =?utf8?q?=E9=97=AE=E9=A2=98=EF=BC=9A=E5=A6=82=EF=BC=8C=E7=B4=A2=E5=BC=950?= =?utf8?q?=E7=9A=84=E6=AD=8C=E6=9B=B2=E8=8B=A5=E5=9C=A8=E6=92=AD=E6=94=BE?= =?utf8?q?=E4=B8=AD=EF=BC=8C=E5=9C=A8=E5=88=A0=E9=99=A4=E5=85=B6=E4=BB=96?= =?utf8?q?=E9=9F=B3=E4=B9=90=E5=90=8E=EF=BC=8C=E5=BD=93=E5=89=8D=E9=9F=B3?= =?utf8?q?=E4=B9=90=E6=92=AD=E6=94=BE=E7=8A=B6=E6=80=81=E4=BC=9A=E5=8F=98?= =?utf8?q?=E6=88=90=E6=9C=AA=E6=92=AD=E6=94=BE=E7=8A=B6=E6=80=81=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../player/include/PlayerListDelSongView.h | 5 +++-- .../nativeui/player/include/PlayersView.h | 3 ++- .../player/src/PlayerListDelSongView.cpp | 18 ++++++++++++++++-- .../player/src/PlayersCaseListAdapter.cpp | 3 ++- .../nativeui/player/src/PlayersModel.cpp | 10 ---------- .../nativeui/player/src/PlayersPresenter.cpp | 2 +- .../nativeui/player/src/PlayersView.cpp | 9 +++++++++ 7 files changed, 33 insertions(+), 17 deletions(-) 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 e01aa52f5..9e8c3c976 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/player/include/PlayerListDelSongView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/player/include/PlayerListDelSongView.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-08-05 15:20:03 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-08-12 18:24:31 + * @LastEditTime: 2024-12-05 21:03:56 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/player/include/PlayerListDelSongView.h */ @@ -44,7 +44,7 @@ namespace OHOS virtual ~PlayerListDelSongView(); static PlayerListDelSongView *GetInstance(void); UIViewGroup *CreatePlayerListDelSongView(); - void SetTheDelSongLabelStyle(const char *songName); + void SetTheDelSongLabelStyle(const char *songName,int index); void DeleteSongNameFile(void); UIButton *GetEnsureDeleteButton(void); UIButton *GetCancelDeleteButton(void); @@ -65,6 +65,7 @@ namespace OHOS UIButton *cancelDeleteButton{nullptr}; std::string delSongName; + int deleteSongIndex{0}; UIView::OnDragListener *dragListener{nullptr}; UIView::OnClickListener *buttonClickListener{nullptr}; 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 3d2eba03f..febe0e36e 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/player/include/PlayersView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/player/include/PlayersView.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-08-05 15:20:03 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-10-19 14:38:21 + * @LastEditTime: 2024-12-05 20:38:46 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/player/include/PlayersView.h */ @@ -98,6 +98,7 @@ namespace OHOS PlayersCaseListAdapter *GetMusicListAdapter(void); UIList *GetMusicListList(void); + void RefreshMusicListList(void); UICircleProgress *GetPlaybackProgress(void); UICheckBox::UICheckBoxState GetPlayerButtonState(void); 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 26e96a37a..37508333a 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayerListDelSongView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayerListDelSongView.cpp @@ -85,9 +85,10 @@ namespace OHOS /// @brief 设置歌曲名标签样式 /// @param songName 歌曲名 - void PlayerListDelSongView::SetTheDelSongLabelStyle(const char *songName) + void PlayerListDelSongView::SetTheDelSongLabelStyle(const char *songName,int index) { delSongName = songName; + deleteSongIndex = index; if (songNameLabel != nullptr) { songNameLabel->SetText(PlayersModel::GetInstance()->getHexMusicNameFromMusicName(songName).c_str()); @@ -103,7 +104,20 @@ namespace OHOS if (uapi_delete_files(path.c_str())) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Deleted file: %s successed!", path.c_str()); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Deleted file: %s successed!", path.c_str()); + int index = PlayersModel::GetInstance()->GetCurrentIndex(); + if(deleteSongIndex < index) + { + if(index - 1 < 0) + { + index = 0; + } + else + { + index--; + } + PlayersModel::GetInstance()->SetCurrentIndex(index); + } } else { diff --git a/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersCaseListAdapter.cpp b/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersCaseListAdapter.cpp index 3dfd4f59c..9fc2d1280 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersCaseListAdapter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersCaseListAdapter.cpp @@ -56,7 +56,7 @@ namespace OHOS playersView->ChangeView(PlayersView::MUSIC_LIST_VIEW, PlayersView::MUSIC_DELETE_VIEW); if (playersView->GetPlayerListDelSongView()) { - playersView->GetPlayerListDelSongView()->SetTheDelSongLabelStyle(musicPlayName); + playersView->GetPlayerListDelSongView()->SetTheDelSongLabelStyle(musicPlayName, view.GetViewIndex()); } return true; } @@ -105,6 +105,7 @@ namespace OHOS } PlayersModel::GetInstance()->PlayerStat(); } + playersView->RefreshMusicListList();//刷新音乐列表 WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "index = %d ,uri = %s.", PlayersModel::GetInstance()->GetCurrentIndex(), PlayersModel::GetInstance()->GetPlayerUri().c_str()); return true; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersModel.cpp index 041edf4f8..1cde3a627 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersModel.cpp @@ -181,16 +181,6 @@ void PlayersModel::SetCurrentIndex(int16_t value) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PlayersModel::SetCurrentIndex,value = %d",value); currentIndex = value; - /* --------------------------------- 刷新音乐列表 --------------------------------- */ - PlayersView *playersView = PlayersView::GetInstance(); - if (playersView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "playersView null!"); - return; - } - if(playersView->GetMusicListList()!=nullptr){ - playersView->GetMusicListList()->RefreshList(); - } - /* -------------------------------------------------------------------------- */ } int16_t PlayersModel::GetPlayerModel(void) 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 2450e8042..987d0062d 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersPresenter.cpp @@ -460,7 +460,7 @@ void PlayersListGroup::SetUpListCase() WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "musicName = %s,index = %d",playerCaseInfo.sliceId,playerCaseInfo.index); playersCaseList_->PushBack(playerCaseInfo); } - PlayersModel::GetInstance()->showIdToMusicNameMapData(); + // PlayersModel::GetInstance()->showIdToMusicNameMapData();//关闭打印 } List& PlayersListGroup::GetCase() 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 3503e3393..8f2a9a7e4 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersView.cpp @@ -127,6 +127,15 @@ namespace OHOS return musicList; } + /*刷新音乐列表*/ + void PlayersView::RefreshMusicListList(void) + { + if(musicList) + { + musicList->RefreshList(); + } + } + /*获取音乐列表的适配器*/ PlayersCaseListAdapter *PlayersView::GetMusicListAdapter(void) { -- 2.17.1