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 _galleryInfos = new List(); 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(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) { } } }