using System; using Shared; namespace HDL_ON.UI.Music { public class CommonLogic { public CommonLogic() { } /// /// 更新当前播放音乐 /// 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(); } } }