PoemGalleryView.cs 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. using System.Collections.Generic;
  2. using ET;
  3. using FairyGUI;
  4. using UI.Poem;
  5. using UnityEngine;
  6. namespace GFGGame
  7. {
  8. public class PoemGalleryView : BaseWindow
  9. {
  10. private UI_PoemGalleryUI _ui;
  11. private List<PoemGalleryData> _galleryInfos = new List<PoemGalleryData>();
  12. private int _infoType = 0;//0推荐1好友2收藏3我的
  13. public override void Dispose()
  14. {
  15. if (_ui != null)
  16. {
  17. _ui.Dispose();
  18. _ui = null;
  19. }
  20. base.Dispose();
  21. }
  22. protected override void OnInit()
  23. {
  24. base.OnInit();
  25. packageName = UI_PoemGalleryUI.PACKAGE_NAME;
  26. _ui = UI_PoemGalleryUI.Create();
  27. this.viewCom = _ui.target;
  28. isfullScreen = true;
  29. _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("gzs_bjbj");
  30. _ui.m_btnback.onClick.Add(OnBtnBackClick);
  31. _ui.m_btnRecover.onClick.Add(OnBtnRecoverClick);
  32. _ui.m_btnJoin.onClick.Add(OnBtnJoinClick);
  33. _ui.m_btnFavorites.onClick.Add(OnBtnFavoritesClick);
  34. _ui.m_comNormal.m_btnShop.onClick.Add(OnBtnShopClick);
  35. _ui.m_comNormal.m_btnRecommend.onClick.Add(OnBtnRecommendClick);
  36. _ui.m_comNormal.m_btnNewest.onClick.Add(OnBtnNewestClick);
  37. _ui.m_comNormal.m_c1.onChanged.Add(OnNormalTabChange);
  38. _ui.m_comFavorites.m_c1.onChanged.Add(OnFavoritesTabChange);
  39. _ui.m_comNormal.m_listRecommend.itemRenderer = RenderListItem;
  40. _ui.m_comNormal.m_listRecommend.SetVirtual();
  41. _ui.m_comNormal.m_listRecommend.scrollPane.onPullDownRelease.Add(onPullDownRelease);
  42. _ui.m_comNormal.m_listRecommend.scrollPane.onScroll.Add(onScroll);
  43. _ui.m_comNormal.m_listRecommend.scrollPane.onScrollEnd.Add(OnScrollEnd);
  44. // SwipeGesture swipeGesture;
  45. // swipeGesture = new SwipeGesture(_ui.m_comNormal.m_listRecommend);
  46. // swipeGesture.onMove.Add(OnMove);
  47. }
  48. protected override void AddEventListener()
  49. {
  50. base.AddEventListener();
  51. }
  52. protected override void OnShown()
  53. {
  54. base.OnShown();
  55. }
  56. protected override void OnHide()
  57. {
  58. base.OnHide();
  59. }
  60. protected override void RemoveEventListener()
  61. {
  62. base.RemoveEventListener();
  63. }
  64. private void OnBtnBackClick()
  65. {
  66. ViewManager.GoBackFrom(typeof(PoemGalleryView).FullName);
  67. }
  68. //投稿
  69. private void OnBtnJoinClick()
  70. {
  71. }
  72. //首页
  73. private void OnBtnRecoverClick()
  74. {
  75. _ui.m_comNormal.m_c1.selectedIndex = 0;
  76. }
  77. //收藏夹
  78. private void OnBtnFavoritesClick()
  79. {
  80. _ui.m_comFavorites.m_c1.selectedIndex = 0;
  81. }
  82. //切换首页页签
  83. private void OnNormalTabChange()
  84. {
  85. if (_ui.m_comNormal.m_c1.selectedIndex == 2)
  86. {
  87. }
  88. else
  89. {
  90. if (_ui.m_comNormal.m_c1.selectedIndex == 0)
  91. {
  92. _infoType = 0;
  93. _galleryInfos = PoemGalleryDataManager.Instance.RecommendInfos;
  94. _ui.m_comNormal.m_listRecommend.numItems = 5;
  95. }
  96. else if (_ui.m_comNormal.m_c1.selectedIndex == 1)
  97. {
  98. _infoType = 1;
  99. _galleryInfos = PoemGalleryDataManager.Instance.FrinedInfos;
  100. }
  101. }
  102. }
  103. //切换收藏页签
  104. private void OnFavoritesTabChange()
  105. {
  106. if (_ui.m_comFavorites.m_c1.selectedIndex == 0)
  107. {
  108. _infoType = 2;
  109. _galleryInfos = PoemGalleryDataManager.Instance.FavoriteInfos;
  110. }
  111. else if (_ui.m_comFavorites.m_c1.selectedIndex == 1)
  112. {
  113. _infoType = 3;
  114. _galleryInfos = PoemGalleryDataManager.Instance.MySelfInfos;
  115. }
  116. }
  117. private void onPullDownRelease()
  118. {
  119. UI_ComHead header = UI_ComHead.Proxy(_ui.m_comNormal.m_listRecommend.scrollPane.header);
  120. // ScrollPaneHeader header = (ScrollPaneHeader)_ui.m_comNormal.m_listRecommend.scrollPane.header;
  121. // if (header.ReadyToRefresh)
  122. // {
  123. // header.SetRefreshStatus(2);
  124. header.m_c1.selectedIndex = 1;
  125. _ui.m_comNormal.m_listRecommend.scrollPane.LockHeader(header.target.sourceHeight);
  126. //Simulate a async resquest
  127. Timers.inst.Add(2, 1, (object param) =>
  128. {
  129. header.m_c1.selectedIndex = 2;
  130. // _ui.m_comNormal.m_listRecommend.numItems += 5;
  131. // //Refresh completed
  132. // header.SetRefreshStatus(3);
  133. // _ui.m_comNormal.m_listRecommend.scrollPane.LockHeader(35);
  134. // Timers.inst.Add(2, 1, (object param2) =>
  135. // {
  136. // header.SetRefreshStatus(0);
  137. _ui.m_comNormal.m_listRecommend.scrollPane.LockHeader(0);
  138. header.m_c1.selectedIndex = 0;
  139. // });
  140. });
  141. // }
  142. }
  143. private void OnMove(EventContext context)
  144. {
  145. SwipeGesture swipeture = (SwipeGesture)context.sender;
  146. ScrollPane scrollPane = _ui.m_comNormal.m_listRecommend.scrollPane;
  147. ET.Log.Debug("posY:" + scrollPane.header.position.y + " swipetureY:" + swipeture.position.y + " " + (-scrollPane.header.height + swipeture.position.y));
  148. scrollPane.header.SetXY(scrollPane.header.position.x, -scrollPane.header.height + swipeture.position.y);
  149. }
  150. private void onScroll()
  151. {
  152. ScrollPane scrollPane = _ui.m_comNormal.m_listRecommend.scrollPane;
  153. // scrollPane.
  154. // ET.Log.Debug("posY:" + scrollPane.posY + " scrollingPosY:" + scrollPane.scrollingPosY);
  155. }
  156. private void OnScrollEnd()
  157. {
  158. // ScrollPane scrollPane = _ui.m_comNormal.m_listRecommend.scrollPane;
  159. // scrollPane.header.SetXY();
  160. // _ui.m_comNormal.m_listRecommend.scrollPane.header.y = -_ui.m_comNormal.m_listRecommend.scrollPane.header.height;
  161. }
  162. //积分商店
  163. private void OnBtnShopClick()
  164. {
  165. ViewManager.Show<ClothingShopView>(new object[] { ConstStoreId.GALLERY_STORE_ID }, new object[] { typeof(PoemGalleryView).FullName, this.viewData }, true);
  166. }
  167. //推荐
  168. private void OnBtnRecommendClick()
  169. {
  170. }
  171. //最新
  172. private void OnBtnNewestClick()
  173. {
  174. }
  175. private void RenderListItem(int index, GObject obj)
  176. {
  177. }
  178. }
  179. }