using Shared;
|
using System.Collections.Generic;
|
using HDL_ON.UI.Music;
|
using HDL_ON.UI.UI2.FuntionControlView.Aks.CommonView;
|
using HDL_ON.UI.UI2.FuntionControlView.VideoDoorLock;
|
using HDL_ON.UI.UI2.FuntionControlView.Aks.Entity;
|
|
namespace HDL_ON.UI.UI2.FuntionControlView.Aks
|
{
|
/// <summary>
|
/// 收藏界面
|
/// </summary>
|
public class CollectPage : FrameLayout
|
{
|
public CollectPage(RemoteControlEntity remoteControlEntity)
|
{
|
this.remoteControl = remoteControlEntity;
|
//读缓存数据
|
var collectList = AksCommonMethod.Current.CollectList;
|
this.mMovieCollectList .AddRange(collectList);
|
}
|
/// <summary>
|
/// 影片收藏列表
|
/// </summary>
|
private List<MovieLibrary> mMovieCollectList =new List<MovieLibrary>();
|
/// <summary>
|
/// 当前的遥控器对象
|
/// </summary>
|
RemoteControlEntity remoteControl;
|
/// <summary>
|
/// 影片列表上下滑动容器
|
/// </summary>
|
VerticalRefreshLayout vv;
|
/// <summary>
|
/// 影片容器
|
/// </summary>
|
CornerFramLayout imageFLayout;
|
/// <summary>
|
/// 头部布局
|
/// </summary>
|
private TopView topView;
|
/// <summary>
|
/// 当前页数
|
/// </summary>
|
private int pageNo=1;
|
|
|
|
public void Show()
|
{
|
//初始化UI
|
this.InitUi();
|
this.InitMiddle();
|
//读取数据
|
ReadData();
|
|
}
|
|
/// <summary>
|
/// 初始化头部界面
|
/// </summary>
|
private void InitUi()
|
{
|
this.BackgroundColor = MusicColor.ViewColor;
|
this.topView = new TopView();
|
this.topView.setBtn.Visible = false;
|
//this.topView.topNameBtn.TextID = StringId.shanchushebei;
|
this.topView.topNameBtn.Text ="我的收藏";
|
this.AddChidren(topView.TopFLayoutView());
|
vv = new VerticalRefreshLayout
|
{
|
Y = topView.fLayout.Bottom,
|
Height = Application.GetRealHeight(H_W.H - H_W.T_Height),
|
BackgroundColor = MusicColor.WhiteColor,
|
};
|
this.AddChidren(vv);
|
//返回
|
this.topView.clickBackBtn.MouseUpEventHandler += (sender, e) =>
|
{
|
this.RemoveFromParent();
|
};
|
}
|
/// <summary>
|
/// 初始化中部界面
|
/// </summary>
|
private void InitMiddle()
|
{
|
if (vv == null)
|
{
|
return;
|
}
|
vv.RemoveAll();
|
int count = this.mMovieCollectList == null ? 0 : this.mMovieCollectList .Count;
|
imageFLayout = new CornerFramLayout(343, count * 168, 0);
|
vv.AddChidren(imageFLayout);
|
imageFLayout.X = Application.GetRealWidth(16);
|
imageFLayout.LoadImagePage(this.mMovieCollectList );
|
imageFLayout.AdjustRealHeight(16);
|
|
vv.BeginHeaderRefreshingAction += () =>
|
{
|
//关闭刷新View;
|
vv.EndHeaderRefreshing();
|
//强制更新
|
mMovieCollectList .Clear();
|
ReadData();
|
};
|
imageFLayout.selectImageAction += (movieLibrary) =>
|
{
|
CommonMethod.Current.MainThread(() =>
|
{
|
DetailPage detailPage = new DetailPage(remoteControl, movieLibrary);
|
MainPage.BasePageView.AddChidren(detailPage);
|
MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
|
detailPage.Show();
|
detailPage.action += (isUpdate) =>
|
{
|
//是否要更新
|
if (isUpdate)
|
{
|
|
this.mMovieCollectList = AksCommonMethod.Current.CollectList;
|
InitMiddle();
|
}
|
};
|
});
|
};
|
|
}
|
|
/// <summary>
|
/// 初始数据
|
/// </summary>
|
private void ReadData()
|
{
|
if (mMovieCollectList .Count > 0)
|
{
|
CommonMethod.Current.MainThread(() =>
|
{
|
//有缓存数据直接加载
|
InitMiddle();
|
});
|
return;
|
}
|
CommonMethod.Current.Loading.Start();
|
CommonMethod.Current.SunThread(() =>
|
{
|
try
|
{
|
this.mMovieCollectList = SendMethod.Current.GetcollectPage(this.remoteControl.deviceId, this.remoteControl.rcId, pageNo, SendMethod.pageSize);
|
for (int i = 0; i < this.mMovieCollectList .Count; i++)
|
{
|
var mMovieLibrary = this.mMovieCollectList [i];
|
var bytes = SendMethod.Current.GetImage(mMovieLibrary.posterUrl);
|
mMovieLibrary.imageBytes = bytes;
|
//缓存数据
|
AksCommonMethod.Current.AddCollectMovie(mMovieLibrary);
|
}
|
}
|
catch { }
|
finally
|
{
|
CommonMethod.Current.MainThread(() =>
|
{
|
CommonMethod.Current.Loading.Hide();
|
InitMiddle();
|
|
});
|
}
|
});
|
|
}
|
|
}
|
}
|