陈嘉乐
2020-05-25 258d1675d02d3610cb302514fb5c86ab68ee6571
HDL_ON/UI/Music/A31LoveMusicList.cs
@@ -17,14 +17,14 @@
        /// <summary>
        /// 先加载界面出来
        /// </summary>
        public void Show(string listName, List<MusicInfo>loveList)
        public void Show()
        {
            #region   界面布局------
            this.BackgroundColor = Color.ViewColor;
            var topView = new TopView();
            this.AddChidren(topView.TopFLayoutView());
            topView.topNameBtn.Text= listName;
            topView.topNameBtn.TextID = StringId.a31Music;
            topView.clickBackBtn.MouseUpEventHandler += (sender, e) =>
            {
@@ -46,17 +46,17 @@
                middViewLayout.EndHeaderRefreshing();
            };
            #endregion
            MusicView(listName, loveList);
            MusicView(Language.StringByID(StringId.a31Music));
        }
        /// <summary> 
        /// 加载数据的方法
        /// </summary>
        public void MusicView(string listName, List<MusicInfo> loveList)
        public void MusicView(string listName)
        {
            middViewLayout.RemoveAll();
            for (int i = 0; i < loveList.Count; i++)
            for (int i = 0; i < A31MusicModel.Current.LoveMusicInfoList.Count; i++)
            {
                var songs = loveList[i];
                var songs = A31MusicModel.Current.LoveMusicInfoList[i];
                if (string.IsNullOrEmpty(songs.Title))
                {
                    //防止歌曲名字为空抛异常
@@ -140,45 +140,20 @@
                    Y = Application.GetRealHeight(8),
                    Width = Application.GetMinRealAverage(28),
                    Height = Application.GetMinRealAverage(28),
                    UnSelectedImagePath = "MusicIcon/love.png",
                    SelectedImagePath = "MusicIcon/loveSelected.png",
                    UnSelectedImagePath = "MusicIcon/loveSelected.png",
                };
                musicViewFl.AddChidren(loveIcon);
                loveIcon.MouseUpEventHandler += (sender, e) =>
                {
                    loveIcon.IsSelected = !loveIcon.IsSelected;
                    if (loveIcon.IsSelected)
                    var music= A31MusicModel.Current.LoveMusicInfoList.Find((m) => m.URL == songs.URL);
                    if (music!= null)
                    {
                        ///查找音乐是否存在在列表
                        var music1 = A31MusicModel.Current.LoveMusicInfoList.Find((m) => m.URL == songs.URL);
                        if (music1 == null)
                        {
                            ///没有存在就添加
                            A31MusicModel.Current.LoveMusicInfoList.Add(songs);
                        }
                    }
                    else
                    {
                        ///查找音乐是否存在在列表
                        var music1 = A31MusicModel.Current.LoveMusicInfoList.Find((m) => m.URL == songs.URL);
                        if (music1 != null)
                        {
                            ///存在就删除
                            A31MusicModel.Current.LoveMusicInfoList.Remove(songs);
                        }
                        ///存在就删除
                        A31MusicModel.Current.LoveMusicInfoList.Remove(music);
                    }
                    A31MusicModel.Save();
                    musicViewFl.RemoveFromParent();
                };
                var music = A31MusicModel.Current.LoveMusicInfoList.Find((m) => m.URL == songs.URL);
                if (music != null)
                {
                    loveIcon.IsSelected = true;
                }
                else
                {
                    loveIcon.IsSelected = false;
                }
                //添加到我的列表
                Button addIcon = new Button
@@ -217,7 +192,7 @@
                            MainPage.BasePageView.RemoveViewByTag("Music");
                            System.Threading.Tasks.Task.Run(() =>
                            {
                                PushList(songs, listName, loveList);
                                PushList(songs, listName, A31MusicModel.Current.LoveMusicInfoList);
                            });
                        });
                    });