From 8e81f0bb8ff2f9c5653e5a9df96005961fd8e684 Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Sat, 14 Jan 2017 01:47:26 +0100 Subject: [PATCH] Update profile on remote changes.. --- .../b44t/messenger/MessagesController.java | 2 - .../b44t/messenger/NotificationCenter.java | 1 - .../java/com/b44t/ui/ProfileActivity.java | 40 +++---------------- 3 files changed, 5 insertions(+), 38 deletions(-) diff --git a/MessengerProj/src/main/java/com/b44t/messenger/MessagesController.java b/MessengerProj/src/main/java/com/b44t/messenger/MessagesController.java index 7a0a30e06..9cccab36f 100644 --- a/MessengerProj/src/main/java/com/b44t/messenger/MessagesController.java +++ b/MessengerProj/src/main/java/com/b44t/messenger/MessagesController.java @@ -61,8 +61,6 @@ public class MessagesController implements NotificationCenter.NotificationCenter public static final int UPDATE_MASK_SELECT_DIALOG = 512; public static final int UPDATE_MASK_NEW_MESSAGE = 2048; public static final int UPDATE_MASK_SEND_STATE = 4096; - public static final int UPDATE_MASK_CHANNEL = 8192; - public static final int UPDATE_MASK_CHAT_ADMINS = 16384; private static volatile MessagesController Instance = null; diff --git a/MessengerProj/src/main/java/com/b44t/messenger/NotificationCenter.java b/MessengerProj/src/main/java/com/b44t/messenger/NotificationCenter.java index 8464a1197..1ea7e5f45 100644 --- a/MessengerProj/src/main/java/com/b44t/messenger/NotificationCenter.java +++ b/MessengerProj/src/main/java/com/b44t/messenger/NotificationCenter.java @@ -56,7 +56,6 @@ public class NotificationCenter { //public static final int screenStateChanged = totalEvents++; -- currently not used, but this may get handy public static final int stickersDidLoaded = totalEvents++; public static final int didReplacedPhotoInMemCache = totalEvents++; - public static final int userInfoDidLoaded = totalEvents++; public static final int musicDidLoaded = totalEvents++; public static final int locationPermissionGranted = totalEvents++; public static final int wasUnableToFindCurrentLocation = totalEvents++; diff --git a/MessengerProj/src/main/java/com/b44t/ui/ProfileActivity.java b/MessengerProj/src/main/java/com/b44t/ui/ProfileActivity.java index f0b6ed488..b32890a7e 100644 --- a/MessengerProj/src/main/java/com/b44t/ui/ProfileActivity.java +++ b/MessengerProj/src/main/java/com/b44t/ui/ProfileActivity.java @@ -194,8 +194,6 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. } NotificationCenter.getInstance().addObserver(this, NotificationCenter.updateInterfaces); NotificationCenter.getInstance().addObserver(this, NotificationCenter.contactsDidLoaded); - NotificationCenter.getInstance().addObserver(this, NotificationCenter.userInfoDidLoaded); - } else if (chat_id != 0) { sortedUserIds = MrMailbox.getChatContacts(chat_id); @@ -228,7 +226,6 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. NotificationCenter.getInstance().removeObserver(this, NotificationCenter.closeChats); if (user_id != 0) { NotificationCenter.getInstance().removeObserver(this, NotificationCenter.contactsDidLoaded); - NotificationCenter.getInstance().removeObserver(this, NotificationCenter.userInfoDidLoaded); //MessagesController.getInstance().cancelLoadFullUser(user_id); } else if (chat_id != 0) { //NotificationCenter.getInstance().removeObserver(this, NotificationCenter.chatInfoDidLoaded); @@ -435,10 +432,6 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. @Override public void onClick(DialogInterface dialogInterface, int i) { MrMailbox.addContactToChat(chat_id, added_user_id); - sortedUserIds = MrMailbox.getChatContacts(chat_id); - updateRowsIds(); - updateProfileData(); - listAdapter.notifyDataSetChanged(); NotificationCenter.getInstance().postNotificationName(NotificationCenter.updateInterfaces, MessagesController.UPDATE_MASK_CHAT_MEMBERS); } }); @@ -489,10 +482,6 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. @Override public void onClick(DialogInterface dialogInterface, int i) { MrMailbox.removeContactFromChat(chat_id, curr_user_id); - sortedUserIds = MrMailbox.getChatContacts(chat_id); - updateRowsIds(); - updateProfileData(); - listAdapter.notifyDataSetChanged(); NotificationCenter.getInstance().postNotificationName(NotificationCenter.updateInterfaces, MessagesController.UPDATE_MASK_CHAT_MEMBERS); } }); @@ -827,22 +816,11 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. updateProfileData(); } } else if (chat_id != 0) { - if ((mask & MessagesController.UPDATE_MASK_CHAT_ADMINS) != 0) { - createActionBarMenu(); - updateRowsIds(); - if (listAdapter != null) { - listAdapter.notifyDataSetChanged(); - } - } - if ((mask & MessagesController.UPDATE_MASK_CHANNEL) != 0 || (mask & MessagesController.UPDATE_MASK_CHAT_AVATAR) != 0 || (mask & MessagesController.UPDATE_MASK_CHAT_NAME) != 0 || (mask & MessagesController.UPDATE_MASK_CHAT_MEMBERS) != 0 || (mask & MessagesController.UPDATE_MASK_STATUS) != 0) { - updateProfileData(); - } - if ((mask & MessagesController.UPDATE_MASK_CHANNEL) != 0) { - updateRowsIds(); - if (listAdapter != null) { - listAdapter.notifyDataSetChanged(); - } - } + sortedUserIds = MrMailbox.getChatContacts(chat_id); + updateRowsIds(); + updateProfileData(); + listAdapter.notifyDataSetChanged(); + if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0 || (mask & MessagesController.UPDATE_MASK_NAME) != 0 || (mask & MessagesController.UPDATE_MASK_STATUS) != 0) { if (listView != null) { int count = listView.getChildCount(); @@ -859,14 +837,6 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. createActionBarMenu(); } else if (id == NotificationCenter.closeChats) { removeSelfFromStack(); - } else if (id == NotificationCenter.userInfoDidLoaded) { - int uid = (Integer) args[0]; - if (uid == user_id) { - updateRowsIds(); - if (listAdapter != null) { - listAdapter.notifyDataSetChanged(); - } - } } }