From 52e317b95d830f8cd1156b403ff5a34fb8f9bccb Mon Sep 17 00:00:00 2001
From: 陈嘉乐 <cjl@hdlchina.com.cn>
Date: 星期五, 31 七月 2020 17:43:42 +0800
Subject: [PATCH] 2020-7-31-2

---
 HDL_ON/UI/UI2/FuntionControlView/Music/A31PlayMusicPage.cs |  295 +++++++---------------------------------------------------
 1 files changed, 38 insertions(+), 257 deletions(-)

diff --git a/HDL_ON/UI/UI2/FuntionControlView/Music/A31PlayMusicPage.cs b/HDL_ON/UI/UI2/FuntionControlView/Music/A31PlayMusicPage.cs
index fdf4b3b..f136cd6 100644
--- a/HDL_ON/UI/UI2/FuntionControlView/Music/A31PlayMusicPage.cs
+++ b/HDL_ON/UI/UI2/FuntionControlView/Music/A31PlayMusicPage.cs
@@ -8,9 +8,15 @@
 {
     public class A31PlayMusicPage : FrameLayout
     {
+        /// <summary>
+        /// 褰撳墠瀵硅薄鏋勯�犲嚱鏁�
+        /// </summary>
         public A31PlayMusicPage()
         {
         }
+        /// <summary>
+        /// 閲嶅啓RemoveFromParent鏂规硶
+        /// </summary>
         public override void RemoveFromParent()
         {
             base.RemoveFromParent();
@@ -28,6 +34,9 @@
             }
 
         }
+        /// <summary>
+        /// new甯冨眬鐣岄潰
+        /// </summary>
         View.PlayView playView = new View.PlayView();
       
         public void Show()
@@ -76,8 +85,8 @@
 
             };
             #endregion
-            //蹇繘婊戝姩浜嬩欢;
-            EventHandler<int> seekClick = (sender, e) =>
+            //蹇繘婊戝姩寮硅捣浜嬩欢;
+            playView.diyArcSeekBar.OnStopTrackingTouchEvent+= (sender, e) =>
             {
                 int totalSecond = (int)(playView.diyArcSeekBar.Progress * 1.0f / 100 * int.Parse(A31MusicModel.Current.A31PlayStatus.totlen) / 1000);
                 //鍒嗛挓
@@ -88,9 +97,6 @@
                 SendMethod.Seek(time, A31MusicModel.Current);
                 A31MusicModel.Current.A31PlayStatus.curpos = (DateTime.Parse(time) - DateTime.Parse("00:00:00")).TotalMilliseconds.ToString();
             };
