1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- using UnityEngine;
- using UnityEngine.UI;
- using System.Collections;
- public class ChatBarChatView : View
- {
- public Text findFriendBtnLabel;
- public Transform container;
- public ChatBarChatItem itemPrefab;
- protected override void OnInitCompleted ()
- {
- if (!FollowManager.GetInstance ().initialized)
- {
- ListHelper.HideAll (container);
- FollowManager.GetInstance ().InitCompletion.AddListener (OnFollowersInit);
- FollowManager.GetInstance ().Init ();
- }
- else
- {
- OnFollowersInit ();
- }
- }
- protected override void OnDestroy ()
- {
- base.OnDestroy ();
- FollowManager.GetInstance ().InitCompletion.RemoveListener (OnFollowersInit);
- FollowManager.GetInstance ().FollowAdded.RemoveListener (OnFollowAdded);
- FollowManager.GetInstance ().FollowDeleted.RemoveListener (OnFollowDeleted);
- }
- private void OnFollowersInit()
- {
- FollowManager.GetInstance ().InitCompletion.RemoveListener (OnFollowersInit);
- FollowManager.GetInstance ().FollowAdded.AddListener (OnFollowAdded);
- FollowManager.GetInstance ().FollowDeleted.AddListener (OnFollowDeleted);
- OnVisibleChanged ();
- if (!ChatManager.GetInstance ().initialized)
- ChatManager.GetInstance ().Init ();
- }
- protected override void OnVisibleChanged ()
- {
- if(visible && FollowManager.GetInstance().initialized)
- {
- ListHelper.FillList<Follower> (container, FollowManager.GetInstance().GetFollowList(), itemPrefab);
- }
- }
- private void OnFollowAdded(int userId)
- {
- Follower follower = FollowManager.GetInstance ().GetFollower (userId);
- if(follower != null)
- {
- ListHelper.AddToList<Follower> (container, follower, itemPrefab);
- }
- }
-
- private void OnFollowDeleted(object follower)
- {
- ListHelper.Remove<Follower> (container, follower as Follower);
- }
- public void ShowFindFriendPanel()
- {
- ChatPanel.ShowFindFriend ();
- }
- }
|