using System.Collections.Generic;
using ET;
using FairyGUI;
using UI.Poem;
using UnityEngine;
namespace GFGGame
{
class TabType
{
///
/// 首页
///
public static int RECOVER = 0;
///
/// 投稿
///
public static int JOIN = 1;
///
/// 收藏
///
public static int FAVORITES = 2;
}
class RecommendType
{
///
/// 推荐
///
public static int RECOMMEND = 0;
///
/// 好友
///
public static int FRIEND = 1;
///
/// 排行榜
///
public static int RANK = 2;
}
class FavoritesType
{
///
/// 我的收藏
///
public static int FAVORITE = 0;
///
/// 我的作品
///
public static int MY_SELF = 1;
}
public class PoemGalleryView : BaseWindow
{
private UI_PoemGalleryUI _ui;
private GList _list;
private GList _list1;
private GList _scrollList;
private UI_ComScroll _comScroll;
private ScrollPane _curScrollPane;
private GComponent _curFooter;
// private List _galleryDatas = new List();
private List _galleryDatas = new List();
private int _sortType = 0;//由GallerySortType定义
private int _lastGalleryDatasCount = 0;
private int _tabIndex = 0;//当前选中大页签下标,首页0投稿1收藏2
private int _subtabIndex = 0;//当前选中小页签下标,推荐0好友1排行榜2;我的收藏0我的作品1
private bool isPullDown = false;//是否下拉刷新中,刷新中再次下拉不会重新请求更新数据
private bool isPullUp = false;//是否上拉刷新中,刷新中再次下拉不会重新请求更新数据
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;
isReturnView = true;
_ui.m_loaBg.url = ResPathUtil.GetBgImgPath("hc_bj_1");
_ui.m_comNormal.m_comBoBox.items = new string[] { "推荐", "最新" };
_ui.m_comNormal.m_comBoBox.icons = new string[] { "ui://Poem/hl_pxpx", "ui://Poem/hl_zxzx" };
_ui.m_comNormal.m_comBoBox.onChanged.Add(OnNormalTabChange);
_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_comScroll.m_listRecommend.scrollPane.onPullDownRelease.Add(SetPullDownParent0);
_ui.m_comNormal.m_comScroll.m_listRecommend1.scrollPane.onPullDownRelease.Add(SetPullDownParent1);
_ui.m_comNormal.m_comScroll.m_listRecommend.scrollPane.onPullUpRelease.Add(OnPullUpToRefresh);
_ui.m_comNormal.m_comScroll.m_listRecommend1.scrollPane.onPullUpRelease.Add(OnPullUpToRefresh);
_ui.m_comNormal.m_comScroll.m_listRecommend.scrollPane.onScroll.Add(SetScrollCom0);
_ui.m_comNormal.m_comScroll.m_listRecommend1.scrollPane.onScroll.Add(SetScrollCom1);
_ui.m_comNormal.m_comScroll.m_listRecommend.SetVirtual();
_ui.m_comNormal.m_comScroll.m_listRecommend1.SetVirtual();
_ui.m_comNormal.m_comScroll.m_listRecommend.itemRenderer = RenderListItem;
_ui.m_comNormal.m_comScroll.m_listRecommend1.itemRenderer = RenderListItem1;
_ui.m_comNormal.m_comScroll.m_listRecommend.scrollPane.twinsScrollPane = _ui.m_comNormal.m_comScroll.m_listRecommend1.scrollPane;
_ui.m_comNormal.m_comScroll.m_listRecommend1.scrollPane.twinsScrollPane = _ui.m_comNormal.m_comScroll.m_listRecommend.scrollPane;
_ui.m_comFavorites.m_comScroll.m_listRecommend.scrollPane.onPullDownRelease.Add(OnPullDownRelease);
_ui.m_comFavorites.m_comScroll.m_listRecommend1.scrollPane.onPullDownRelease.Add(OnPullDownRelease);
_ui.m_comFavorites.m_comScroll.m_listRecommend.scrollPane.onPullUpRelease.Add(OnPullUpToRefresh);
_ui.m_comFavorites.m_comScroll.m_listRecommend1.scrollPane.onPullUpRelease.Add(OnPullUpToRefresh);
_ui.m_comFavorites.m_comScroll.m_listRecommend.scrollPane.onScroll.Add(SetScrollCom2);
_ui.m_comFavorites.m_comScroll.m_listRecommend1.scrollPane.onScroll.Add(SetScrollCom3);
_ui.m_comFavorites.m_comScroll.m_listRecommend.SetVirtual();
_ui.m_comFavorites.m_comScroll.m_listRecommend1.SetVirtual();
_ui.m_comFavorites.m_comScroll.m_listRecommend.itemRenderer = RenderListItem;
_ui.m_comFavorites.m_comScroll.m_listRecommend1.itemRenderer = RenderListItem1;
_ui.m_comFavorites.m_comScroll.m_listRecommend.scrollPane.twinsScrollPane = _ui.m_comFavorites.m_comScroll.m_listRecommend1.scrollPane;
_ui.m_comFavorites.m_comScroll.m_listRecommend1.scrollPane.twinsScrollPane = _ui.m_comFavorites.m_comScroll.m_listRecommend.scrollPane;
_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_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();
EventAgent.AddEventListener(ConstMessage.GALLERY_DATA_CHANGE, UpdateGalleryList);
EventAgent.AddEventListener(ConstMessage.DOWNLOAD_FINISH_ONE, UpdateGalleryList);
EventAgent.AddEventListener(ConstMessage.DOWNLOAD_FINISH_ONE, UpdateGalleryRankList);
}
protected override async void OnShown()
{
base.OnShown();
if (this.viewData != null)
{
_tabIndex = (int)(this.viewData as object[])[0];
_subtabIndex = (int)(this.viewData as object[])[1];
_ui.m_comNormal.m_comBoBox.selectedIndex = (int)(this.viewData as object[])[2];
UpdateList();
UpdateGalleryList();
UpdateGalleryRankList();
if (_tabIndex == TabType.RECOVER)
{
_ui.m_comNormal.m_c1.selectedIndex = _subtabIndex;
}
else if (_tabIndex == TabType.FAVORITES)
{
_ui.m_comFavorites.m_c1.selectedIndex = _subtabIndex;
}
}
else
{
_tabIndex = TabType.RECOVER;
_subtabIndex = RecommendType.RECOMMEND;
_ui.m_comNormal.m_comBoBox.selectedIndex = 0;
_ui.m_comNormal.m_c1.selectedIndex = _subtabIndex;
_ui.m_comFavorites.m_c1.selectedIndex = _subtabIndex;
// _comScroll = _ui.m_comNormal.m_comScroll.target;
// if (_ui.m_comNormal.m_comScroll.m_listRecommend.numItems > 0) _ui.m_comNormal.m_comScroll.m_listRecommend.ScrollToView(0);
// if (_ui.m_comNormal.m_comScroll.m_listRecommend1.numItems > 0) _ui.m_comNormal.m_comScroll.m_listRecommend1.ScrollToView(0);
// if (_ui.m_comFavorites.m_comScroll.m_listRecommend.numItems > 0) _ui.m_comFavorites.m_comScroll.m_listRecommend.ScrollToView(0);
// if (_ui.m_comFavorites.m_comScroll.m_listRecommend1.numItems > 0) _ui.m_comFavorites.m_comScroll.m_listRecommend1.ScrollToView(0);
_ui.m_comNormal.m_comScroll.m_listRecommend.numItems = 0;
_ui.m_comNormal.m_comScroll.m_listRecommend1.numItems = 0;
_ui.m_comFavorites.m_comScroll.m_listRecommend.numItems = 0;
_ui.m_comFavorites.m_comScroll.m_listRecommend1.numItems = 0;
_scrollList = _ui.m_comNormal.m_comScroll.m_listRecommend;
ViewManager.Show();
UpdateList();
PullDown();
OnPullDownRelease();
}
_ui.m_c1.selectedIndex = _tabIndex;
// _ui.m_comNormal.m_comScroll.m_comHeader.target.y = -_ui.m_comNormal.m_comScroll.m_comHeader.target.height;
// _ui.m_comNormal.m_comScroll.m_comFooter.target.y = _ui.m_comNormal.m_comScroll.target.height;
// _ui.m_comFavorites.m_comScroll.m_comHeader.target.y = -_ui.m_comFavorites.m_comScroll.m_comHeader.target.height;
// _ui.m_comFavorites.m_comScroll.m_comFooter.target.y = _ui.m_comFavorites.m_comScroll.target.height;
_ui.m_comNormal.m_comScroll.m_comHeader.m_grpLoad.visible = true;
_ui.m_comNormal.m_comScroll.m_comFooter.m_grpLoad.visible = true;
_ui.m_comFavorites.m_comScroll.m_comHeader.target.visible = false;
_ui.m_comFavorites.m_comScroll.m_comFooter.m_grpLoad.visible = true;
UpdateView();
if (PoemGalleryDataManager.Instance.HasBonus)
{
bool result = await PoemGallerySProxy.ReqGetGalleryRankBonus();
if (result && PoemGalleryDataManager.Instance.MyWorksRanks.Count > 0)
{
ViewManager.Show();
}
}
}
protected override void OnHide()
{
base.OnHide();
ResetPullRelease();
_ui.m_comNormal.m_comBoBox.selectedIndex = 0;
}
protected override void RemoveEventListener()
{
base.RemoveEventListener();
EventAgent.RemoveEventListener(ConstMessage.GALLERY_DATA_CHANGE, UpdateGalleryList);
EventAgent.RemoveEventListener(ConstMessage.DOWNLOAD_FINISH_ONE, UpdateGalleryList);
EventAgent.RemoveEventListener(ConstMessage.DOWNLOAD_FINISH_ONE, UpdateGalleryRankList);
}
private void OnBtnBackClick()
{
ViewManager.GoBackFrom(typeof(PoemGalleryView).FullName);
}
///
/// 积分商店
///
private void OnBtnShopClick()
{
object[] gobackParamDatas = new object[] { _tabIndex, _subtabIndex, _ui.m_comNormal.m_comBoBox.selectedIndex };
ViewManager.Show(new object[] { ConstStoreTabId.STORE_EXCHANGE, ConstStoreSubId.STORE_EXCHANGE_GALLERY });
}
///
/// 排行榜奖励
///
private void OnBtnRewardClick()
{
ViewManager.Show();
}
/********************************************************页签切换*************************************************/
///
/// 首页
///
private void OnBtnRecoverClick()
{
int lastTabIndex = _tabIndex;
_tabIndex = _ui.m_c1.selectedIndex;
_subtabIndex = _ui.m_comNormal.m_c1.selectedIndex;
if (lastTabIndex == TabType.RECOVER)//当前在推荐页要刷新
{
if (_ui.m_comNormal.m_c1.selectedIndex == RecommendType.RECOMMEND)//重新拉取数据
{
PullDown();
OnPullDownRelease();
}
else//切页签并重新拉取数据
{
_ui.m_comNormal.m_c1.selectedIndex = RecommendType.RECOMMEND;
}
}
else//更新列表
{
_ui.m_comNormal.m_c1.selectedIndex = RecommendType.RECOMMEND;
UpdateList();
UpdateGalleryList();
}
}
///
/// 投稿
///
private void OnBtnJoinClick()
{
object[] gobackParamDatas = new object[] { _tabIndex, _subtabIndex, _ui.m_comNormal.m_comBoBox.selectedIndex };
ViewManager.Show(1,false);
}
///
///收藏夹
///
private void OnBtnFavoritesClick()
{
if (_tabIndex == TabType.FAVORITES) return;
ResetPullRelease();
_tabIndex = _ui.m_c1.selectedIndex;
_ui.m_comFavorites.m_c1.selectedIndex = FavoritesType.FAVORITE;
_subtabIndex = _ui.m_comFavorites.m_c1.selectedIndex;
OnFavoritesTabChange();
}
///
/// 切换首页页签
///
private void OnNormalTabChange()
{
ResetPullRelease();
// _ui.m_comNormal.m_comScroll.target.scrollPane.header.visible = false;
_subtabIndex = _ui.m_comNormal.m_c1.selectedIndex;
if (_ui.m_comNormal.m_c1.selectedIndex == RecommendType.RANK)//排行榜
{
_galleryDatas = PoemGalleryDataManager.Instance.RankDatas;
if (_ui.m_comNormal.m_listRank.numItems > 0) _ui.m_comNormal.m_listRank.ScrollToView(0);
ReqGalleryRankList();
}
else
{
UpdateList();
_list.numItems = 0;
_list1.numItems = 0;
if (_list.numItems > 0) _list.ScrollToView(0);
if (_list1.numItems > 0) _list.ScrollToView(0);
ReqGalleryList(0);
}
}
///
/// 切换收藏页签
///
private void OnFavoritesTabChange()
{
_subtabIndex = _ui.m_comFavorites.m_c1.selectedIndex;
UpdateList();
_list.numItems = 0;
_list1.numItems = 0;
ReqGalleryList(0);
}
private void UpdateList()
{
ResetPullRelease();
if (_tabIndex == TabType.RECOVER)
{
_ui.m_comNormal.m_comScroll.m_comHeader.target.visible = true;
if (_subtabIndex == RecommendType.RECOMMEND)//首页
{
// _ui.m_comNormal.m_comScroll.target.scrollPane.header.visible = true;
if (_ui.m_comNormal.m_comBoBox.selectedIndex == 0)//推荐
{
_sortType = (int)GallerySortType.Recommend;
_galleryDatas = PoemGalleryDataManager.Instance.RecommendDatas;
}
else//最新
{
_sortType = (int)GallerySortType.Newest;
_galleryDatas = PoemGalleryDataManager.Instance.NewestDatas;
}
}
else if (_subtabIndex == RecommendType.FRIEND)//好友
{
_sortType = (int)GallerySortType.Friend;
_galleryDatas = PoemGalleryDataManager.Instance.FrinedDatas;
_ui.m_comNormal.m_comScroll.m_comHeader.target.visible = false;
}
else if (_subtabIndex == RecommendType.RANK)
{
_galleryDatas = PoemGalleryDataManager.Instance.RankDatas;
}
_list = _ui.m_comNormal.m_comScroll.m_listRecommend;
_list1 = _ui.m_comNormal.m_comScroll.m_listRecommend1;
_comScroll = _ui.m_comNormal.m_comScroll;
// _curScrollPane = _ui.m_comNormal.m_comScroll.m_listRecommend.scrollPane;
}
else if (_tabIndex == TabType.FAVORITES)
{
if (_subtabIndex == FavoritesType.FAVORITE)//我的收藏
{
_sortType = (int)GallerySortType.MyCollect;
_galleryDatas = PoemGalleryDataManager.Instance.FavoriteDatas;
}
else if (_subtabIndex == FavoritesType.MY_SELF)//我的作品
{
_sortType = (int)GallerySortType.MyWorks;
_galleryDatas = PoemGalleryDataManager.Instance.MySelfDatas;
}
_list = _ui.m_comFavorites.m_comScroll.m_listRecommend;
_list1 = _ui.m_comFavorites.m_comScroll.m_listRecommend1;
_comScroll = _ui.m_comFavorites.m_comScroll;
if (_list.numItems > 0) _list.ScrollToView(0);
if (_list1.numItems > 0) _list1.ScrollToView(0);
}
}
/********************************************************请求更新列表*************************************************/
//请求刷新
private async void ReqGalleryList(int startIndex)
{
if (PoemGalleryDataManager.Instance.IsResulting())
{
if (_sortType == (int)GallerySortType.Recommend || _sortType == (int)GallerySortType.Newest || _sortType == (int)GallerySortType.Friend)
{
return;
}
}
bool result = await PoemGallerySProxy.ReqGalleryList(_sortType, startIndex, PoemGalleryDataManager.pageCount);
if (result)
{
Timers.inst.StartCoroutine(PictureStorageHelper.Download(_galleryDatas, startIndex, UpdateGalleryList));
}
}
private void UpdateGalleryList()
{
if (_tabIndex == TabType.RECOVER && _subtabIndex == RecommendType.RANK)
{
_ui.m_comNormal.m_listRank.numItems = _galleryDatas.Count;
}
else
{
if (_galleryDatas.Count % 2 == 0)
{
_list.numItems = _galleryDatas.Count / 2;
_list1.numItems = _galleryDatas.Count / 2;
}
else
{
_list.numItems = (_galleryDatas.Count + 1) / 2;
_list1.numItems = (_galleryDatas.Count - 1) / 2;
}
}
UpdateView();
ResetPullRelease();
}
//请求排行榜刷新
private async void ReqGalleryRankList()
{
if (PoemGalleryDataManager.Instance.IsResulting())
{
return;
}
bool result = await PoemGallerySProxy.ReqRankList();
if (result)
{
Timers.inst.StartCoroutine(PictureStorageHelper.Download(_galleryDatas, 0, UpdateGalleryRankList));
}
}
private void UpdateGalleryRankList()
{
if (_tabIndex != TabType.RECOVER || _subtabIndex != RecommendType.RANK) return;
// if (_ui.m_comNormal.m_listRank.numItems > 0) _ui.m_comNormal.m_listRank.ScrollToView(0);
_ui.m_comNormal.m_listRank.numItems = _galleryDatas.Count;
UpdateView();
}
/********************************************************界面更新*************************************************/
private void UpdateView()
{
bool isResulting = PoemGalleryDataManager.Instance.IsResulting();
_ui.m_comNormal.m_grpResult.visible = isResulting;
// _ui.m_comNormal.m_comScroll.target.visible = !isResulting;
_ui.m_comNormal.m_listRank.visible = !isResulting;
GalleryThemeCfg themeCfg = GalleryThemeCfgArray.Instance.GetCfg((int)PoemGalleryDataManager.Instance.ThemeId);
_ui.m_comNormal.m_txtTheme.text = string.Format("本期主题:{0}", themeCfg.theme);
_ui.m_comNormal.m_txtRank.text = string.Format("我的排名: {0}", PoemGalleryDataManager.Instance.MyRank > 0 && !isResulting ? PoemGalleryDataManager.Instance.MyRank.ToString() : "- -");
int curCount = GameGlobal.myNumericComponent.GetAsInt(NumericType.LikeGalleryWorksCountDaily);
int maxCount = GalleryIntegralCfgArray.Instance.dataArray.Length;
_ui.m_comNormal.m_txtRewardCount.text = string.Format("奖励次数:{0}/{1}", Mathf.Min(curCount, maxCount), maxCount);
_ui.m_comNormal.m_txtTime.text = string.Format("截止日期:{0}", PoemGalleryDataManager.Instance.GetThemeTime());
}
private void RenderListItem(int index, GObject obj)
{
long workId = _galleryDatas[index * 2];
UpdateListItem(workId, obj);
}
private void RenderListItem1(int index, GObject obj)
{
long workId = _galleryDatas[index * 2 + 1];
UpdateListItem(workId, obj);
}
private void UpdateListItem(long workId, GObject obj)
{
PoemGalleryData data = PoemGalleryDataManager.Instance.GetGalleryDataById(workId);
UI_ListItem item = UI_ListItem.Proxy(obj);
item.m_c1.selectedIndex = 0;
if (data.Ntexture == null) return;
item.m_c1.selectedIndex = 1;
item.m_loaIcon.texture = data.Ntexture;
item.m_loaIcon.height = item.m_loaIcon.width * item.m_loaIcon.texture.height / item.m_loaIcon.texture.width;
item.m_txtName.text = data.AuthorName;
item.m_btnCollect.title = data.CollectCount.ToString();
item.m_btnCollect.selected = data.CollectOrNot;
item.m_btnVote.title = data.VoteCount.ToString();
item.m_btnVote.selected = data.VoteOrNot;
if (item.m_loaIcon.data == null)
{
item.m_loaIcon.onClick.Add(OnLoaIconClick);
}
item.m_loaIcon.data = workId;
if (item.m_btnCollect.data == null)
{
item.m_btnCollect.onClick.Add(OnBtnCollectClick);
}
item.m_btnCollect.data = workId;
if (item.m_btnVote.data == null)
{
item.m_btnVote.onClick.Add(OnBtnVoteClick);
}
item.m_btnVote.data = workId;
UI_ListItem.ProxyEnd();
}
private void RenderListRankItem(int index, GObject obj)
{
long workId = _galleryDatas[index];
PoemGalleryData data = PoemGalleryDataManager.Instance.GetGalleryDataById(workId);
UI_ListRankItem item = UI_ListRankItem.Proxy(obj);
if (data.Ntexture == null) return;
item.m_loaIcon.texture = data.Ntexture;
item.m_loaIcon.height = item.m_loaIcon.width * item.m_loaIcon.texture.height / item.m_loaIcon.texture.width;
item.m_txtName.text = data.AuthorName;
item.m_btnCollect.title = data.CollectCount.ToString();
item.m_btnCollect.selected = data.CollectOrNot;
item.m_btnVote.title = data.VoteCount.ToString();
item.m_btnVote.selected = data.VoteOrNot;
item.m_txtRank.text = data.Rank.ToString();
item.m_c1.selectedIndex = index < 3 ? index : 3;
if (item.m_loaIcon.data == null)
{
item.m_loaIcon.onClick.Add(OnLoaIconClick);
}
item.m_loaIcon.data = workId;
if (item.m_btnCollect.data == null)
{
item.m_btnCollect.onClick.Add(OnBtnCollectClick);
}
item.m_btnCollect.data = workId;
if (item.m_btnVote.data == null)
{
item.m_btnVote.onClick.Add(OnBtnVoteClick);
}
item.m_btnVote.data = workId;
UI_ListRankItem.ProxyEnd();
}
private void OnLoaIconClick(EventContext context)
{
GObject obj = context.sender as GObject;
long workId = (long)obj.data;
object[] gobackParamDatas = new object[] { _tabIndex, _subtabIndex, _ui.m_comNormal.m_comBoBox.selectedIndex };
ViewManager.Show(new object[] { _sortType, workId });
}
private async void OnBtnCollectClick(EventContext context)
{
GObject obj = context.sender as GObject;
long workId = (long)obj.data;
PoemGalleryData galleryData = PoemGalleryDataManager.Instance.GetGalleryDataById(workId);
if (galleryData.CollectOrNot)
{
bool result = await PoemGallerySProxy.ReqCancelCollecteGalleryWorks(workId);
if (result)
{
if (_tabIndex == TabType.FAVORITES && _subtabIndex == FavoritesType.FAVORITE)
{
ReqGalleryList(0);//当前为收藏页要重新拉取数据
}
else
{
UpdateGalleryList();
}
}
}
else
{
bool result = await PoemGallerySProxy.ReqCollecteGalleryWorks(workId);
if (result)
{
if (_tabIndex == TabType.FAVORITES && _subtabIndex == FavoritesType.FAVORITE)
{
ReqGalleryList(0);//当前为收藏页要重新拉取数据
}
else
{
UpdateGalleryList();
}
}
}
}
private async void OnBtnVoteClick(EventContext context)
{
GButton obj = context.sender as GButton;
long workId = (long)obj.data;
PoemGalleryData galleryData = PoemGalleryDataManager.Instance.GetGalleryDataById(workId);
if (galleryData.VoteOrNot) return;
if (PoemGalleryDataManager.Instance.IsResulting())
{
obj.selected = galleryData.VoteOrNot;
PromptController.Instance.ShowFloatTextPrompt("排行榜数据正在结算,无法操作");
return;
}
if (!PoemGalleryDataManager.Instance.IsCurThemeWork(galleryData.CreateTime))
{
obj.selected = galleryData.VoteOrNot;
PromptController.Instance.ShowFloatTextPrompt("往期作品,无法操作");
return;
}
bool result = await PoemGallerySProxy.ReqVoteGalleryWorks(workId);
if (result)
{
UpdateGalleryList();
int Count = GameGlobal.myNumericComponent.GetAsInt(NumericType.LikeGalleryWorksCountDaily);
GalleryIntegralCfg integralCfg = GalleryIntegralCfgArray.Instance.GetCfg(Count);
if (integralCfg != null)
{
ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(integralCfg.itemId);
PromptController.Instance.ShowFloatTextPrompt(string.Format("{0} +{1}", itemCfg.name, integralCfg.Count));
}
}
}
/********************************************************下拉刷新*************************************************/
//自动下拉
private void PullDown()
{
if (_list.numItems > 0) _list.ScrollToView(0);
_curScrollPane = _list.scrollPane;
_curScrollPane.header.height = _curScrollPane.header.sourceHeight;
}
private void SetScrollCom0()
{
_scrollList = _ui.m_comNormal.m_comScroll.m_listRecommend;
UpdateHeaderPos(_ui.m_comNormal.m_comScroll.m_comHeader.target, _ui.m_comNormal.m_comScroll.m_comFooter.target, _ui.m_comNormal.m_comScroll.m_listRecommend);
}
private void SetScrollCom1()
{
_scrollList = _ui.m_comNormal.m_comScroll.m_listRecommend1;
UpdateHeaderPos(_ui.m_comNormal.m_comScroll.m_comHeader.target, _ui.m_comNormal.m_comScroll.m_comFooter.target, _ui.m_comNormal.m_comScroll.m_listRecommend1);
}
private void SetScrollCom2()
{
_scrollList = _ui.m_comFavorites.m_comScroll.m_listRecommend;
UpdateHeaderPos(null, _ui.m_comFavorites.m_comScroll.m_comFooter.target, _ui.m_comFavorites.m_comScroll.m_listRecommend);
}
private void SetScrollCom3()
{
_scrollList = _ui.m_comFavorites.m_comScroll.m_listRecommend1;
UpdateHeaderPos(null, _ui.m_comFavorites.m_comScroll.m_comFooter.target, _ui.m_comFavorites.m_comScroll.m_listRecommend1);
}
private void UpdateHeaderPos(GComponent header, GComponent footer, GList list)
{
if (header != null && list.scrollPane.container.y > 0)
{
header.height = list.scrollPane.header.height;
}
else if (footer != null && list.scrollPane.container.y < -list.scrollPane.posY)
{
footer.height = list.scrollPane.footer.height;
}
}
private void SetPullDownParent0()
{
_curScrollPane = _ui.m_comNormal.m_comScroll.m_listRecommend.scrollPane;
OnPullDownRelease();
}
private void SetPullDownParent1()
{
_curScrollPane = _ui.m_comNormal.m_comScroll.m_listRecommend1.scrollPane;
OnPullDownRelease();
}
//下拉刷新
private async void OnPullDownRelease()
{
if (!_comScroll.m_comHeader.target.visible || _scrollList.scrollPane.header.height < _scrollList.scrollPane.header.sourceHeight || isPullDown) return;
isPullDown = true;
_scrollList.scrollPane.LockHeader(_scrollList.scrollPane.header.sourceHeight);
bool result = await PoemGallerySProxy.ReqGalleryList(_sortType, 0, PoemGalleryDataManager.pageCount);
// OnPullDownTimeComplete();
if (result)
{
Timers.inst.StartCoroutine(PictureStorageHelper.Download(_galleryDatas, 0, UpdateGalleryList));
}
}
private void OnPullDownTimeComplete()
{
if (_scrollList == null) return;
GComponent header = _scrollList.scrollPane.header;
Transition transition = header.GetTransition("t0");
transition.Stop();
_scrollList.scrollPane.LockHeader(0);
isPullDown = false;
}
//上拉刷新
private async void OnPullUpToRefresh()
{
GComponent header = _scrollList.scrollPane.header;
if (!header.visible || header.height > header.sourceHeight || isPullDown) return;
GComponent footer = _scrollList.scrollPane.footer;
if (footer.height <= footer.sourceHeight || isPullUp) return;
_lastGalleryDatasCount = _galleryDatas.Count;
isPullUp = true;
_scrollList.scrollPane.LockFooter(footer.sourceHeight + 10);
bool result = await PoemGallerySProxy.ReqGalleryList(_sortType, _galleryDatas.Count, PoemGalleryDataManager.pageCount);
if (result)
{
Timers.inst.StartCoroutine(PictureStorageHelper.Download(_galleryDatas, _lastGalleryDatasCount, UpdateGalleryList));
}
}
private void OnPullUpTimeComplete()
{
if (_scrollList == null) return;
GComponent footer = _scrollList.scrollPane.footer;
Transition transition = footer.GetTransition("t0");
transition.Stop();
_scrollList.scrollPane.LockFooter(0);
isPullUp = false;
_ui.m_comNormal.m_comScroll.m_comFooter.target.height = footer.initHeight;
_ui.m_comFavorites.m_comScroll.m_comFooter.target.height = footer.initHeight;
}
//重置上拉/下拉刷新状态
private void ResetPullRelease()
{
OnPullDownTimeComplete();
OnPullUpTimeComplete();
ViewManager.Hide();
}
}
}