-            //playView.diyArcSeekBar.OnProgressChangedEvent += seekClick;
-            playView.diyArcSeekBar.OnStopTrackingTouchEvent += seekClick;//蹇繘婊戝姩涓嶅彂鍛戒护锛�
-            
             ///鍒囨崲鎾斁妯″紡鐐瑰嚮浜嬩欢;
             playView.playOrderBtn.MouseUpEventHandler += (sender, e) =>
              {
@@ -178,115 +184,22 @@
             {
                 #region  甯冨眬鐣岄潰---
                 Loading loading = new Loading();
-                FrameLayout popFra = new FrameLayout()
+                UI2.FuntionControlView.Music.View.MyListView myListView = new UI2.FuntionControlView.Music.View.MyListView();
+                myListView.frameLayout(this, A31MusicModel.Current);
+                myListView.dialogFra.AddChidren(loading);//dialogFra鍒锋柊鍥炬爣鐖舵帶浠�
+                ///涓嬫媺鍒锋柊
+                myListView.verticalScrolViewLayout.BeginHeaderRefreshingAction += () =>
                 {
-                    BackgroundColor = Color.PopupBackgroundColor,
+                    //缁撴潫鍒锋柊
+                    myListView.verticalScrolViewLayout.EndHeaderRefreshing();
                 };
-                this.AddChidren(popFra);
-
-                FrameLayout dialogFra = new FrameLayout()
-                {
-                    X = Application.GetRealWidth(16),
-                    Y = Application.GetRealHeight(187),
-                    Width = Application.GetRealWidth(344),
-                    Height = Application.GetRealHeight(460),
-                    BackgroundColor = Color.WhiteColor,
-                    Radius = (uint)Application.GetRealHeight(12),
-                };
-                popFra.AddChidren(dialogFra);
-                dialogFra.AddChidren(loading);//dialogFra鍒锋柊鍥炬爣鐖舵帶浠�
-
-                FrameLayout topFra = new FrameLayout()
-                {
-                    Width = Application.GetRealWidth(344),
-                    Height = Application.GetRealHeight(50),
-                };
-                dialogFra.AddChidren(topFra);
-                Button orderIconBtn = new Button
-                {
-                    X = Application.GetRealWidth(16),
-                    Y = Application.GetRealHeight(11),
-                    Width = Application.GetMinRealAverage(28),
-                    Height = Application.GetMinRealAverage(28),
-                };
-                topFra.AddChidren(orderIconBtn);
-                Button orderTxetBtn = new Button
-                {
-                    X = Application.GetRealWidth(60),
-                    Y = Application.GetRealHeight(14),
-                    Width = Application.GetRealWidth(120),
-                    Height = Application.GetRealHeight(22),
-                    TextColor = Color.TextColor,
-                    TextSize = TextSize.Text16,
-                    TextAlignment = TextAlignment.CenterLeft,
-                };
-                topFra.AddChidren(orderTxetBtn);
-                switch (A31MusicModel.Current.A31PlayStatus.loop)
-                {
-                    //0鍒楄〃寰幆锛�1鍗曟洸寰幆锛�2闅忔満鎾斁;
-                    case "0":
-                        orderIconBtn.UnSelectedImagePath = "MusicIcon/list.png";
-                        orderTxetBtn.Text = Language.StringByID(StringId.listMode);
-                        break;
-
-                    case "1":
-                        orderIconBtn.UnSelectedImagePath = "MusicIcon/single.png";
-                        orderTxetBtn.Text = Language.StringByID(StringId.singleMode);
-
-                        break;
-                    case "2":
-                        orderIconBtn.UnSelectedImagePath = "MusicIcon/random.png";
-                        orderTxetBtn.Text = Language.StringByID(StringId.randomMode);
-                        break;
-                }
-                Button backIextBtn = new Button
-                {
-                    X = Application.GetRealWidth(288),//300
-                    Y = Application.GetRealHeight(15),
-                    Width = Application.GetRealWidth(28 + 12),//28
-                    Height = Application.GetRealHeight(20),
-                    TextID = StringId.cancelMusic,
-                    TextColor = Color.MusicNoTxetColor,
-                    TextSize = TextSize.Text14,
-                    TextAlignment = TextAlignment.CenterLeft,
-                };
-                topFra.AddChidren(backIextBtn);
-                Button lineBtn = new Button
-                {
-                    Y = topFra.Height - 1,
-                    Width = Application.GetRealWidth(344),
-                    Height = H_W.Line,
-                    BackgroundColor = Color.LineColor,
-                };
-                topFra.AddChidren(lineBtn);
-                VerticalScrolViewLayout verticalScrolViewLayout = new VerticalScrolViewLayout
-                {
-                    Y = Application.GetRealHeight(50),
-                    Height = Application.GetRealHeight(410),
-                    Width = Application.GetRealWidth(344),
-                };
-                dialogFra.AddChidren(verticalScrolViewLayout);
                 ///绉婚櫎鐣岄潰
                 EventHandler<MouseEventArgs> removeFromParentView = (sen, e1) =>
                  {
-                   
-                     if (updateSelectedMusicThread != null)
-                     {
-                         try
-                         {
-                             if (updateSelectedMusicThread.IsAlive)
-                             {
-                                 updateSelectedMusicThread.Abort();
-                                 ///鍏抽棴绾跨▼
-                             }
-                         }
-                         catch { }
-                     }
-
-                     popFra.RemoveFromParent();
+                     myListView.popFra.RemoveFromParent();
                  };
-                backIextBtn.MouseUpEventHandler += removeFromParentView;
-                popFra.MouseUpEventHandler += removeFromParentView;
+                myListView.backIextBtn.MouseUpEventHandler += removeFromParentView;
+                myListView.popFra.MouseUpEventHandler += removeFromParentView;
                 #endregion
                 loading.Start();
                 System.Threading.Tasks.Task.Run(() =>
@@ -350,8 +263,8 @@
                         Application.RunOnMainThread(() =>
                         {
                             loading.Hide();
-                            PlayListView(popFra, verticalScrolViewLayout, playListName);
-                            UpdateSelectedMusic(verticalScrolViewLayout);
+                            PlayListView(myListView.popFra, myListView.verticalScrolViewLayout, playListName);
+                            UpdateSelectedMusic(myListView.popFra, myListView.verticalScrolViewLayout);
                         });
                     }
                 });
