123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211 |
- using System.Collections.Generic;
- using ET;
- using FairyGUI;
- using UI.Poem;
- using UnityEngine;
- namespace GFGGame
- {
- public class PoemGalleryView : BaseWindow
- {
- private UI_PoemGalleryUI _ui;
- private List<PoemGalleryData> _galleryInfos = new List<PoemGalleryData>();
- private int _infoType = 0;//0推荐1好友2收藏3我的
- public override void Dispose()
- {
- if (_ui != null)
- {
- _ui.Dispose();
- _ui = null;
- }
- base.Dispose();
- }
- protected override void OnInit()
- {
- base.OnInit();
- packageName = UI_PoemGalleryUI.PACKAGE_NAME;
- _ui = UI_PoemGalleryUI.Create();
- this.viewCom = _ui.target;
- isfullScreen = true;
- _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("gzs_bjbj");
- _ui.m_btnback.onClick.Add(OnBtnBackClick);
- _ui.m_btnRecover.onClick.Add(OnBtnRecoverClick);
- _ui.m_btnJoin.onClick.Add(OnBtnJoinClick);
- _ui.m_btnFavorites.onClick.Add(OnBtnFavoritesClick);
- _ui.m_comNormal.m_btnShop.onClick.Add(OnBtnShopClick);
- _ui.m_comNormal.m_btnRecommend.onClick.Add(OnBtnRecommendClick);
- _ui.m_comNormal.m_btnNewest.onClick.Add(OnBtnNewestClick);
- _ui.m_comNormal.m_c1.onChanged.Add(OnNormalTabChange);
- _ui.m_comFavorites.m_c1.onChanged.Add(OnFavoritesTabChange);
- _ui.m_comNormal.m_listRecommend.itemRenderer = RenderListItem;
- _ui.m_comNormal.m_listRecommend.SetVirtual();
- _ui.m_comNormal.m_listRecommend.scrollPane.onPullDownRelease.Add(onPullDownRelease);
- _ui.m_comNormal.m_listRecommend.scrollPane.onScroll.Add(onScroll);
- _ui.m_comNormal.m_listRecommend.scrollPane.onScrollEnd.Add(OnScrollEnd);
- // SwipeGesture swipeGesture;
- // swipeGesture = new SwipeGesture(_ui.m_comNormal.m_listRecommend);
- // swipeGesture.onMove.Add(OnMove);
- }
- protected override void AddEventListener()
- {
- base.AddEventListener();
- }
- protected override void OnShown()
- {
- base.OnShown();
- }
- protected override void OnHide()
- {
- base.OnHide();
- }
- protected override void RemoveEventListener()
- {
- base.RemoveEventListener();
- }
- private void OnBtnBackClick()
- {
- ViewManager.GoBackFrom(typeof(PoemGalleryView).FullName);
- }
- //投稿
- private void OnBtnJoinClick()
- {
- }
- //首页
- private void OnBtnRecoverClick()
- {
- _ui.m_comNormal.m_c1.selectedIndex = 0;
- }
- //收藏夹
- private void OnBtnFavoritesClick()
- {
- _ui.m_comFavorites.m_c1.selectedIndex = 0;
- }
- //切换首页页签
- private void OnNormalTabChange()
- {
- if (_ui.m_comNormal.m_c1.selectedIndex == 2)
- {
- }
- else
- {
- if (_ui.m_comNormal.m_c1.selectedIndex == 0)
- {
- _infoType = 0;
- _galleryInfos = PoemGalleryDataManager.Instance.RecommendInfos;
- _ui.m_comNormal.m_listRecommend.numItems = 5;
- }
- else if (_ui.m_comNormal.m_c1.selectedIndex == 1)
- {
- _infoType = 1;
- _galleryInfos = PoemGalleryDataManager.Instance.FrinedInfos;
- }
- }
- }
- //切换收藏页签
- private void OnFavoritesTabChange()
- {
- if (_ui.m_comFavorites.m_c1.selectedIndex == 0)
- {
- _infoType = 2;
- _galleryInfos = PoemGalleryDataManager.Instance.FavoriteInfos;
- }
- else if (_ui.m_comFavorites.m_c1.selectedIndex == 1)
- {
- _infoType = 3;
- _galleryInfos = PoemGalleryDataManager.Instance.MySelfInfos;
- }
- }
- private void onPullDownRelease()
- {
- UI_ComHead header = UI_ComHead.Proxy(_ui.m_comNormal.m_listRecommend.scrollPane.header);
- // ScrollPaneHeader header = (ScrollPaneHeader)_ui.m_comNormal.m_listRecommend.scrollPane.header;
- // if (header.ReadyToRefresh)
- // {
- // header.SetRefreshStatus(2);
- header.m_c1.selectedIndex = 1;
- _ui.m_comNormal.m_listRecommend.scrollPane.LockHeader(header.target.sourceHeight);
- //Simulate a async resquest
- Timers.inst.Add(2, 1, (object param) =>
- {
- header.m_c1.selectedIndex = 2;
- // _ui.m_comNormal.m_listRecommend.numItems += 5;
- // //Refresh completed
- // header.SetRefreshStatus(3);
- // _ui.m_comNormal.m_listRecommend.scrollPane.LockHeader(35);
- // Timers.inst.Add(2, 1, (object param2) =>
- // {
- // header.SetRefreshStatus(0);
- _ui.m_comNormal.m_listRecommend.scrollPane.LockHeader(0);
- header.m_c1.selectedIndex = 0;
- // });
- });
- // }
- }
- private void OnMove(EventContext context)
- {
- SwipeGesture swipeture = (SwipeGesture)context.sender;
- ScrollPane scrollPane = _ui.m_comNormal.m_listRecommend.scrollPane;
- ET.Log.Debug("posY:" + scrollPane.header.position.y + " swipetureY:" + swipeture.position.y + " " + (-scrollPane.header.height + swipeture.position.y));
- scrollPane.header.SetXY(scrollPane.header.position.x, -scrollPane.header.height + swipeture.position.y);
- }
- private void onScroll()
- {
- ScrollPane scrollPane = _ui.m_comNormal.m_listRecommend.scrollPane;
- // scrollPane.
- // ET.Log.Debug("posY:" + scrollPane.posY + " scrollingPosY:" + scrollPane.scrollingPosY);
- }
- private void OnScrollEnd()
- {
- // ScrollPane scrollPane = _ui.m_comNormal.m_listRecommend.scrollPane;
- // scrollPane.header.SetXY();
- // _ui.m_comNormal.m_listRecommend.scrollPane.header.y = -_ui.m_comNormal.m_listRecommend.scrollPane.header.height;
- }
- //积分商店
- private void OnBtnShopClick()
- {
- ViewManager.Show<ClothingShopView>(new object[] { ConstStoreId.GALLERY_STORE_ID }, new object[] { typeof(PoemGalleryView).FullName, this.viewData }, true);
- }
- //推荐
- private void OnBtnRecommendClick()
- {
- }
- //最新
- private void OnBtnNewestClick()
- {
- }
- private void RenderListItem(int index, GObject obj)
- {
- }
- }
- }
|