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 { /// /// 收藏界面 /// public class CollectPage : FrameLayout { public CollectPage(RemoteControlEntity remoteControlEntity) { this.remoteControl = remoteControlEntity; //读缓存数据 var collectList = AksCommonMethod.Current.CollectList; this.mMovieCollectList .AddRange(collectList); } /// /// 影片收藏列表 /// private List mMovieCollectList =new List(); /// /// 当前的遥控器对象 /// RemoteControlEntity remoteControl; /// /// 影片列表上下滑动容器 /// VerticalRefreshLayout vv; /// /// 影片容器 /// CornerFramLayout imageFLayout; /// /// 头部布局 /// private TopView topView; /// /// 当前页数 /// private int pageNo=1; public void Show() { //初始化UI this.InitUi(); this.InitMiddle(); //读取数据 ReadData(); } /// /// 初始化头部界面 /// 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(); }; } /// /// 初始化中部界面 /// 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(); } }; }); }; } /// /// 初始数据 /// 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(); }); } }); } } }