陈嘉乐
2020-05-18 e29de9af8f507d288a61d9459fb3d1f72976876f
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
using System;
using Shared;
namespace HDL_ON.UI.Music
{
    public class CommonLogic
    {
        public CommonLogic()
        {
        }
 
        /// <summary>
        /// 更新当前播放音乐
        /// </summary>
        public static void UpdateSelectedMusic1(VerticalRefreshLayout middViewLayout, System.Threading.Thread updateSelectedMusicThread)
        {
            for (int i = 0; i < middViewLayout.ChildrenCount; i++)
            {
                FrameLayout view = (FrameLayout)middViewLayout.GetChildren(i);
                var volIconBtn = (Button)view.GetChildren(0);//直接FrameLayout父控件找到该控件Button
                var songNameBtn = (Button)view.GetChildren(1);//直接FrameLayout父控件找到该控件Button
                var artistNameBtn = (Button)view.GetChildren(2);//直接FrameLayout父控件找到该控件Button
                if (A31MusicModel.Current.A31PlayStatus.TrackURL == songNameBtn.Tag.ToString())
                {
                    volIconBtn.Visible = true;
                    songNameBtn.TextColor = Color.SelectedColor;
                    songNameBtn.X = Application.GetRealWidth(48);
                    artistNameBtn.X = songNameBtn.Right;
                    artistNameBtn.TextColor = Color.SelectedColor;
                }
                else
                {
                    volIconBtn.Visible = false;
                    songNameBtn.TextColor = Color.MusicTxet14Color;
                    songNameBtn.X = Application.GetRealWidth(16);
                    artistNameBtn.X = songNameBtn.Right;
                    artistNameBtn.TextColor = Color.MusicNoTxetColor;
                }
 
 
            }
            //    //Button volIconBtn = null;
            //    //Button songNameBtn = null;
            //    //Button artistNameBtn =null;
            //    //for (int j = 0; j < view.ChildrenCount; j++)
            //    //{
            //    //    Button button = (Button)view.GetChildren(j);
            //    //    if ("playStatus" == button.Name)
            //    //    {
            //    //        volIconBtn = button;
            //    //    }
            //    //    if ("song" == button.Name)
            //    //    {
            //    //        songNameBtn = button;
            //    //    }
            //    //    if ("singer" == button.Name)
            //    //    {
            //    //        artistNameBtn = button;
            //    //    }
            //    //}
            //    //if (A31MusicModel.Current.A31PlayStatus.TrackURL == songNameBtn.Tag.ToString())
            //    //{
            //    //    volIconBtn.Visible = true;
            //    //    songNameBtn.TextColor = Color.SelectedColor;
            //    //    songNameBtn.X = Application.GetRealWidth(48);
            //    //    artistNameBtn.X = songNameBtn.Right;
            //    //    artistNameBtn.TextColor = Color.SelectedColor;
            //    //}
            //    //else
            //    //{
            //    //    volIconBtn.Visible = false;
            //    //    songNameBtn.TextColor = Color.MusicTxet14Color;
            //    //    songNameBtn.X = Application.GetRealWidth(16);
            //    //    artistNameBtn.X = songNameBtn.Right;
            //    //    artistNameBtn.TextColor = Color.MusicNoTxetColor;
            //    //}
            //}
 
 
 
            updateSelectedMusicThread = new System.Threading.Thread(() =>
        {
            while (true)
            {
                Console.WriteLine("123456789");
                System.Threading.Thread.Sleep(1000);
                Application.RunOnMainThread(() =>
                {
                    try
                    {
                        for (int i = 0; i < middViewLayout.ChildrenCount; i++)
                        {
                            FrameLayout view = (FrameLayout)middViewLayout.GetChildren(i);
                            var volIconBtn = (Button)view.GetChildren(0);//直接FrameLayout父控件找到该控件Button
                                var songNameBtn = (Button)view.GetChildren(1);//直接FrameLayout父控件找到该控件Button
                                var artistNameBtn = (Button)view.GetChildren(2);//直接FrameLayout父控件找到该控件Button
                                if (A31MusicModel.Current.A31PlayStatus.TrackURL == songNameBtn.Tag.ToString())
                            {
                                volIconBtn.Visible = true;
                                songNameBtn.TextColor = Color.SelectedColor;
                                songNameBtn.X = Application.GetRealWidth(48);
                                artistNameBtn.X = songNameBtn.Right;
                                artistNameBtn.TextColor = Color.SelectedColor;
                            }
                            else
                            {
                                volIconBtn.Visible = false;
                                songNameBtn.TextColor = Color.MusicTxet14Color;
                                songNameBtn.X = Application.GetRealWidth(16);
                                artistNameBtn.X = songNameBtn.Right;
                                artistNameBtn.TextColor = Color.MusicNoTxetColor;
                            }
 
 
                        }
                    }
                    catch { }
 
                });
            }
        });
            updateSelectedMusicThread.Start();
        }
    }
}