123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264 |
- 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<long> _galleryIds = new List<long>();
- 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_listRecommend.itemRenderer = RenderListItem;
- _ui.m_comNormal.m_listRecommend.SetVirtual();
- _ui.m_comNormal.m_listRecommend.scrollPane.onPullDownRelease.Add(onPullDownRelease);
- _ui.m_comNormal.m_listRecommend.scrollPane.header.onSizeChanged.Add(OnSizeChanged);
- _ui.m_comNormal.m_listFriend.itemRenderer = RenderListItem;
- _ui.m_comNormal.m_listFriend.SetVirtual();
- _ui.m_comNormal.m_listRank.itemRenderer = RenderListRankItem;
- _ui.m_comNormal.m_listRank.SetVirtual();
- _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_btnReward.onClick.Add(OnBtnRewardClick);
- _ui.m_comNormal.m_c1.onChanged.Add(OnNormalTabChange);
- _ui.m_comFavorites.m_c1.onChanged.Add(OnFavoritesTabChange);
- }
- 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);
- }
- /// <summary>
- /// 投稿
- /// </summary>
- private void OnBtnJoinClick()
- {
- ViewManager.Show<DressUpView>(1, new object[] { typeof(PoemGalleryView).FullName, this.viewData }, true);
- }
- /// <summary>
- /// 首页
- /// </summary>
- private void OnBtnRecoverClick()
- {
- _ui.m_comNormal.m_c1.selectedIndex = 0;
- }
- /// <summary>
- ///收藏夹
- /// </summary>
- private void OnBtnFavoritesClick()
- {
- _ui.m_comFavorites.m_c1.selectedIndex = 0;
- }
- /// <summary>
- /// 切换首页页签
- /// </summary>
- private void OnNormalTabChange()
- {
- if (_ui.m_comNormal.m_c1.selectedIndex == 2)
- {
- }
- else
- {
- if (_ui.m_comNormal.m_c1.selectedIndex == 0)
- {
- // _infoType = GalleryType.Recommend;
- _galleryIds = PoemGalleryDataManager.Instance.RecommendInfos;
- _ui.m_comNormal.m_listRecommend.numItems = 5;
- }
- else if (_ui.m_comNormal.m_c1.selectedIndex == 1)
- {
- // _infoType = GalleryType.Friend;
- _galleryIds = PoemGalleryDataManager.Instance.FrinedInfos;
- }
- }
- }
- /// <summary>
- /// 切换收藏页签
- /// </summary>
- private void OnFavoritesTabChange()
- {
- if (_ui.m_comFavorites.m_c1.selectedIndex == 0)
- {
- // _infoType = GalleryType.Favorite;
- _galleryIds = PoemGalleryDataManager.Instance.FavoriteInfos;
- }
- else if (_ui.m_comFavorites.m_c1.selectedIndex == 1)
- {
- // _infoType = GalleryType.MySelf;
- _galleryIds = PoemGalleryDataManager.Instance.MySelfInfos;
- }
- }
- /// <summary>
- /// 积分商店
- /// </summary>
- private void OnBtnShopClick()
- {
- ViewManager.Show<ClothingShopView>(new object[] { ConstStoreId.GALLERY_STORE_ID }, new object[] { typeof(PoemGalleryView).FullName, this.viewData }, true);
- }
- /// <summary>
- /// 推荐
- /// </summary>
- private void OnBtnRecommendClick()
- {
- }
- /// <summary>
- /// 最新
- /// </summary>
- private void OnBtnNewestClick()
- {
- ViewManager.Show<PoemGalleryRewardView>(null, new object[] { typeof(PoemGalleryView).FullName, this.viewData }, true);
- }
- /// <summary>
- /// 排行榜奖励
- /// </summary>
- private void OnBtnRewardClick()
- {
- }
- private void RenderListItem(int index, GObject obj)
- {
- PoemGalleryData data = PoemGalleryDataManager.Instance.GetGalleryDataById(_galleryIds[index]);
- UI_ListItem item = UI_ListItem.Proxy(obj);
- if (item.m_loaIcon.data == null)
- {
- item.m_loaIcon.onClick.Add(OnLoaIconClick);
- }
- item.m_loaIcon.data = data;
- if (item.m_btnCollect.data == null)
- {
- item.m_btnCollect.onClick.Add(OnBtnCollectClick);
- }
- item.m_btnCollect.data = data;
- if (item.m_btnVote.data == null)
- {
- item.m_btnVote.onClick.Add(OnBtnVoteClick);
- }
- item.m_btnVote.data = data;
- UI_ListItem.ProxyEnd();
- }
- private void RenderListRankItem(int index, GObject obj)
- {
- }
- private void OnLoaIconClick(EventContext context)
- {
- GObject obj = context.data as GObject;
- PoemGalleryData data = obj.data as PoemGalleryData;
- }
- private void OnBtnCollectClick(EventContext context)
- {
- GObject obj = context.data as GObject;
- PoemGalleryData data = obj.data as PoemGalleryData;
- }
- private void OnBtnVoteClick(EventContext context)
- {
- GObject obj = context.data as GObject;
- PoemGalleryData data = obj.data as PoemGalleryData;
- }
- private void onPullDownRelease()
- {
- GComponent header = _ui.m_comNormal.m_listRecommend.scrollPane.header;
- Controller controller = header.GetController("c1");
- controller.selectedIndex = 1;
- _ui.m_comNormal.m_listRecommend.scrollPane.LockHeader(header.sourceHeight);
- Timers.inst.Add(2, 1, (object param) =>
- {
- controller.selectedIndex = 2;
- _ui.m_comNormal.m_listRecommend.scrollPane.LockHeader(0);
- });
- }
- private void OnSizeChanged()
- {
- GComponent header = _ui.m_comNormal.m_listRecommend.scrollPane.header;
- Controller controller = _ui.m_comNormal.m_listRecommend.scrollPane.header.GetController("c1");
- if (header.height <= 1)
- {
- controller.selectedIndex = 0;
- }
- }
- }
- }
|