using System;
|
using System.Collections.Generic;
|
using HDL_ON.UI.UI2.FuntionControlView.Music;
|
using Shared;
|
namespace HDL_ON.UI.Music
|
{
|
public class A31FlieList : FrameLayout
|
{
|
|
public A31FlieList(string source,string title)
|
{
|
Tag = "Music";
|
this.source = source;
|
this.title = title;
|
}
|
/// <summary>
|
/// 音乐源
|
/// </summary>
|
private string source = string.Empty;
|
/// <summary>
|
/// 标题
|
/// </summary>
|
private string title = string.Empty;
|
|
VerticalRefreshLayout middViewLayout;
|
public void Show()
|
{
|
#region 界面布局------
|
|
this.BackgroundColor = MusicColor.ViewColor;
|
var topView = new TopView();
|
this.AddChidren(topView.TopFLayoutView());
|
topView.topNameBtn.Text=this.title;
|
topView.clickBackBtn.MouseUpEventHandler += (sender, e) =>
|
{
|
this.RemoveFromParent();
|
};
|
middViewLayout = new VerticalRefreshLayout
|
{
|
BackgroundColor = MusicColor.WhiteColor,
|
Y = topView.fLayout.Bottom,
|
Height = Application.GetRealHeight(H_W.H - H_W.T_Height),
|
};
|
this.AddChidren(middViewLayout);
|
#endregion
|
|
middViewLayout.BeginHeaderRefreshingAction += () =>
|
{
|
System.Threading.Tasks.Task.Run(() =>
|
{
|
try
|
{
|
var Group = SendMethod.Current.GetSingleSourceListNameList(A31MusicModel.Current.functionMusic, this.source);
|
CommonMethod.Current.AddSourceGroupListMemory(Group);//保存缓存
|
}
|
catch { }
|
finally
|
{
|
Application.RunOnMainThread(() =>
|
{
|
var listNameList = CommonMethod.Current.GetListNameListMemory(this.source);
|
this.FileListView(listNameList);
|
middViewLayout.EndHeaderRefreshing();
|
});
|
}
|
});
|
|
};
|
|
}
|
/// <summary>
|
/// 加载列表
|
/// </summary>
|
/// <param name="listNames">列表名列表</param>
|
public void FileListView(List<ListName> listNames)
|
{
|
middViewLayout.RemoveAll();
|
for (int i = 0; i < listNames.Count; i++)
|
{
|
var listName= listNames[i];
|
RowLayout addFlieRow = new RowLayout
|
{
|
Height = Application.GetRealHeight(104),
|
LineColor = MusicColor.WhiteColor,
|
SubViewWidth = Application.GetRealWidth(90),//改变编辑控件宽度多少;
|
};
|
middViewLayout.AddChidren(addFlieRow);
|
//文件图标
|
Button fileIconBtn = new Button
|
{
|
X = Application.GetRealWidth(16),
|
Y = Application.GetRealHeight(8),
|
Width = Application.GetRealWidth(88),
|
Height = Application.GetRealWidth(88),
|
UnSelectedImagePath = "MusicIcon/fileList.png",
|
};
|
addFlieRow.AddChidren(fileIconBtn);
|
|
//文件名控件
|
Button fileNameBtn = new Button
|
{
|
X = fileIconBtn.Right + Application.GetRealWidth(16),
|
Y = Application.GetRealHeight(42),
|
Width = Application.GetRealWidth(217),
|
Height = Application.GetRealHeight(20),
|
TextColor = MusicColor.TextColor,
|
TextSize = TextSize.Text14,
|
TextAlignment = TextAlignment.CenterLeft,
|
Text = listName.group,
|
};
|
addFlieRow.AddChidren(fileNameBtn);
|
|
Button clickBtn = new Button
|
{
|
X = fileIconBtn.Right + Application.GetRealWidth(16),
|
Width = Application.GetRealWidth(375 - 138),
|
Height = Application.GetRealHeight(104),
|
Tag=listName.group
|
};
|
addFlieRow.AddChidren(clickBtn);
|
clickBtn.MouseUpEventHandler += (sender, e) =>
|
{
|
string groupName = clickBtn.Tag.ToString();
|
Loading loading = new Loading();
|
this.AddChidren(loading);
|
loading.Start();
|
//向缓存拿列表
|
var songListMemory = CommonMethod.Current.GetSongListMemory(groupName,this.source);
|
System.Threading.Tasks.Task.Run(() =>
|
{
|
try
|
{
|
//缓存没有列表才去读取
|
if (songListMemory.songs.Count == 0)
|
{
|
//读取歌曲列表
|
var songList = SendMethod.Current.GetSingleSongList(A31MusicModel.Current.functionMusic, groupName, this.source);
|
CommonMethod.Current.AddSongListMemory(songList,this.source);//保存缓存
|
songListMemory.songs.AddRange(songList.songs);//更新列表
|
}
|
}
|
catch
|
{
|
}
|
finally
|
{
|
Application.RunOnMainThread(() =>
|
{
|
loading.Hide();
|
A31SongPlay a31Song = new A31SongPlay();
|
MainPage.BasePageView.AddChidren(a31Song);
|
MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
|
a31Song.Show(songListMemory);
|
});
|
}
|
});
|
|
};
|
|
|
|
}
|
}
|
|
|
|
|
}
|
}
|