wxr
2024-11-01 c0c734d7a84cf7105401878ffc4b64cbb67621d1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
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.Aks.Entity;
using HDL_ON.Entity;
using HDL_ON.UI.UI2.FuntionControlView.VideoDoorLock;
 
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();
 
                    });
                }
            });
 
        }
 
    }
}