yyl
20 小时以前 5d3366f2e0f687995eb7ad2107c4379fe7acd4e8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
    public class ChatRecently : MonoBehaviour
    {
        [SerializeField] ScrollerController m_RecentlyControl;
 
        // FriendsModel m_FriendModel;
        // FriendsModel friendModel
        // {
        //     get
        //     {
        //         return m_FriendModel ?? (m_FriendModel = ModelCenter.Instance.GetModel<FriendsModel>());
        //     }
        // }
 
        private void OnEnable()
        {
            UpdatePlayer();
            DisplayRecently();
            // friendModel.RefreshFriendCntEvent += RefreshFriendCntEvent;
            // friendModel.RefreshFriendModel += DisplayRecently;
        }
 
        private void OnDisable()
        {
            // friendModel.RefreshFriendCntEvent -= RefreshFriendCntEvent;
            // friendModel.RefreshFriendModel -= DisplayRecently;
        }
 
        private void DisplayRecently()
        {
            m_RecentlyControl.Refresh();
            // var _dict = friendModel.GetFriendInfoDict((byte)GroupType.RecentContact);
            // if (_dict != null)
            // {
            //     if (friendModel.tempFriendData != null && !_dict.ContainsKey(friendModel.tempFriendData.PlayerID))
            //     {
            //         m_RecentlyControl.AddCell(ScrollerDataType.Header, (int)friendModel.tempFriendData.PlayerID, OnClickFriend);
            //     }
            //     foreach (var _id in _dict.Keys)
            //     {
            //         m_RecentlyControl.AddCell(ScrollerDataType.Header, (int)_id, OnClickFriend);
            //     }
            // }
            // else if (friendModel.tempFriendData != null)
            // {
            //     m_RecentlyControl.AddCell(ScrollerDataType.Header, (int)friendModel.tempFriendData.PlayerID, OnClickFriend);
            // }
            m_RecentlyControl.Restart();
        }
 
        private void OnClickFriend(CellView _cell)
        {
            // if(_cell.index!= ChatManager.Instance.PteChatID)
            // {
            //     ChatManager.Instance.PteChatID = _cell.index;
            //     var _dict = friendModel.GetFriendInfoDict((byte)GroupType.RecentContact);
            //     if (friendModel.tempFriendData != null
            //         && ChatManager.Instance.PteChatID == friendModel.tempFriendData.PlayerID)
            //     {
            //         ChatManager.Instance.PteChatName = friendModel.tempFriendData.PlayerName;
            //         LanguageVerify.toPlayerLevel = friendModel.tempFriendData.LV;
            //     }
            //     else
            //     {
            //         ChatManager.Instance.PteChatName = _dict != null && _dict.ContainsKey((uint)ChatManager.Instance.PteChatID) ?
            //                         _dict[(uint)ChatManager.Instance.PteChatID].PlayerName : string.Empty;
            //         LanguageVerify.toPlayerLevel = _dict != null && _dict.ContainsKey((uint)ChatManager.Instance.PteChatID) ?
            //                         _dict[(uint)ChatManager.Instance.PteChatID].LV : 0;
            //     }
            //     ChatManager.Instance.SelectRecentlyChat(ChatManager.Instance.PteChatID);
            //     m_RecentlyControl.m_Scorller.RefreshActiveCellViews();
            // }
        }
 
        private void RefreshFriendCntEvent(/*GroupType _type, bool arg2*/)
        {
            // if (_type == GroupType.RecentContact)
            // {
            //     DisplayRecently();
            // }
        }
 
        private void UpdatePlayer()
        {
            // TODO YYL
            // if (friendModel.tempFriendData != null)
            // {
            //     ChatManager.Instance.PteChatID = (int)friendModel.tempFriendData.PlayerID;
            //     ChatManager.Instance.PteChatName = friendModel.tempFriendData.PlayerName;
            //     LanguageVerify.toPlayerLevel = friendModel.tempFriendData.LV;
            //     ChatManager.Instance.SelectRecentlyChat(ChatManager.Instance.PteChatID);
            //     return;
            // }
            // var _dict = friendModel.GetFriendInfoDict((byte)GroupType.RecentContact);
            // if (_dict != null && _dict.Count > 0)
            // {
            //     ChatManager.Instance.PteChatID = (int)_dict.Keys.First();
            //     ChatManager.Instance.PteChatName = _dict[(uint)ChatManager.Instance.PteChatID].PlayerName;
            //     LanguageVerify.toPlayerLevel = _dict[(uint)ChatManager.Instance.PteChatID].LV;
            //     ChatManager.Instance.SelectRecentlyChat(ChatManager.Instance.PteChatID);
            // }
        }
    }