PoemGalleryView.cs 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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.header.onSizeChanged.Add(OnSizeChanged);
  43. }
  44. protected override void AddEventListener()
  45. {
  46. base.AddEventListener();
  47. }
  48. protected override void OnShown()
  49. {
  50. base.OnShown();
  51. }
  52. protected override void OnHide()
  53. {
  54. base.OnHide();
  55. }
  56. protected override void RemoveEventListener()
  57. {
  58. base.RemoveEventListener();
  59. }
  60. private void OnBtnBackClick()
  61. {
  62. ViewManager.GoBackFrom(typeof(PoemGalleryView).FullName);
  63. }
  64. //投稿
  65. private void OnBtnJoinClick()
  66. {
  67. }
  68. //首页
  69. private void OnBtnRecoverClick()
  70. {
  71. _ui.m_comNormal.m_c1.selectedIndex = 0;
  72. }
  73. //收藏夹
  74. private void OnBtnFavoritesClick()
  75. {
  76. _ui.m_comFavorites.m_c1.selectedIndex = 0;
  77. }
  78. //切换首页页签
  79. private void OnNormalTabChange()
  80. {
  81. if (_ui.m_comNormal.m_c1.selectedIndex == 2)
  82. {
  83. }
  84. else
  85. {
  86. if (_ui.m_comNormal.m_c1.selectedIndex == 0)
  87. {
  88. _infoType = 0;
  89. _galleryInfos = PoemGalleryDataManager.Instance.RecommendInfos;
  90. _ui.m_comNormal.m_listRecommend.numItems = 5;
  91. }
  92. else if (_ui.m_comNormal.m_c1.selectedIndex == 1)
  93. {
  94. _infoType = 1;
  95. _galleryInfos = PoemGalleryDataManager.Instance.FrinedInfos;
  96. }
  97. }
  98. }
  99. //切换收藏页签
  100. private void OnFavoritesTabChange()
  101. {
  102. if (_ui.m_comFavorites.m_c1.selectedIndex == 0)
  103. {
  104. _infoType = 2;
  105. _galleryInfos = PoemGalleryDataManager.Instance.FavoriteInfos;
  106. }
  107. else if (_ui.m_comFavorites.m_c1.selectedIndex == 1)
  108. {
  109. _infoType = 3;
  110. _galleryInfos = PoemGalleryDataManager.Instance.MySelfInfos;
  111. }
  112. }
  113. private void onPullDownRelease()
  114. {
  115. GComponent header = _ui.m_comNormal.m_listRecommend.scrollPane.header;
  116. Controller controller = header.GetController("c1");
  117. controller.selectedIndex = 1;
  118. _ui.m_comNormal.m_listRecommend.scrollPane.LockHeader(header.sourceHeight);
  119. Timers.inst.Add(2, 1, (object param) =>
  120. {
  121. controller.selectedIndex = 2;
  122. _ui.m_comNormal.m_listRecommend.scrollPane.LockHeader(0);
  123. });
  124. }
  125. private void OnSizeChanged()
  126. {
  127. GComponent header = _ui.m_comNormal.m_listRecommend.scrollPane.header;
  128. Controller controller = _ui.m_comNormal.m_listRecommend.scrollPane.header.GetController("c1");
  129. if (header.height <= 1)
  130. {
  131. controller.selectedIndex = 0;
  132. }
  133. }
  134. //积分商店
  135. private void OnBtnShopClick()
  136. {
  137. ViewManager.Show<ClothingShopView>(new object[] { ConstStoreId.GALLERY_STORE_ID }, new object[] { typeof(PoemGalleryView).FullName, this.viewData }, true);
  138. }
  139. //推荐
  140. private void OnBtnRecommendClick()
  141. {
  142. }
  143. //最新
  144. private void OnBtnNewestClick()
  145. {
  146. }
  147. private void RenderListItem(int index, GObject obj)
  148. {
  149. }
  150. }
  151. }