PoemGalleryView.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615
  1. using System.Collections.Generic;
  2. using ET;
  3. using FairyGUI;
  4. using UI.Poem;
  5. using UnityEngine;
  6. namespace GFGGame
  7. {
  8. class TabType
  9. {
  10. /// <summary>
  11. /// 首页
  12. /// </summary>
  13. public static int RECOVER = 0;
  14. /// <summary>
  15. /// 投稿
  16. /// </summary>
  17. public static int JOIN = 1;
  18. /// <summary>
  19. /// 收藏
  20. /// </summary>
  21. public static int FAVORITES = 2;
  22. }
  23. class RecommendType
  24. {
  25. /// <summary>
  26. /// 推荐
  27. /// </summary>
  28. public static int RECOMMEND = 0;
  29. /// <summary>
  30. /// 好友
  31. /// </summary>
  32. public static int FRIEND = 1;
  33. /// <summary>
  34. /// 排行榜
  35. /// </summary>
  36. public static int RANK = 2;
  37. }
  38. class FavoritesType
  39. {
  40. /// <summary>
  41. /// 我的收藏
  42. /// </summary>
  43. public static int FAVORITE = 0;
  44. /// <summary>
  45. /// 我的作品
  46. /// </summary>
  47. public static int MY_SELF = 1;
  48. }
  49. public class PoemGalleryView : BaseWindow
  50. {
  51. private UI_PoemGalleryUI _ui;
  52. private GList _list;
  53. private GList _list1;
  54. private GComponent _comScroll;
  55. // private List<PoemGalleryData> _galleryDatas = new List<PoemGalleryData>();
  56. private List<long> _galleryDatas = new List<long>();
  57. private int _sortType = 0;//由GallerySortType定义
  58. private int _pageCount = 10;
  59. private int _tabIndex = 0;//当前选中大页签下标,首页0投稿1收藏2
  60. private int _subtabIndex = 0;//当前选中小页签下标,推荐0好友1排行榜2;我的收藏0我的作品1
  61. private bool isPullDown = false;//是否下拉刷新中,刷新中再次下拉不会重新请求更新数据
  62. private bool isPullUp = false;//是否上拉刷新中,刷新中再次下拉不会重新请求更新数据
  63. public override void Dispose()
  64. {
  65. if (_ui != null)
  66. {
  67. _ui.Dispose();
  68. _ui = null;
  69. }
  70. base.Dispose();
  71. }
  72. protected override void OnInit()
  73. {
  74. base.OnInit();
  75. packageName = UI_PoemGalleryUI.PACKAGE_NAME;
  76. _ui = UI_PoemGalleryUI.Create();
  77. this.viewCom = _ui.target;
  78. isfullScreen = true;
  79. _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("hc_bj_1");
  80. _ui.m_comNormal.m_comBoBox.items = new string[] { "推荐", "最新" };
  81. _ui.m_comNormal.m_comBoBox.icons = new string[] { "ui://Poem/hl_pxpx", "ui://Poem/hl_zxzx" };
  82. _ui.m_btnback.onClick.Add(OnBtnBackClick);
  83. _ui.m_btnRecover.onClick.Add(OnBtnRecoverClick);
  84. _ui.m_btnJoin.onClick.Add(OnBtnJoinClick);
  85. _ui.m_btnFavorites.onClick.Add(OnBtnFavoritesClick);
  86. _ui.m_comNormal.m_comScroll.target.scrollPane.onPullDownRelease.Add(onPullDownRelease);
  87. _ui.m_comNormal.m_comScroll.target.scrollPane.onPullUpRelease.Add(OnPullUpToRefresh);
  88. _ui.m_comNormal.m_comScroll.target.scrollPane.onScrollEnd.Add(onScrollEnd);
  89. _ui.m_comFavorites.m_comScroll.target.scrollPane.onPullDownRelease.Add(onPullDownRelease);
  90. _ui.m_comFavorites.m_comScroll.target.scrollPane.onPullUpRelease.Add(OnPullUpToRefresh);
  91. _ui.m_comFavorites.m_comScroll.target.scrollPane.onScrollEnd.Add(onScrollEnd);
  92. _ui.m_comNormal.m_comScroll.m_listRecommend.itemRenderer = RenderListItem;
  93. _ui.m_comNormal.m_comScroll.m_listRecommend1.itemRenderer = RenderListItem1;
  94. _ui.m_comFavorites.m_comScroll.m_listRecommend.itemRenderer = RenderListItem;
  95. _ui.m_comFavorites.m_comScroll.m_listRecommend1.itemRenderer = RenderListItem1;
  96. _ui.m_comNormal.m_listRank.itemRenderer = RenderListRankItem;
  97. _ui.m_comNormal.m_listRank.SetVirtual();
  98. _ui.m_comNormal.m_btnShop.onClick.Add(OnBtnShopClick);
  99. _ui.m_comNormal.m_btnReward.onClick.Add(OnBtnRewardClick);
  100. _ui.m_comNormal.m_c1.onChanged.Add(OnNormalTabChange);
  101. _ui.m_comFavorites.m_c1.onChanged.Add(OnFavoritesTabChange);
  102. }
  103. protected override void AddEventListener()
  104. {
  105. base.AddEventListener();
  106. // EventAgent.AddEventListener(ConstMessage.GALLERY_DATA_CHANGE, UpdateGalleryList);
  107. // EventAgent.AddEventListener(ConstMessage.GALLERY_RANK_DATA_CHANGE, UpdateGalleryRankList);
  108. }
  109. protected override void OnShown()
  110. {
  111. base.OnShown();
  112. if (this.viewData != null)
  113. {
  114. _tabIndex = (int)(this.viewData as object[])[0];
  115. _subtabIndex = (int)(this.viewData as object[])[1];
  116. _ui.m_comNormal.m_comBoBox.selectedIndex = (int)(this.viewData as object[])[2];
  117. _ui.m_comNormal.m_c1.selectedIndex = _subtabIndex;
  118. _ui.m_comFavorites.m_c1.selectedIndex = _subtabIndex;
  119. UpdateGalleryList();
  120. }
  121. else
  122. {
  123. _tabIndex = TabType.RECOVER;
  124. _subtabIndex = RecommendType.RECOMMEND;
  125. _ui.m_comNormal.m_comBoBox.selectedIndex = 0;
  126. _ui.m_comNormal.m_c1.selectedIndex = _subtabIndex;
  127. _ui.m_comFavorites.m_c1.selectedIndex = _subtabIndex;
  128. _comScroll = _ui.m_comNormal.m_comScroll.target;
  129. if (_ui.m_comNormal.m_comScroll.m_listRecommend.numItems > 0) _ui.m_comNormal.m_comScroll.m_listRecommend.ScrollToView(0);
  130. if (_ui.m_comNormal.m_comScroll.m_listRecommend1.numItems > 0) _ui.m_comNormal.m_comScroll.m_listRecommend1.ScrollToView(0);
  131. if (_ui.m_comFavorites.m_comScroll.m_listRecommend.numItems > 0) _ui.m_comFavorites.m_comScroll.m_listRecommend.ScrollToView(0);
  132. if (_ui.m_comFavorites.m_comScroll.m_listRecommend1.numItems > 0) _ui.m_comFavorites.m_comScroll.m_listRecommend1.ScrollToView(0);
  133. OnNormalTabChange();
  134. }
  135. _ui.m_c1.selectedIndex = _tabIndex;
  136. // UpdateGalleryList();
  137. UpdateView();
  138. }
  139. protected override void OnHide()
  140. {
  141. base.OnHide();
  142. ResetPullRelease();
  143. _ui.m_comNormal.m_comBoBox.selectedIndex = 0;
  144. }
  145. protected override void RemoveEventListener()
  146. {
  147. base.RemoveEventListener();
  148. // EventAgent.RemoveEventListener(ConstMessage.GALLERY_DATA_CHANGE, UpdateGalleryList);
  149. // EventAgent.RemoveEventListener(ConstMessage.GALLERY_RANK_DATA_CHANGE, UpdateGalleryRankList);
  150. }
  151. private void OnBtnBackClick()
  152. {
  153. ViewManager.GoBackFrom(typeof(PoemGalleryView).FullName);
  154. }
  155. /// <summary>
  156. /// 积分商店
  157. /// </summary>
  158. private void OnBtnShopClick()
  159. {
  160. object[] gobackParamDatas = new object[] { _tabIndex, _subtabIndex, _ui.m_comNormal.m_comBoBox.selectedIndex };
  161. ViewManager.Show<GalleryShopView>(new object[] { ConstStoreId.GALLERY_STORE_ID }, new object[] { typeof(PoemGalleryView).FullName, gobackParamDatas }, true);
  162. }
  163. /// <summary>
  164. /// 排行榜奖励
  165. /// </summary>
  166. private void OnBtnRewardClick()
  167. {
  168. ViewManager.Show<PoemGalleryRewardView>(null, new object[] { typeof(PoemGalleryView).FullName, this.viewData });
  169. }
  170. /********************************************************页签切换*************************************************/
  171. /// <summary>
  172. /// 首页
  173. /// </summary>
  174. private void OnBtnRecoverClick()
  175. {
  176. if (_tabIndex == TabType.RECOVER && _ui.m_comNormal.m_c1.selectedIndex == RecommendType.RECOMMEND)//当前在推荐页要刷新
  177. {
  178. PullDown();
  179. onPullDownRelease();
  180. }
  181. else//当前不在推荐页只把页签切回到推荐页,不刷新
  182. {
  183. _ui.m_comNormal.m_c1.selectedIndex = RecommendType.RECOMMEND;
  184. }
  185. _tabIndex = _ui.m_c1.selectedIndex;
  186. _subtabIndex = _ui.m_comNormal.m_c1.selectedIndex;
  187. _comScroll = _ui.m_comNormal.m_comScroll.target;
  188. }
  189. /// <summary>
  190. /// 投稿
  191. /// </summary>
  192. private void OnBtnJoinClick()
  193. {
  194. object[] gobackParamDatas = new object[] { _tabIndex, _subtabIndex, _ui.m_comNormal.m_comBoBox.selectedIndex };
  195. ViewManager.Show<DressUpView>(1, new object[] { typeof(PoemGalleryView).FullName, gobackParamDatas }, true);
  196. }
  197. /// <summary>
  198. ///收藏夹
  199. /// </summary>
  200. private void OnBtnFavoritesClick()
  201. {
  202. _tabIndex = _ui.m_c1.selectedIndex;
  203. _comScroll = _ui.m_comFavorites.m_comScroll.target;
  204. if (_ui.m_comFavorites.m_c1.selectedIndex != FavoritesType.FAVORITE)
  205. {
  206. _ui.m_comFavorites.m_c1.selectedIndex = FavoritesType.FAVORITE;
  207. }
  208. _subtabIndex = _ui.m_comFavorites.m_c1.selectedIndex;
  209. ResetPullRelease();
  210. }
  211. /// <summary>
  212. /// 切换首页页签
  213. /// </summary>
  214. private void OnNormalTabChange()
  215. {
  216. ResetPullRelease();
  217. _subtabIndex = _ui.m_comNormal.m_c1.selectedIndex;
  218. if (_ui.m_comNormal.m_c1.selectedIndex == RecommendType.RANK)//排行榜
  219. {
  220. _galleryDatas = PoemGalleryDataManager.Instance.RankDatas;
  221. ReqGalleryRankList();
  222. }
  223. else
  224. {
  225. if (_ui.m_comNormal.m_c1.selectedIndex == RecommendType.RECOMMEND)//首页
  226. {
  227. if (_ui.m_comNormal.m_comBoBox.selectedIndex == 0)//推荐
  228. {
  229. _sortType = (int)GallerySortType.Recommend;
  230. _galleryDatas = PoemGalleryDataManager.Instance.RecommendDatas;
  231. }
  232. else//最新
  233. {
  234. _sortType = (int)GallerySortType.Newest;
  235. _galleryDatas = PoemGalleryDataManager.Instance.NewestDatas;
  236. }
  237. }
  238. else if (_ui.m_comNormal.m_c1.selectedIndex == RecommendType.FRIEND)//好友
  239. {
  240. _sortType = (int)GallerySortType.Friend;
  241. _galleryDatas = PoemGalleryDataManager.Instance.FrinedDatas;
  242. }
  243. _list = _ui.m_comNormal.m_comScroll.m_listRecommend;
  244. _list1 = _ui.m_comNormal.m_comScroll.m_listRecommend1;
  245. if (_list.numItems > 0) _list.ScrollToView(0);
  246. if (_list1.numItems > 0) _list.ScrollToView(0);
  247. ReqGalleryList(0);
  248. }
  249. }
  250. /// <summary>
  251. /// 切换收藏页签
  252. /// </summary>
  253. private void OnFavoritesTabChange()
  254. {
  255. _subtabIndex = _ui.m_comFavorites.m_c1.selectedIndex;
  256. if (_ui.m_comFavorites.m_c1.selectedIndex == FavoritesType.FAVORITE)//我的收藏
  257. {
  258. _sortType = (int)GallerySortType.MyCollect;
  259. _galleryDatas = PoemGalleryDataManager.Instance.FrinedDatas;
  260. }
  261. else if (_ui.m_comFavorites.m_c1.selectedIndex == FavoritesType.MY_SELF)//我的作品
  262. {
  263. _sortType = (int)GallerySortType.MyWorks;
  264. _galleryDatas = PoemGalleryDataManager.Instance.FrinedDatas;
  265. }
  266. _list = _ui.m_comNormal.m_comScroll.m_listRecommend;
  267. _list1 = _ui.m_comNormal.m_comScroll.m_listRecommend1;
  268. if (_list.numItems > 0) _list.ScrollToView(0);
  269. if (_list1.numItems > 0) _list.ScrollToView(0);
  270. ReqGalleryList(0);
  271. }
  272. /********************************************************请求更新列表*************************************************/
  273. private void onScrollEnd()
  274. {
  275. if (_comScroll.scrollPane.percY == 1)
  276. {
  277. ReqGalleryList(_list.numItems);
  278. }
  279. }
  280. //请求刷新
  281. private async void ReqGalleryList(int startIndex)
  282. {
  283. bool result = await PoemGallerySProxy.ReqGalleryList(_sortType, startIndex, _pageCount);
  284. if (result)
  285. {
  286. UpdateGalleryList();
  287. }
  288. }
  289. private void UpdateGalleryList()
  290. {
  291. if (_galleryDatas.Count % 2 == 0)
  292. {
  293. _list.numItems = _galleryDatas.Count / 2;
  294. _list1.numItems = _galleryDatas.Count / 2;
  295. }
  296. else
  297. {
  298. _list.numItems = (_galleryDatas.Count + 1) / 2;
  299. _list1.numItems = (_galleryDatas.Count - 1) / 2;
  300. }
  301. _list.ResizeToFit();
  302. _list1.ResizeToFit();
  303. UpdateView();
  304. }
  305. //请求排行榜刷新
  306. private void ReqGalleryRankList()
  307. {
  308. PoemGallerySProxy.ReqRankList().Coroutine();
  309. }
  310. private void UpdateGalleryRankList()
  311. {
  312. _ui.m_comNormal.m_listRank.numItems = _galleryDatas.Count;
  313. UpdateView();
  314. }
  315. private void RefreshList()
  316. {
  317. if (_ui.m_comNormal.m_c1.selectedIndex == RecommendType.RANK)
  318. {
  319. _ui.m_comNormal.m_listRank.RefreshVirtualList();
  320. }
  321. else
  322. {
  323. _list.RefreshVirtualList();
  324. _list1.RefreshVirtualList();
  325. }
  326. UpdateView();
  327. }
  328. /********************************************************界面更新*************************************************/
  329. private void UpdateView()
  330. {
  331. GalleryThemeCfg themeCfg = GalleryThemeCfgArray.Instance.GetCfg((int)PoemGalleryDataManager.Instance.ThemeId);
  332. _ui.m_comNormal.m_txtTheme.text = string.Format("本期主题:{0}", themeCfg.theme);
  333. _ui.m_comNormal.m_txtRank.text = string.Format("我的排名:{0}", PoemGalleryDataManager.Instance.MyRank);
  334. _ui.m_comNormal.m_txtRewardCount.text = string.Format("奖励次数:{0}/{1}", PoemGalleryDataManager.Instance.VoteCount, GalleryRewardCfgArray.Instance.dataArray.Length);
  335. _ui.m_comNormal.m_txtTime.text = PoemGalleryDataManager.Instance.GetThemeTime();
  336. _ui.m_comNormal.m_grpResult.visible = PoemGalleryDataManager.Instance.IsResulting();
  337. }
  338. private void RenderListItem(int index, GObject obj)
  339. {
  340. long workId = _galleryDatas[index * 2];
  341. UpdateListItem(workId, obj);
  342. }
  343. private void RenderListItem1(int index, GObject obj)
  344. {
  345. long workId = _galleryDatas[index * 2 + 1];
  346. UpdateListItem(workId, obj);
  347. }
  348. private void UpdateListItem(long workId, GObject obj)
  349. {
  350. PoemGalleryData data = PoemGalleryDataManager.Instance.GetGalleryDataById(workId);
  351. UI_ListItem item = UI_ListItem.Proxy(obj);
  352. if (data.Ntexture == null)
  353. {
  354. Timers.inst.StartCoroutine(PictureStorageHelper.DownloadFile(data.PictureTempUrl, (Texture2D texture) =>
  355. {
  356. data.Ntexture = new NTexture(texture);
  357. item.m_loaIcon.texture = data.Ntexture;
  358. }));
  359. }
  360. else
  361. {
  362. item.m_loaIcon.texture = data.Ntexture;
  363. }
  364. item.m_loaIcon.height = item.m_loaIcon.width * item.m_loaIcon.texture.height / item.m_loaIcon.texture.width;
  365. item.m_txtName.text = data.AuthorName;
  366. item.m_btnCollect.title = data.CollectCount.ToString();
  367. item.m_btnCollect.selected = data.CollectOrNot;
  368. item.m_btnVote.title = data.VoteCount.ToString();
  369. item.m_btnVote.selected = data.VoteOrNot;
  370. if (item.m_loaIcon.data == null)
  371. {
  372. item.m_loaIcon.onClick.Add(OnLoaIconClick);
  373. }
  374. item.m_loaIcon.data = workId;
  375. if (item.m_btnCollect.data == null)
  376. {
  377. item.m_btnCollect.onClick.Add(OnBtnCollectClick);
  378. }
  379. item.m_btnCollect.data = workId;
  380. if (item.m_btnVote.data == null)
  381. {
  382. item.m_btnVote.onClick.Add(OnBtnVoteClick);
  383. }
  384. item.m_btnVote.data = workId;
  385. UI_ListItem.ProxyEnd();
  386. }
  387. private void RenderListRankItem(int index, GObject obj)
  388. {
  389. long workId = _galleryDatas[index];
  390. PoemGalleryData data = PoemGalleryDataManager.Instance.GetGalleryDataById(workId);
  391. UI_ListRankItem item = UI_ListRankItem.Proxy(obj);
  392. // item.target.height = item.m_loaIcon.height + 80;
  393. // item.m_loaIcon.texture = data.Ntexture;
  394. // item.m_txtName.text = data.AuthorName;
  395. // item.m_btnCollect.title = data.CollectCount.ToString();
  396. // item.m_btnCollect.selected = data.CollectOrNot;
  397. // item.m_btnVote.title = data.VoteCount.ToString();
  398. // item.m_btnVote.selected = data.VoteOrNot;
  399. // item.m_c1.selectedIndex = index < 3 ? index : 3;
  400. // if (item.m_loaIcon.data == null)
  401. // {
  402. // item.m_loaIcon.onClick.Add(OnLoaIconClick);
  403. // }
  404. // item.m_loaIcon.data = workId;
  405. // if (item.m_btnCollect.data == null)
  406. // {
  407. // item.m_btnCollect.onClick.Add(OnBtnCollectClick);
  408. // }
  409. // item.m_btnCollect.data = workId;
  410. // if (item.m_btnVote.data == null)
  411. // {
  412. // item.m_btnVote.onClick.Add(OnBtnVoteClick);
  413. // }
  414. // item.m_btnVote.data = workId;
  415. UI_ListRankItem.ProxyEnd();
  416. }
  417. private void OnLoaIconClick(EventContext context)
  418. {
  419. GObject obj = context.data as GObject;
  420. long workId = (long)obj.data;
  421. object[] gobackParamDatas = new object[] { _tabIndex, _subtabIndex, _ui.m_comNormal.m_comBoBox.selectedIndex };
  422. ViewManager.Show<PoemGalleryPreviewView>(new object[] { _sortType, workId }, new object[] { typeof(PoemGalleryView).FullName, gobackParamDatas });
  423. }
  424. private async void OnBtnCollectClick(EventContext context)
  425. {
  426. GObject obj = context.data as GObject;
  427. long workId = (long)obj.data;
  428. PoemGalleryData galleryData = PoemGalleryDataManager.Instance.GetGalleryDataById(workId);
  429. if (galleryData.CollectOrNot)
  430. {
  431. bool result = await PoemGallerySProxy.ReqCancelCollecteGalleryWorks(workId);
  432. if (result)
  433. {
  434. if (_tabIndex == TabType.FAVORITES && _subtabIndex == FavoritesType.FAVORITE)
  435. {
  436. ReqGalleryList(0);//当前为收藏页要重新拉取数据
  437. }
  438. else
  439. {
  440. RefreshList();
  441. }
  442. }
  443. }
  444. else
  445. {
  446. bool result = await PoemGallerySProxy.ReqCollecteGalleryWorks(workId);
  447. if (result)
  448. {
  449. if (_tabIndex == TabType.FAVORITES && _subtabIndex == FavoritesType.FAVORITE)
  450. {
  451. ReqGalleryList(0);//当前为收藏页要重新拉取数据
  452. }
  453. else
  454. {
  455. RefreshList();
  456. }
  457. }
  458. }
  459. }
  460. private async void OnBtnVoteClick(EventContext context)
  461. {
  462. GObject obj = context.data as GObject;
  463. long workId = (long)obj.data;
  464. PoemGalleryData galleryData = PoemGalleryDataManager.Instance.GetGalleryDataById(workId);
  465. if (galleryData.VoteOrNot) return;
  466. bool result = await PoemGallerySProxy.ReqVoteGalleryWorks(workId);
  467. if (result)
  468. {
  469. RefreshList();
  470. int Count = GameGlobal.myNumericComponent.GetAsInt(NumericType.LikeGalleryWorksCountDaily);
  471. GalleryIntegralCfg integralCfg = GalleryIntegralCfgArray.Instance.GetCfg(Count);
  472. if (integralCfg != null)
  473. {
  474. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(integralCfg.itemId);
  475. PromptController.Instance.ShowFloatTextPrompt(string.Format("{0} +{1}", itemCfg.name, integralCfg.Count));
  476. }
  477. }
  478. }
  479. /********************************************************下拉刷新*************************************************/
  480. //自动下拉
  481. private void PullDown()
  482. {
  483. _list.ScrollToView(0);
  484. GComponent header = _comScroll.scrollPane.header;
  485. header.height = header.sourceHeight;
  486. }
  487. //下拉刷新
  488. private async void onPullDownRelease()
  489. {
  490. GComponent header = _comScroll.scrollPane.header;
  491. if (header.height < header.sourceHeight || isPullDown) return;
  492. isPullDown = true;
  493. _comScroll.scrollPane.LockHeader(header.sourceHeight);
  494. bool result = await PoemGallerySProxy.ReqGalleryList(_sortType, 0, _pageCount);
  495. OnPullDownTimeComplete();
  496. if (result)
  497. {
  498. UpdateGalleryList();
  499. }
  500. }
  501. private void OnPullDownTimeComplete()
  502. {
  503. GComponent header = _comScroll.scrollPane.header;
  504. Transition transition = header.GetTransition("t0");
  505. transition.Stop();
  506. _comScroll.scrollPane.LockHeader(0);
  507. isPullDown = false;
  508. }
  509. //上拉刷新
  510. private async void OnPullUpToRefresh()
  511. {
  512. GComponent footer = _comScroll.scrollPane.footer;
  513. if (footer.height < footer.sourceHeight || isPullUp) return;
  514. isPullUp = true;
  515. _comScroll.scrollPane.LockFooter(footer.sourceHeight + 10);
  516. bool result = await PoemGallerySProxy.ReqGalleryList(_sortType, _galleryDatas.Count, _pageCount);
  517. OnPullUpTimeComplete();
  518. if (result)
  519. {
  520. UpdateGalleryList();
  521. }
  522. }
  523. private void OnPullUpTimeComplete()
  524. {
  525. GComponent footer = _comScroll.scrollPane.footer;
  526. Transition transition = footer.GetTransition("t0");
  527. transition.Stop();
  528. // header.GetController("c1").selectedIndex = 2;
  529. _comScroll.scrollPane.LockFooter(0);
  530. isPullUp = false;
  531. }
  532. //重置上拉/下拉刷新状态
  533. private void ResetPullRelease()
  534. {
  535. // Timers.inst.Remove(OnPullDownTimeComplete);
  536. OnPullDownTimeComplete();
  537. // Timers.inst.Remove(OnPullUpTimeComplete);
  538. OnPullUpTimeComplete();
  539. }
  540. }
  541. }