@@ -363,7 +276,6 @@
                 if (A31MusicModel.Current.ServerClientType == 1 && A31MusicModel.Current.Slave.slave_list.Count != 0)
                 { ///涓绘挱鏀惧櫒
                    //new View.DialogView { }.PlayerVolumeView(A31MusicModel.Current);
-
                     var volumeView = new View.DialogView { };
                     volumeView.PlayerVolumeView(A31MusicModel.Current);
                     volumeView.UpdateVolume();
@@ -440,7 +352,9 @@
             };
 
         }
-      
+        /// <summary>
+        /// 瀹氫箟鍏ㄥ眬绾跨▼
+        /// </summary>
         System.Threading.Thread timerThread;
         /// <summary>
         /// 瀹氭椂鏇存柊鐘舵��
@@ -744,7 +658,7 @@
         /// 鏄剧ず褰撳墠鎾斁闊充箰View
         /// </summary>
         /// <param name="verticalScrolViewLayout"></param>
-        void PlayListView(FrameLayout frameLayout, VerticalScrolViewLayout verticalScrolViewLayout, string playListName)
+        void PlayListView(FrameLayout frameLayout, VerticalRefreshLayout verticalScrolViewLayout, string playListName)
         {
             verticalScrolViewLayout.RemoveAll();
             int number = 0;
@@ -752,106 +666,15 @@
             {
                 number++;
                 var songs = A31MusicModel.Current.CurrentPlayMusicInfoList[i];
-                if (string.IsNullOrEmpty(songs.Title))
-                {
-                    //闃叉姝屾洸鍚嶅瓧涓虹┖鎶涘紓甯�
-                    songs.Title = " ";
-                }
-                if (string.IsNullOrEmpty(songs.Artist))
-                {
-                    //闃叉姝屾墜鍚嶅瓧涓虹┖鎶涘紓甯�
-                    songs.Artist = " ";
-                }
-                FrameLayout musicViewFl = new FrameLayout
-                {
-                    Width = Application.GetRealWidth(375),
-                    Height = Application.GetRealHeight(44),
-                };
-                verticalScrolViewLayout.AddChidren(musicViewFl);
-                //鍒楄〃褰撳墠鎾斁闊充箰鍥炬爣
-                Button playIconBtn = new Button
-                {
-                    X = Application.GetRealWidth(16),
-                    Y = Application.GetRealHeight(10),
-                    Width = Application.GetMinRealAverage(24),
-                    Height = Application.GetMinRealAverage(24),
-                    UnSelectedImagePath = "MusicIcon/playStatus.png",
-                    Visible = false,
-                    Name = "playStatus",
-                    Tag = songs.URL,
-                };
-                musicViewFl.AddChidren(playIconBtn);
-                //姝屾洸鎺т欢
-                Button songBtn = new Button
-                {
-                    X = Application.GetRealWidth(16),
-                    Y = Application.GetRealHeight(11),
-                    Width = Application.GetRealWidth(100),
-                    Height = Application.GetRealHeight(22),
-                    TextColor = Color.MusicTxet14Color,
-                    TextSize = TextSize.Text16,
-                    TextAlignment = TextAlignment.CenterLeft,
-                    Name = "song",
-                    Tag = songs.URL,
-                    Text = songs.Title.Trim()
-                };
-                musicViewFl.AddChidren(songBtn);
-                var wText = songBtn.GetTextWidth();//鑾峰彇鏂囨湰瀹藉害
-                ///(姝屾洸+姝屾墜)瀹藉害鏈�澶у�兼椂280
-                if (wText > 280)
-                {
-
-                    songBtn.Width = Application.GetRealWidth(280);
-                }
-                else
-                {
-                    songBtn.Width = wText + 5;
-                }
-                //姝屾墜鎺т欢
-                Button singerBtn = new Button
-                {
-                    X = songBtn.Right,
-                    Y = Application.GetRealHeight(11),
-                    Width = Application.GetRealWidth(280 - songBtn.Width),
-                    Height = Application.GetRealHeight(22),
-                    TextColor = Color.MusicNoTxetColor,
-                    TextSize = TextSize.Text12,
-                    TextAlignment = TextAlignment.CenterLeft,
-                    //Text =("-" +songs.Artist).Trim(),
-                    Name = "singer",
-                    Tag = songs.URL,
-                    Text = "-" + songs.Artist.Trim()
-                };
-                musicViewFl.AddChidren(singerBtn);
-                if (wText > 280)
-                {
-                    ///姝屽悕闀垮害灏忎簬250鎵嶅彲浠ユ樉绀烘瓕鎵嬪嚭鏉�
-                    singerBtn.Width = Application.GetRealWidth(0);
-                }
-
-                //鐐瑰嚮鎺т欢
-                Button clickBtn = new Button
-                {
-                    Width = Application.GetRealWidth(280),
-                    Height = Application.GetRealHeight(44),
-                    Tag = number,//鏍囪鎾斁鍝竴棣栨瓕鏇�
-                };
-                musicViewFl.AddChidren(clickBtn);
+                View.SongView songView = new View.SongView();
+                songView.SongFrameLayout(verticalScrolViewLayout, songs);
+                songView.loveIcon.Visible = false;
+                songView.addIcon.Visible = false;
+                songView.clickBtn.Width = Application.GetRealWidth(344);
+                songView.clickBtn.Tag = number;//鏍囪鎾斁鍝竴棣栨瓕鏇�
                 ///鐐瑰嚮鎾斁浜嬩欢
-                clickBtn.MouseUpEventHandler += (sender, e) =>
+                songView.clickBtn.MouseUpEventHandler += (sender, e) =>
                 {
-                    if (updateSelectedMusicThread != null)
-                    {
-                        try
-                        {
-                            if (updateSelectedMusicThread.IsAlive)
-                            {
-                                updateSelectedMusicThread.Abort();
-                                ///鍏抽棴绾跨▼
-                            }
-                        }
-                        catch { }
-                    }
                     System.Threading.Tasks.Task.Run(() =>
                     {
                         System.Threading.Thread.Sleep(50);
@@ -859,10 +682,10 @@
                         {
                             //绉婚櫎鐣岄潰
                             frameLayout.RemoveFromParent();
-                            A31MusicModel.Current.A31PlayStatus.Title = songBtn.Text;
+                            A31MusicModel.Current.A31PlayStatus.Title = songView.songBtn.Text;
                             System.Threading.Tasks.Task.Run(() =>
                             {
-                                SendMethod.ListMusicPlay(playListName, clickBtn.Tag, A31MusicModel.Current);
+                                SendMethod.ListMusicPlay(playListName, songView.clickBtn.Tag, A31MusicModel.Current);
                             });
                         });
                     });
@@ -874,51 +697,9 @@
         /// <summary>
         /// 瀹氭椂鏇存柊褰撳墠鎾斁闊充箰
         /// </summary>
-        System.Threading.Thread updateSelectedMusicThread;
-        void UpdateSelectedMusic(VerticalScrolViewLayout middViewLayout)
+        void UpdateSelectedMusic(FrameLayout frameLayout, VerticalRefreshLayout middViewLayout)
         {
-            updateSelectedMusicThread = new System.Threading.Thread(() =>
-            {
-                while (this.Parent != null)
-                {
-                    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 { }
-
-                    });
-                }
-            })
-            { IsBackground = true };
-            updateSelectedMusicThread.Start();
+            UI2.FuntionControlView.Music.UpdateThread.updateThread(frameLayout, middViewLayout, A31MusicModel.Current);
         }
     }
 }

--
Gitblit v1.8.0