备份CatanBuilding瘦身独立工程
This commit is contained in:
711
Assets/Scripts/UI/Social/Friend/FishingFriendAddPanel.cs
Normal file
711
Assets/Scripts/UI/Social/Friend/FishingFriendAddPanel.cs
Normal file
@@ -0,0 +1,711 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using EnhancedUI.EnhancedScroller;
|
||||
using GameCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityNative.Sharing;
|
||||
|
||||
namespace game
|
||||
{
|
||||
public class FishingFriendAddPanel : BasePanel, IEnhancedScrollerDelegate
|
||||
{
|
||||
|
||||
#region 分享
|
||||
Button btn_invite;
|
||||
GameObject icon_gift_invite;
|
||||
#endregion
|
||||
GameObject empty;
|
||||
GameObject loading;
|
||||
Button btn_add;
|
||||
// 好友码相关
|
||||
TMP_Text text_code;
|
||||
Button btn_copy;
|
||||
Button btn_share;
|
||||
// ScrollView相关
|
||||
EnhancedScroller scroller;
|
||||
public FriendInvitedItemTitleBar invitedItemTitleBar;
|
||||
public FriendInvitedItem invitedItem;
|
||||
public FriendRecommendedItemTitleBar recommendedItemTitleBar;
|
||||
public FriendRecommendedItem recommendedItem;
|
||||
|
||||
List<FriendAddItemData> m_DataList = new List<FriendAddItemData>();
|
||||
List<FriendAddItemData> m_InvitedDataList = new List<FriendAddItemData>();
|
||||
FriendRecommendedListData m_RecommendedListData;
|
||||
|
||||
int m_PageNo = 0;
|
||||
|
||||
#region 后台网络处理
|
||||
private List<FriendAddPanelBackendOperation> m_BackendOperationList = new List<FriendAddPanelBackendOperation>();
|
||||
|
||||
#endregion
|
||||
|
||||
private IUnityNativeSharing adapter;
|
||||
|
||||
#region 主页处理 / 空白搜索处理
|
||||
private async Task InitDefault()
|
||||
{
|
||||
m_DataList.Clear();
|
||||
m_InvitedDataList.Clear();
|
||||
if (m_RecommendedListData != null && m_RecommendedListData.RecommendedList != null)
|
||||
{
|
||||
m_RecommendedListData.RecommendedList.Clear();
|
||||
}
|
||||
if (IsExpire())
|
||||
{
|
||||
// 获取HomePage数据
|
||||
string json = await GContext.container.Resolve<FriendService>().GetHomePage(GContext.container.Resolve<IUserService>().UserId, m_PageNo);
|
||||
bool flag = true;
|
||||
if (string.IsNullOrEmpty(json))
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
GetHomePageResp getHomePageResp = null;
|
||||
if (flag == true)
|
||||
{
|
||||
try
|
||||
{
|
||||
getHomePageResp = Newtonsoft.Json.JsonConvert.DeserializeObject<GetHomePageResp>(json);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
GameDebug.LogError("FishingFriendAddPanel deserialize [GetHomePageResp] data has failed. Exception: " + ex.ToString());
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
|
||||
m_DataList.Clear();
|
||||
if (flag == false)
|
||||
{
|
||||
scroller.gameObject.SetActive(false);
|
||||
empty.SetActive(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (getHomePageResp.Code > 0)
|
||||
{
|
||||
List<BFriendInfo> list = new List<BFriendInfo>();
|
||||
if (getHomePageResp.Friends != null)
|
||||
{
|
||||
foreach (var item in getHomePageResp.Friends)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(item))
|
||||
{
|
||||
BFriendInfo info = Newtonsoft.Json.JsonConvert.DeserializeObject<BFriendInfo>(item);
|
||||
FriendHelper.FixBFriendInfoData(info);
|
||||
list.Add(info);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (list.Count > 0)
|
||||
{
|
||||
// InvitedItem TitleBar Data
|
||||
var invitedTitleBarData = new FriendAddItemData()
|
||||
{
|
||||
Type = FriendHelper.Friend_Add_Item_Type_Invited_TitleBar,
|
||||
FriendInfo = null,
|
||||
Extra = 0
|
||||
};
|
||||
m_InvitedDataList.Add(invitedTitleBarData);
|
||||
m_DataList.Add(invitedTitleBarData);
|
||||
|
||||
// InvitedItem Data
|
||||
foreach (var item in list)
|
||||
{
|
||||
var invitedItemData = new FriendAddItemData()
|
||||
{
|
||||
Type = FriendHelper.Friend_Add_Item_Type_Invited_Item,
|
||||
FriendInfo = item,
|
||||
Extra = 0
|
||||
};
|
||||
m_DataList.Add(invitedItemData);
|
||||
m_InvitedDataList.Add(invitedItemData);
|
||||
}
|
||||
}
|
||||
|
||||
if (getHomePageResp.RecommendedList != null && getHomePageResp.RecommendedList.Length > 0)
|
||||
{
|
||||
if (m_RecommendedListData != null && m_RecommendedListData.RecommendedList != null)
|
||||
{
|
||||
m_RecommendedListData.RecommendedList.Clear();
|
||||
}
|
||||
m_RecommendedListData = new FriendRecommendedListData();
|
||||
m_RecommendedListData.RecommendedList = new List<FriendAddItemData>();
|
||||
m_RecommendedListData.ExpirationDate = DateTime.Now.AddDays(3);
|
||||
|
||||
// RecommendedItem TitleBar Data
|
||||
var recommendedTitleBarData = new FriendAddItemData()
|
||||
{
|
||||
Type = FriendHelper.Friend_Add_Item_Type_Recommended_TitleBar,
|
||||
FriendInfo = null,
|
||||
Extra = 0
|
||||
};
|
||||
m_RecommendedListData.RecommendedList.Add(recommendedTitleBarData);
|
||||
m_DataList.Add(recommendedTitleBarData);
|
||||
|
||||
// RecommendedItem Data
|
||||
foreach (var item in getHomePageResp.RecommendedList)
|
||||
{
|
||||
var recommendedItemData = new FriendAddItemData()
|
||||
{
|
||||
Type = FriendHelper.Friend_Add_Item_Type_Recommended_Item,
|
||||
FriendInfo = item,
|
||||
Extra = 0
|
||||
};
|
||||
m_RecommendedListData.RecommendedList.Add(recommendedItemData);
|
||||
m_DataList.Add(recommendedItemData);
|
||||
}
|
||||
SyncRecommendedListData();
|
||||
}
|
||||
}
|
||||
if (m_DataList.Count > 0)
|
||||
{
|
||||
scroller.gameObject.SetActive(true);
|
||||
empty.SetActive(false);
|
||||
scroller.ReloadData();
|
||||
}
|
||||
else
|
||||
{
|
||||
scroller.gameObject.SetActive(false);
|
||||
empty.SetActive(true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 获取邀请列表数据,再合并推荐列表数据
|
||||
string json = await GContext.container.Resolve<FriendService>().GetInvitedList();
|
||||
bool flag = true;
|
||||
if (string.IsNullOrEmpty(json))
|
||||
{
|
||||
flag = false;
|
||||
|
||||
}
|
||||
GetInvitedListResp getInvitedListResp = null;
|
||||
if (flag == true)
|
||||
{
|
||||
try
|
||||
{
|
||||
getInvitedListResp = Newtonsoft.Json.JsonConvert.DeserializeObject<GetInvitedListResp>(json);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
GameDebug.LogError("FishingFriendAddPanel deserialize [GetInvitedListResp] data has failed. Exception: " + ex.ToString());
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
|
||||
m_DataList.Clear();
|
||||
if (flag == false)
|
||||
{
|
||||
scroller.gameObject.SetActive(false);
|
||||
empty.SetActive(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (getInvitedListResp.Code > 0)
|
||||
{
|
||||
List<BFriendInfo> list = new List<BFriendInfo>();
|
||||
if (getInvitedListResp.Friends != null)
|
||||
{
|
||||
foreach (var item in getInvitedListResp.Friends)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(item))
|
||||
{
|
||||
BFriendInfo info = Newtonsoft.Json.JsonConvert.DeserializeObject<BFriendInfo>(item);
|
||||
FriendHelper.FixBFriendInfoData(info);
|
||||
list.Add(info);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (list.Count > 0)
|
||||
{
|
||||
// InvitedItem TitleBar Data
|
||||
var invitedTitleBarData = new FriendAddItemData()
|
||||
{
|
||||
Type = FriendHelper.Friend_Add_Item_Type_Invited_TitleBar,
|
||||
FriendInfo = null,
|
||||
Extra = 0
|
||||
};
|
||||
m_InvitedDataList.Add(invitedTitleBarData);
|
||||
m_DataList.Add(invitedTitleBarData);
|
||||
|
||||
// InvitedItem Data
|
||||
foreach (var item in list)
|
||||
{
|
||||
var invitedItemData = new FriendAddItemData()
|
||||
{
|
||||
Type = FriendHelper.Friend_Add_Item_Type_Invited_Item,
|
||||
FriendInfo = item,
|
||||
Extra = 0
|
||||
};
|
||||
m_InvitedDataList.Add(invitedItemData);
|
||||
m_DataList.Add(invitedItemData);
|
||||
}
|
||||
}
|
||||
if (m_RecommendedListData != null && m_RecommendedListData.RecommendedList != null)
|
||||
{
|
||||
m_DataList.AddRange(m_RecommendedListData.RecommendedList.ToArray());
|
||||
}
|
||||
}
|
||||
if (m_DataList.Count > 0)
|
||||
{
|
||||
scroller.gameObject.SetActive(true);
|
||||
scroller.ReloadData();
|
||||
empty.SetActive(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
scroller.gameObject.SetActive(false);
|
||||
empty.SetActive(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsExpire()
|
||||
{
|
||||
if (PlayerPrefs.HasKey(FriendHelper.FriendRecommendedListDataKey) == false) return true;
|
||||
string data = PlayerPrefs.GetString(FriendHelper.FriendRecommendedListDataKey);
|
||||
if (string.IsNullOrEmpty(data)) return true;
|
||||
|
||||
m_RecommendedListData = Newtonsoft.Json.JsonConvert.DeserializeObject<FriendRecommendedListData>(data);
|
||||
if (m_RecommendedListData == null) return true;
|
||||
|
||||
if (DateTime.Now < m_RecommendedListData.ExpirationDate) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void SyncRecommendedListData()
|
||||
{
|
||||
lock (m_RecommendedListData)
|
||||
{
|
||||
if (m_RecommendedListData == null)
|
||||
{
|
||||
if (PlayerPrefs.HasKey(FriendHelper.FriendRecommendedListDataKey))
|
||||
{
|
||||
PlayerPrefs.DeleteKey(FriendHelper.FriendRecommendedListDataKey);
|
||||
}
|
||||
return;
|
||||
}
|
||||
PlayerPrefs.SetString(FriendHelper.FriendRecommendedListDataKey, Newtonsoft.Json.JsonConvert.SerializeObject(m_RecommendedListData));
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 数据相关
|
||||
List<FriendAddPanelBackendOperation> m_RecommendedBackendOperationList = new List<FriendAddPanelBackendOperation>();
|
||||
public void StartRecommendedInvite(FriendAddItemData data)
|
||||
{
|
||||
var backendOperation = new FriendAddPanelBackendOperation();
|
||||
|
||||
m_RecommendedBackendOperationList.Add(backendOperation);
|
||||
|
||||
backendOperation.StartRecommendedInvite(this, data, ResumeRecommendedData);
|
||||
|
||||
RemoveRecommendedData(data);
|
||||
}
|
||||
public void ResumeRecommendedData(FriendAddItemData data)
|
||||
{
|
||||
if (data == null) return;
|
||||
if (m_RecommendedBackendOperationList == null || m_RecommendedBackendOperationList.Count < 1) return;
|
||||
|
||||
bool flag = false;
|
||||
int count = m_RecommendedBackendOperationList.Count;
|
||||
for (int i = count - 1; i >= 0; --i)
|
||||
{
|
||||
var item = m_RecommendedBackendOperationList[i];
|
||||
if (item != null && item.Data != null && item.Data.EqualsPlayFabId(data))
|
||||
{
|
||||
flag = true;
|
||||
m_RecommendedBackendOperationList.RemoveAt(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!flag) return;
|
||||
|
||||
if (m_RecommendedListData == null || m_RecommendedListData.RecommendedList == null) return;
|
||||
|
||||
m_RecommendedListData.RecommendedList.Add(data);
|
||||
|
||||
CombineData();
|
||||
|
||||
RedPointManager.Instance.SetRedPointState(RedPointName.Home_Friend_Add, m_InvitedDataList.Count > 0);
|
||||
}
|
||||
public void RemoveRecommendedData(FriendAddItemData data)
|
||||
{
|
||||
if (m_RecommendedListData == null || m_RecommendedListData.RecommendedList == null) return;
|
||||
|
||||
lock (m_RecommendedListData.RecommendedList)
|
||||
{
|
||||
for (int i = m_InvitedDataList.Count - 1; i >= 0; --i)
|
||||
{
|
||||
var tmpData = m_InvitedDataList[i];
|
||||
if (tmpData.EqualsPlayFabId(data))
|
||||
{
|
||||
m_InvitedDataList.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
for (int i = m_RecommendedListData.RecommendedList.Count - 1; i >= 0; --i)
|
||||
{
|
||||
var tmpData = m_RecommendedListData.RecommendedList[i];
|
||||
if (tmpData.EqualsPlayFabId(data))
|
||||
{
|
||||
m_RecommendedListData.RecommendedList.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_InvitedDataList.Count <= 1)
|
||||
{
|
||||
for (int i = m_InvitedDataList.Count - 1; i >= 0; --i)
|
||||
{
|
||||
var tmpData = m_InvitedDataList[i];
|
||||
if (tmpData.Type == FriendHelper.Friend_Add_Item_Type_Invited_TitleBar)
|
||||
{
|
||||
m_InvitedDataList.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (m_RecommendedListData.RecommendedList.Count <= 1)
|
||||
{
|
||||
for (int i = m_RecommendedListData.RecommendedList.Count - 1; i >= 0; --i)
|
||||
{
|
||||
var tmpData = m_RecommendedListData.RecommendedList[i];
|
||||
if (tmpData.Type == FriendHelper.Friend_Add_Item_Type_Recommended_TitleBar)
|
||||
{
|
||||
m_RecommendedListData.RecommendedList.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SyncRecommendedListData();
|
||||
|
||||
CombineData();
|
||||
|
||||
RedPointManager.Instance.SetRedPointState(RedPointName.Home_Friend_Add, m_InvitedDataList.Count > 0);
|
||||
}
|
||||
|
||||
List<FriendAddPanelBackendOperation> m_InvitedBackendOperationList = new List<FriendAddPanelBackendOperation>();
|
||||
public void StartInvitedAccept(FriendAddItemData data)
|
||||
{
|
||||
var backendOperation = new FriendAddPanelBackendOperation();
|
||||
|
||||
m_InvitedBackendOperationList.Add(backendOperation);
|
||||
|
||||
backendOperation.StartInvitedAccept(this, data, ResumeInvitedData);
|
||||
|
||||
RemoveInvitedData(data);
|
||||
}
|
||||
public void StartInvitedIgnore(FriendAddItemData data)
|
||||
{
|
||||
var backendOperation = new FriendAddPanelBackendOperation();
|
||||
|
||||
m_RecommendedBackendOperationList.Add(backendOperation);
|
||||
|
||||
backendOperation.StartInvitedIgnore(this, data, ResumeInvitedData);
|
||||
|
||||
RemoveInvitedData(data);
|
||||
}
|
||||
public void ResumeInvitedData(FriendAddItemData data)
|
||||
{
|
||||
if (data == null) return;
|
||||
if (m_InvitedBackendOperationList == null || m_InvitedBackendOperationList.Count < 1) return;
|
||||
|
||||
bool flag = false;
|
||||
int count = m_InvitedBackendOperationList.Count;
|
||||
for (int i = count - 1; i >= 0; --i)
|
||||
{
|
||||
var item = m_InvitedBackendOperationList[i];
|
||||
if (item != null && item.Data != null && item.Data.EqualsPlayFabId(data))
|
||||
{
|
||||
flag = true;
|
||||
m_InvitedBackendOperationList.RemoveAt(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!flag) return;
|
||||
|
||||
if (m_InvitedDataList == null) return;
|
||||
|
||||
m_InvitedDataList.Add(data);
|
||||
|
||||
CombineData();
|
||||
|
||||
RedPointManager.Instance.SetRedPointState(RedPointName.Home_Friend_Add, m_InvitedDataList.Count > 0);
|
||||
}
|
||||
public void RemoveInvitedData(FriendAddItemData data)
|
||||
{
|
||||
if (m_InvitedDataList == null) return;
|
||||
|
||||
lock (m_InvitedDataList)
|
||||
{
|
||||
for (int i = m_InvitedDataList.Count - 1; i >= 0; --i)
|
||||
{
|
||||
var tmpData = m_InvitedDataList[i];
|
||||
if (tmpData.EqualsPlayFabId(data))
|
||||
{
|
||||
m_InvitedDataList.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
for (int i = m_RecommendedListData.RecommendedList.Count - 1; i >= 0; --i)
|
||||
{
|
||||
var tmpData = m_RecommendedListData.RecommendedList[i];
|
||||
if (tmpData.EqualsPlayFabId(data))
|
||||
{
|
||||
m_RecommendedListData.RecommendedList.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_InvitedDataList.Count <= 1)
|
||||
{
|
||||
m_InvitedDataList.Clear();
|
||||
}
|
||||
if (m_RecommendedListData.RecommendedList.Count <= 1)
|
||||
{
|
||||
m_RecommendedListData.RecommendedList.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
CombineData();
|
||||
|
||||
GContext.container.Resolve<FriendService>().GetInvitedListCount();
|
||||
RedPointManager.Instance.SetRedPointState(RedPointName.Home_Friend_Add, m_InvitedDataList.Count > 0);
|
||||
}
|
||||
public void CombineData()
|
||||
{
|
||||
lock (m_DataList)
|
||||
{
|
||||
m_DataList.Clear();
|
||||
if (m_InvitedDataList != null && m_InvitedDataList.Count > 1)
|
||||
{
|
||||
m_DataList.AddRange(m_InvitedDataList.ToArray());
|
||||
}
|
||||
if (m_RecommendedListData != null && m_RecommendedListData.RecommendedList != null && m_RecommendedListData.RecommendedList.Count > 1)
|
||||
{
|
||||
m_DataList.AddRange(m_RecommendedListData.RecommendedList.ToArray());
|
||||
}
|
||||
}
|
||||
|
||||
if (m_DataList.Count > 0)
|
||||
{
|
||||
scroller.gameObject.SetActive(true);
|
||||
empty.SetActive(false);
|
||||
var position = scroller.ScrollPosition;
|
||||
scroller.ReloadData();
|
||||
scroller.ScrollPosition = position;
|
||||
}
|
||||
else
|
||||
{
|
||||
scroller.gameObject.SetActive(false);
|
||||
empty.SetActive(true);
|
||||
}
|
||||
}
|
||||
private void UpdateLockAction(float deltaTime)
|
||||
{
|
||||
if (m_LockScrollViewCumulativeTime > 0)
|
||||
{
|
||||
m_LockScrollViewCumulativeTime -= deltaTime;
|
||||
}
|
||||
if (m_LockScrollViewCumulativeTime < 0)
|
||||
{
|
||||
m_LockScrollViewCumulativeTime = 0f;
|
||||
UnlockScrollView();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region UI相关
|
||||
|
||||
private void OnBtnCopyClick()
|
||||
{
|
||||
GUIUtility.systemCopyBuffer = text_code.text;
|
||||
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_25"));
|
||||
}
|
||||
|
||||
void OnClickInviteLink()
|
||||
{
|
||||
if (adapter == null)
|
||||
{
|
||||
adapter = UnityNativeSharing.Create();
|
||||
}
|
||||
string invite = LocalizationMgr.GetFormatTextValue("UI_FishingSocialPanel_45", text_code.text);
|
||||
adapter.ShareText(invite);
|
||||
}
|
||||
private string GetInvitationCodeByPlayFabID()
|
||||
{
|
||||
return GContext.container.Resolve<FriendService>().GetInvitationCodeByPlayFabID(GContext.container.Resolve<IUserService>().UserId);
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region EnhancedScroller Handlers
|
||||
private float m_LockScrollViewCumulativeTime = 0.0f;
|
||||
public void StartLockScrollView(float lockTime)
|
||||
{
|
||||
m_LockScrollViewCumulativeTime = lockTime;
|
||||
LockScrollView();
|
||||
}
|
||||
void LockScrollView()
|
||||
{
|
||||
if (scroller == null || scroller.ScrollRect == null) return;
|
||||
if (scroller.ScrollRect.vertical)
|
||||
{
|
||||
scroller.ScrollRect.vertical = false;
|
||||
}
|
||||
}
|
||||
|
||||
void UnlockScrollView()
|
||||
{
|
||||
if (scroller == null || scroller.ScrollRect == null) return;
|
||||
if (!scroller.ScrollRect.vertical)
|
||||
{
|
||||
scroller.ScrollRect.vertical = true;
|
||||
}
|
||||
}
|
||||
|
||||
public int GetNumberOfCells(EnhancedScroller scroller)
|
||||
{
|
||||
return m_DataList.Count;
|
||||
}
|
||||
|
||||
public float GetCellViewSize(EnhancedScroller scroller, int dataIndex)
|
||||
{
|
||||
if (m_DataList[dataIndex].Type == FriendHelper.Friend_Add_Item_Type_Invited_TitleBar)
|
||||
{
|
||||
return 72f;
|
||||
}
|
||||
else if (m_DataList[dataIndex].Type == FriendHelper.Friend_Add_Item_Type_Invited_Item)
|
||||
{
|
||||
return 150f;
|
||||
}
|
||||
else if (m_DataList[dataIndex].Type == FriendHelper.Friend_Add_Item_Type_Recommended_TitleBar)
|
||||
{
|
||||
return 72f;
|
||||
}
|
||||
return 150f;
|
||||
}
|
||||
|
||||
public EnhancedScrollerCellView GetCellView(EnhancedScroller scroller, int dataIndex, int cellIndex)
|
||||
{
|
||||
FriendAddItem cellView;
|
||||
|
||||
if (m_DataList[dataIndex].Type == FriendHelper.Friend_Add_Item_Type_Invited_TitleBar)
|
||||
{
|
||||
cellView = scroller.GetCellView(invitedItemTitleBar) as FriendInvitedItemTitleBar;
|
||||
cellView.name = "[Invited Title Bar]";
|
||||
cellView.SetData(this, m_DataList[dataIndex], RemoveInvitedData);
|
||||
}
|
||||
else if (m_DataList[dataIndex].Type == FriendHelper.Friend_Add_Item_Type_Invited_Item)
|
||||
{
|
||||
cellView = scroller.GetCellView(invitedItem) as FriendInvitedItem;
|
||||
cellView.name = "[Invited Item] " + cellIndex + "-" + dataIndex;
|
||||
cellView.SetData(this, m_DataList[dataIndex], RemoveInvitedData);
|
||||
}
|
||||
else if (m_DataList[dataIndex].Type == FriendHelper.Friend_Add_Item_Type_Recommended_TitleBar)
|
||||
{
|
||||
cellView = scroller.GetCellView(recommendedItemTitleBar) as FriendRecommendedItemTitleBar;
|
||||
cellView.name = "[Recommended Title Bar]";
|
||||
cellView.SetData(this, m_DataList[dataIndex], RemoveRecommendedData);
|
||||
}
|
||||
else
|
||||
{
|
||||
cellView = scroller.GetCellView(recommendedItem) as FriendRecommendedItem;
|
||||
cellView.name = "[Recommended Item] " + cellIndex + "-" + dataIndex;
|
||||
cellView.SetData(this, m_DataList[dataIndex], RemoveRecommendedData);
|
||||
}
|
||||
|
||||
return cellView;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 生命周期
|
||||
void Awake()
|
||||
{
|
||||
loading = transform.Find("loading").gameObject;
|
||||
empty = transform.Find("add").gameObject;
|
||||
empty.SetActive(false);
|
||||
btn_add = transform.Find("friendcode/btn_search").GetComponent<Button>();
|
||||
icon_gift_invite = transform.Find("btn_invite/btn_green/Ani_Container/p_text/icon").gameObject;
|
||||
btn_invite = transform.Find("btn_invite/btn_green").GetComponent<Button>();
|
||||
btn_invite.onClick.AddListener(OnInviteClick);
|
||||
|
||||
btn_add.onClick.AddListener(OnAddClick);
|
||||
btn_share = transform.Find("friendcode/btn_share").GetComponent<Button>();
|
||||
btn_share.onClick.AddListener(OnClickInviteLink);
|
||||
text_code = transform.Find("friendcode/text_code").GetComponent<TMP_Text>();
|
||||
btn_copy = transform.Find("friendcode/btn_copy").GetComponent<Button>();
|
||||
btn_copy.onClick.AddListener(OnBtnCopyClick);
|
||||
text_code.text = GetInvitationCodeByPlayFabID();
|
||||
|
||||
|
||||
scroller = transform.Find("list/ScrollView").GetComponent<EnhancedScroller>();
|
||||
scroller.Delegate = this;
|
||||
|
||||
m_RecommendedBackendOperationList.Clear();
|
||||
m_InvitedBackendOperationList.Clear();
|
||||
}
|
||||
|
||||
void ShowGiftIcon()
|
||||
{
|
||||
List<cfg.Invite> invites = GContext.container.Resolve<Tables>().TbInvite.DataList;
|
||||
//已经领取奖励的数量
|
||||
string receiveRewardCountStr = PlayFabMgr.Instance.GetLocalData(FriendService.InviteLinkRewardCountKey);
|
||||
if (receiveRewardCountStr != null)
|
||||
{
|
||||
int.TryParse(receiveRewardCountStr, out int InviteLinkRewardCount);
|
||||
icon_gift_invite.SetActive(InviteLinkRewardCount < invites.Count);
|
||||
}
|
||||
}
|
||||
|
||||
void OnInviteClick()
|
||||
{
|
||||
_ = UIManager.Instance.ShowUI(UITypes.FishingSocialInviteFriendsPopupPanel);
|
||||
}
|
||||
|
||||
async void OnAddClick()
|
||||
{
|
||||
await UIManager.Instance.ShowUI(UITypes.FishingSocialFriendSearchPanel);
|
||||
}
|
||||
async void OnEnable()
|
||||
{
|
||||
m_PageNo = 0;
|
||||
ShowGiftIcon();
|
||||
//if (scroller != null) scroller.gameObject.SetActive(false);
|
||||
if (empty != null) empty.SetActive(false);
|
||||
loading.SetActive(true);
|
||||
await InitDefault();
|
||||
|
||||
loading.SetActive(false);
|
||||
}
|
||||
private void Update()
|
||||
{
|
||||
UpdateLockAction(Time.deltaTime);
|
||||
}
|
||||
protected override void OnDestroy()
|
||||
{
|
||||
foreach (var item in m_RecommendedBackendOperationList)
|
||||
{
|
||||
item.Clear();
|
||||
}
|
||||
m_RecommendedBackendOperationList.Clear();
|
||||
|
||||
foreach (var item in m_InvitedBackendOperationList)
|
||||
{
|
||||
item.Clear();
|
||||
}
|
||||
m_InvitedBackendOperationList.Clear();
|
||||
|
||||
base.OnDestroy();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user