wjc
2023-02-03 c484347d42f8c14f03f498e689069a14a45abc93
HDL_ON/UI/UI2/FuntionControlView/Music/A31SongPlay.cs
@@ -2,6 +2,7 @@
using Shared;
using HDL_ON.UI.Music;
using System.Collections.Generic;
using HDL_ON.UI.UI2.FuntionControlView.Music;
namespace HDL_ON.UI.Music
{
@@ -13,13 +14,14 @@
            Tag = "Music";
        }
        public void Show(List<Songs> musicList,string listName)
        public void Show(SongList songLists)
        {
            this.BackgroundColor = MusicColor.ViewColor;
            var topView = new TopView();
            this.AddChidren(topView.TopFLayoutView());
            topView.topNameBtn.TextID = StringId.localMusic;
            topView.topNameBtn.Text=songLists.group;
            topView.clickBackBtn.MouseUpEventHandler += (sender, e) =>
            {
                this.RemoveFromParent();
@@ -33,10 +35,33 @@
            this.AddChidren(vv);
            vv.BeginHeaderRefreshingAction += () =>
            {
                vv.EndHeaderRefreshing();
                System.Threading.Tasks.Task.Run(() =>
                {
                    try
                    {
                        //获取歌曲列表
                        var songList = SendMethod.Current.GetSingleSongList(A31MusicModel.Current.functionMusic, songLists.group, songLists.source);
                        CommonMethod.Current.AddSongListMemory(songList, songLists.source);//保存缓存
                    }
                    catch
                    {
                    }
                    finally
                    {
                        Application.RunOnMainThread(() =>
                        {
                            vv.EndHeaderRefreshing();
                            //从缓存拿列表
                            var songListMemory = CommonMethod.Current.GetSongListMemory(songLists.group, songLists.source);
                            ///加载音乐列表
                            SongListView(vv, songListMemory.songs, songListMemory.group, songLists.source);
                        });
                    }
                });
            };
            ///加载音乐列表
            SongListView(vv, musicList, listName);
            SongListView(vv, songLists.songs, songLists.group,songLists.source);
        }
@@ -46,8 +71,12 @@
        /// <param name="vv">父控件</param>
        /// <param name="musicList">音乐列表</param>
        /// <param name="listName">列表名</param>
        public static void SongListView(VerticalRefreshLayout vv,List<Songs> musicList,string listName, FrameLayout frame = null) {
        /// <param name="source">音乐源</param>
        public static void SongListView(VerticalRefreshLayout vv, List<SongInfo> musicList, string listName,string source, FrameLayout frame = null)
        {
            if (vv!=null) {
                vv.RemoveAll();
            }
            for (int i = 0; i < musicList.Count; i++)
            {
                var songs = musicList[i];
@@ -66,7 +95,7 @@
                        System.Threading.Thread.Sleep(50);
                        Application.RunOnMainThread(() =>
                        {
                            //移除界面
                            //修改缓存属性状态值
                            A31MusicModel.Current.functionMusic.SetAttrState("song_name", songView.songBtn.Text);
                            A31MusicModel.Current.functionMusic.SetAttrState("playlist_name", listName);
                            //移除界面
@@ -78,6 +107,14 @@
                            Dictionary<string, string> dic = new Dictionary<string, string>();
                            dic.Add("song_name", songView.songBtn.Text);
                            dic.Add("playlist_name", listName);
                            if (!string.IsNullOrEmpty(songs.url))
                            {
                                dic.Add("url", songs.url);
                            }
                            if (!string.IsNullOrEmpty(source))
                            {
                                dic.Add("source", source);
                            }
                            SendMethod.Current.SendControlCommand(A31MusicModel.Current.functionMusic, dic);
                        });
                    });
@@ -144,6 +181,6 @@
            });
            updateSelectedMusicThread.Start();
        }
    }
}