JLChen
2020-06-04 6d55af8792cf8fbef0055e677b900fc352dba9a2
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
using System;
using System.Collections.Generic;
using System.Text;
using Shared;
using Shared.SimpleControl.Phone;
using Shared.SimpleControl;
using Shared.SimpleControl.R;
using Newtonsoft.Json.Linq;
namespace Shared.SimpleControl.Phone
{
    public class SonosMyList:FrameLayout
    {
        public void Show (SonosMusic sonosMusic)
        {
            AddChidren (new Button {
                Height = Application.GetRealHeight (36),
                BackgroundColor = SkinStyle.Current.MusicTopFrameLayout,
            });
 
            var topFrameLayout = new FrameLayout {
                Height = Application.GetRealHeight (90),
                Y = Application.GetRealHeight (36),
                BackgroundColor = SkinStyle.Current.MusicTopFrameLayout,
            };
            AddChidren (topFrameLayout);
 
 
            var back = new Button {
                Width = Application.GetRealWidth (82),
                Height = Application.GetRealHeight (89),
                X = Application.GetRealWidth (10),
                Gravity = Gravity.CenterVertical,
                UnSelectedImagePath = "MusicIcon/HomepageBack.png",
            };
            topFrameLayout.AddChidren (back);
            back.MouseDownEventHandler += (sender, e) => {
                this.RemoveFromParent ();
            };
 
            var musiclist = new Button {
                Width = Application.GetRealWidth (200),
                Height = Application.GetRealHeight (150),
                TextID = MyInternationalizationString.MusicMylist,
                TextSize = 15,
                X = Application.GetRealWidth (200),
                Gravity = Gravity.CenterVertical,
            };
            topFrameLayout.AddChidren (musiclist);
 
            var verticalScrolViewLayout = new VerticalScrolViewLayout {
                Height = Application.GetRealHeight (Application.DesignHeight - 126),
                Y = topFrameLayout.Bottom,
                BackgroundColor = 0xff2F2F2F,
            };
            this.AddChidren (verticalScrolViewLayout);
 
 
            MainPage.Loading.Start ();
            sonosMusic.SonosMyList.Clear ();
            System.Threading.Tasks.Task.Run (() => {
                try {
 
                    var tempsonosList = SuperGateWay.Control.getsonosMyList ();
                    if (tempsonosList == null) {
                        return;
                    }
                    foreach (var str in tempsonosList) {
                        try {
                            var result = SuperGateWay.Control.getsonosMySongs (str.Replace (".json", ""));
                            if (result != null) {
                                var songlist = Newtonsoft.Json.JsonConvert.DeserializeObject<listifon> (result);
                                if (songlist != null&&songlist.songitems.Count!=0) {
                                    sonosMusic.SonosMyList.Add (songlist);
                                }
 
                            }
                        } catch { }
                    }
 
                } catch { } finally {
                    Application.RunOnMainThread (() => {
                        MainPage.Loading.Hide ();
 
                        for (int i = 0; i < sonosMusic.SonosMyList.Count; i++) {
                            var rowlist = new RowLayout {
                                Height = Application.GetRealHeight (100),
                            };
                            verticalScrolViewLayout.AddChidren (rowlist);
 
                            var listname = new Button {
                                Height = Application.GetRealHeight (100),
                                TextAlignment = TextAlignment.CenterLeft,
                                X = Application.GetRealWidth (30),
                                Gravity = Gravity.CenterVertical,
                                TextColor = SkinStyle.Current.MusicTextColor,
                                Text = sonosMusic.SonosMyList [i].listname,
                                Tag = sonosMusic.SonosMyList [i],
                            };
                            rowlist.AddChidren (listname);
 
                            var listback = new Button {
                                Width = Application.GetRealWidth (87),
                                Height = Application.GetRealHeight (100),
                                UnSelectedImagePath = "MusicIcon/Next.png",
                                SelectedImagePath = "MusicIcon/NextSelecte.png",
                                X = Application.GetRealWidth (550),
                                Gravity = Gravity.CenterVertical,
                            };
                            rowlist.AddChidren (listback);
 
                            EventHandler<MouseEventArgs> clickList = (sender, e) => {
                                MainPage.Loading.Start (Language.StringByID (MyInternationalizationString.load));
                                System.Threading.Tasks.Task.Run (() => {
                                    Application.RunOnMainThread (() => {
                                        MainPage.Loading.Hide ();
                                        var sonosMyListMusic = new SonosMyListMusic ();
                                        MainPage.MainFrameLayout.AddChidren (sonosMyListMusic);
                                        sonosMyListMusic.Show (sonosMusic,listname.Tag as listifon,listname.Text );
                                    });
                                });
 
                            };
                            rowlist.MouseUpEventHandler += clickList;
                            listname.MouseUpEventHandler += clickList;
                            listback.MouseUpEventHandler += clickList;
 
                        }
                    });
                }
            });
 
 
 
        }
    }
}