音乐界面优化:若当前在播放手机音乐这时点击音乐列表中音乐会提示弹窗而不是点击无反应 1473/2 1473/head 1475/target/1
authorluozheng <1732036298@qq.com>
Thu, 28 Nov 2024 06:49:13 +0000 (14:49 +0800)
committerluozheng <1732036298@qq.com>
Thu, 28 Nov 2024 06:49:13 +0000 (14:49 +0800)
code/sdk/application/wearable/fd230app/nativeui/player/include/PlayersModel.h
code/sdk/application/wearable/fd230app/nativeui/player/src/MusicPlayerTipView.cpp
code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersCaseListAdapter.cpp
code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersModel.cpp
code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersPresenter.cpp
code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersView.cpp

index 5565d96..3ece4e2 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: luozheng 1732036298@qq.com
  * @Date: 2024-08-05 15:20:03
  * @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-10-21 18:17:23
+ * @LastEditTime: 2024-11-28 11:04:43
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/player/include/PlayersModel.h
  */
 
@@ -122,6 +122,8 @@ public:
     std::string getHexMusicNameFromMusicName(const std::string &musicName);
     int getIdToMusicNameMapNumber(void);
     void showIdToMusicNameMapData(void);
+    int getPreShowView(void);
+    void setPreShowView(int index);
     // /* -------------------------------------------------------------------------- */
 private:
     bool phonePlayButtonState{false};
@@ -130,6 +132,7 @@ private:
     int64_t playerMusicDuration_{0};
     int64_t playerProgressValue_{0};
     std::unordered_map<uint16_t, std::pair<std::string,std::string>> idToMusicNameMap;//<id,<16进制文件名,UTF-8文件名>>
+    int preshowView{0};
 private:
     PlayersCaseListAdapter *m_PlayersCaseListAdapter{nullptr};
     int64_t duration_{0};
index 4973b35..5c12853 100644 (file)
@@ -2,11 +2,12 @@
  * @Author: luozheng 1732036298@qq.com
  * @Date: 2024-10-19 11:27:19
  * @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-11-05 14:29:01
+ * @LastEditTime: 2024-11-28 11:22:01
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/player/src/MusicPlayerTipView.cpp
  */
 #include "player/include/MusicPlayerTipView.h"
 #include "player/include/PlayersPresenter.h"
+#include "player/include/PlayersModel.h"
 #include "wearable_log.h"
 #include "UiConfig.h"
 #include "ui_resource_string.h"
@@ -79,7 +80,7 @@ namespace OHOS
         std::string viewId = view.GetViewId();
         if (viewId == OKBUTTON)
         {
-            playersView->ChangeView(PlayersView::MUSIC_PLAYER_TIP_VIEW, PlayersView::MAIN_MUSICPLAYER_VIEW);
+            playersView->ChangeView(PlayersView::MUSIC_PLAYER_TIP_VIEW, PlayersModel::GetInstance()->getPreShowView());
         }
         return true;
     }
index 8d1c55e..3dfd4f5 100644 (file)
@@ -47,15 +47,6 @@ namespace OHOS
             WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "playersView null!");\r
             return false;\r
         }\r
-        /* -------------------------------------------------------------------------- */\r
-        if(PlayersModel::GetInstance()->GetMusicSource() == false) { //本地音乐\r
-            if (PlayersModel::GetInstance()->get_avrcp_ct_or_tg_is_connected() && \r
-                    PlayersModel::GetInstance()->get_a2dp_sink_playing_state()) //若ct或tg端是已连接状态且当前a2dp_sink是已播放状态\r
-            {\r
-                return false;\r
-            }\r
-        }\r
-        /* -------------------------------------------------------------------------- */\r
         BtnOnListData(view);\r
         /* --------------------------- 若点击的是View类型是Button --------------------------- */\r
         if (view.GetViewType() == UIViewType::UI_BUTTON)\r
@@ -69,6 +60,14 @@ namespace OHOS
             }\r
             return true;\r
         }\r
+        else if(PlayersModel::GetInstance()->GetMusicSource() == false) { //本地音乐\r
+            if (PlayersModel::GetInstance()->get_avrcp_ct_or_tg_is_connected() && \r
+                    PlayersModel::GetInstance()->get_a2dp_sink_playing_state()) //若ct或tg端是已连接状态且当前a2dp_sink是已播放状态\r
+            {\r
+                playersView->ChangeView(PlayersView::MUSIC_LIST_VIEW, PlayersView::MUSIC_PLAYER_TIP_VIEW);\r
+                return true;\r
+            }\r
+        }\r
         /* -------------------------------------------------------------------------- */\r
         // 标记当前播放歌曲index_\r
         PlayersModel::GetInstance()->SetCurrentIndex(index_);\r
index 4d76846..041edf4 100644 (file)
@@ -1153,6 +1153,14 @@ bool PlayersModel::GetCurrentMusicIsPlaying(void)
             WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "id = %d name.first = %s name.second = %s", entry.first,entry.second.first.c_str(),entry.second.second.c_str());
         }
     }
+    int PlayersModel::getPreShowView(void)
+    {
+        return preshowView;
+    }
+    void PlayersModel::setPreShowView(int index)
+    {
+        preshowView = index;  
+    }
 }
 
 #ifdef __cplusplus
index 2e4617c..2450e80 100644 (file)
@@ -1245,7 +1245,7 @@ void PlayerOnDragListener::OnDragChangMusicPlayerTipView(const DragEvent& event)
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "playersView GetInstance fail");\r
             return;\r
         }\r
-        playersView->ChangeView(PlayersView::MUSIC_PLAYER_TIP_VIEW, PlayersView::MAIN_MUSICPLAYER_VIEW);\r
+        playersView->ChangeView(PlayersView::MUSIC_PLAYER_TIP_VIEW, PlayersModel::GetInstance()->getPreShowView());\r
         X_DRAG_FLAG = true;\r
     }\r
 }\r
index 5524ade..1ed5587 100644 (file)
@@ -1367,7 +1367,7 @@ namespace OHOS
         {\r
             RootView::GetInstance()->Invalidate();\r
         }\r
-\r
+        PlayersModel::GetInstance()->setPreShowView(hideView);\r
         DestroyTempView(hideView);\r
     }\r
 \r