wjc
2023-02-03 c484347d42f8c14f03f498e689069a14a45abc93
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
using System;
using System.Collections.Generic;
using HDL_ON.UI.UI2.FuntionControlView.Music;
using Shared;
namespace HDL_ON.UI.Music
{
    public class A31FlieList : FrameLayout
    {
 
        public A31FlieList(string source,string title)
        {
            Tag = "Music";
            this.source = source;
            this.title = title;
        }
        /// <summary>
        /// 音乐源
        /// </summary>
        private string source = string.Empty;
        /// <summary>
        /// 标题
        /// </summary>
        private string title = string.Empty;
 
        VerticalRefreshLayout middViewLayout;
        public void Show()
        {
            #region   界面布局------
 
            this.BackgroundColor = MusicColor.ViewColor;
            var topView = new TopView();
            this.AddChidren(topView.TopFLayoutView());
            topView.topNameBtn.Text=this.title;
            topView.clickBackBtn.MouseUpEventHandler += (sender, e) =>
            {
                this.RemoveFromParent();
            };
            middViewLayout = new VerticalRefreshLayout
            {
                BackgroundColor = MusicColor.WhiteColor,
                Y = topView.fLayout.Bottom,
                Height = Application.GetRealHeight(H_W.H - H_W.T_Height),
            };
            this.AddChidren(middViewLayout);
            #endregion
 
            middViewLayout.BeginHeaderRefreshingAction += () =>
            {
                System.Threading.Tasks.Task.Run(() =>
                {
                    try
                    {
                        var Group = SendMethod.Current.GetSingleSourceListNameList(A31MusicModel.Current.functionMusic, this.source);
                        CommonMethod.Current.AddSourceGroupListMemory(Group);//保存缓存
                    }
                    catch { }
                    finally
                    {
                        Application.RunOnMainThread(() =>
                        {
                            var listNameList = CommonMethod.Current.GetListNameListMemory(this.source);
                            this.FileListView(listNameList);
                            middViewLayout.EndHeaderRefreshing();
                        });
                    }
                });
 
            };
 
        }
        /// <summary>
        /// 加载列表
        /// </summary>
        /// <param name="listNames">列表名列表</param>
        public void FileListView(List<ListName> listNames)
        {
            middViewLayout.RemoveAll();
            for (int i = 0; i < listNames.Count; i++)
            {
                var listName= listNames[i];
                 RowLayout addFlieRow = new RowLayout
                {
                    Height = Application.GetRealHeight(104),
                    LineColor = MusicColor.WhiteColor,
                    SubViewWidth = Application.GetRealWidth(90),//改变编辑控件宽度多少;
                };
                middViewLayout.AddChidren(addFlieRow);
                //文件图标
                Button fileIconBtn = new Button
                {
                    X = Application.GetRealWidth(16),
                    Y = Application.GetRealHeight(8),
                    Width = Application.GetRealWidth(88),
                    Height = Application.GetRealWidth(88),
                    UnSelectedImagePath = "MusicIcon/fileList.png",
                };
                addFlieRow.AddChidren(fileIconBtn);
 
                //文件名控件
                Button fileNameBtn = new Button
                {
                    X = fileIconBtn.Right + Application.GetRealWidth(16),
                    Y = Application.GetRealHeight(42),
                    Width = Application.GetRealWidth(217),
                    Height = Application.GetRealHeight(20),
                    TextColor = MusicColor.TextColor,
                    TextSize = TextSize.Text14,
                    TextAlignment = TextAlignment.CenterLeft,
                    Text = listName.group,
                };
                addFlieRow.AddChidren(fileNameBtn);
 
                Button clickBtn = new Button
                {
                    X = fileIconBtn.Right + Application.GetRealWidth(16),
                    Width = Application.GetRealWidth(375 - 138),
                    Height = Application.GetRealHeight(104),
                    Tag=listName.group
                };
                addFlieRow.AddChidren(clickBtn);
                clickBtn.MouseUpEventHandler += (sender, e) =>
                {
                    string groupName = clickBtn.Tag.ToString();
                    Loading loading = new Loading();
                    this.AddChidren(loading);
                    loading.Start();
                    //向缓存拿列表
                    var songListMemory = CommonMethod.Current.GetSongListMemory(groupName,this.source);  
                    System.Threading.Tasks.Task.Run(() =>
                    {
                        try
                        {
                            //缓存没有列表才去读取
                            if (songListMemory.songs.Count == 0)
                            {
                                //读取歌曲列表
                                var songList = SendMethod.Current.GetSingleSongList(A31MusicModel.Current.functionMusic, groupName, this.source);
                                CommonMethod.Current.AddSongListMemory(songList,this.source);//保存缓存
                                songListMemory.songs.AddRange(songList.songs);//更新列表
                            }
                        }
                        catch
                        {
                        }
                        finally
                        {
                            Application.RunOnMainThread(() =>
                            {
                                loading.Hide();
                                A31SongPlay a31Song = new A31SongPlay();
                                MainPage.BasePageView.AddChidren(a31Song);
                                MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
                                a31Song.Show(songListMemory);
                            });
                        }
                    });
 
                };
 
 
 
            }
        }
 
       
 
        
    }
}