Java Code Examples for org.telegram.messenger.MessagesController#UPDATE_MASK_NAME

The following examples show how to use org.telegram.messenger.MessagesController#UPDATE_MASK_NAME . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GroupCreateActivity.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void didReceivedNotification(int id, int account, Object... args) {
    if (id == NotificationCenter.contactsDidLoaded) {
        if (emptyView != null) {
            emptyView.showTextView();
        }
        if (adapter != null) {
            adapter.notifyDataSetChanged();
        }
    } else if (id == NotificationCenter.updateInterfaces) {
        if (listView != null) {
            int mask = (Integer) args[0];
            int count = listView.getChildCount();
            if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0 || (mask & MessagesController.UPDATE_MASK_NAME) != 0 || (mask & MessagesController.UPDATE_MASK_STATUS) != 0) {
                for (int a = 0; a < count; a++) {
                    View child = listView.getChildAt(a);
                    if (child instanceof GroupCreateUserCell) {
                        ((GroupCreateUserCell) child).update(mask);
                    }
                }
            }
        }
    } else if (id == NotificationCenter.chatDidCreated) {
        removeSelfFromStack();
    }
}
 
Example 2
Source File: ContactsActivity.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void didReceivedNotification(int id, int account, Object... args) {
    if (id == NotificationCenter.contactsDidLoaded) {
        if (listViewAdapter != null) {
            listViewAdapter.notifyDataSetChanged();
        }
    } else if (id == NotificationCenter.updateInterfaces) {
        int mask = (Integer)args[0];
        if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0 || (mask & MessagesController.UPDATE_MASK_NAME) != 0 || (mask & MessagesController.UPDATE_MASK_STATUS) != 0) {
            updateVisibleRows(mask);
        }
    } else if (id == NotificationCenter.encryptedChatCreated) {
        if (createSecretChat && creatingChat) {
            TLRPC.EncryptedChat encryptedChat = (TLRPC.EncryptedChat)args[0];
            Bundle args2 = new Bundle();
            args2.putInt("enc_id", encryptedChat.id);
            NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.closeChats);
            presentFragment(new ChatActivity(args2), true);
        }
    } else if (id == NotificationCenter.closeChats) {
        if (!creatingChat) {
            removeSelfFromStack();
        }
    }
}
 
Example 3
Source File: SetAdminsActivity.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void didReceivedNotification(int id, int account, Object... args) {
    if (id == NotificationCenter.chatInfoDidLoaded) {
        TLRPC.ChatFull chatFull = (TLRPC.ChatFull) args[0];
        if (chatFull.id == chat_id) {
            info = chatFull;
            updateChatParticipants();
            updateRowsIds();
        }
    } else if (id == NotificationCenter.updateInterfaces) {
        int mask = (Integer) args[0];
        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();
                for (int a = 0; a < count; a++) {
                    View child = listView.getChildAt(a);
                    if (child instanceof UserCell) {
                        ((UserCell) child).update(mask);
                    }
                }
            }
        }
    }
}
 
Example 4
Source File: FilterUsersActivity.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void didReceivedNotification(int id, int account, Object... args) {
    if (id == NotificationCenter.contactsDidLoad) {
        if (emptyView != null) {
            emptyView.showTextView();
        }
        if (adapter != null) {
            adapter.notifyDataSetChanged();
        }
    } else if (id == NotificationCenter.updateInterfaces) {
        if (listView != null) {
            int mask = (Integer) args[0];
            int count = listView.getChildCount();
            if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0 || (mask & MessagesController.UPDATE_MASK_NAME) != 0 || (mask & MessagesController.UPDATE_MASK_STATUS) != 0) {
                for (int a = 0; a < count; a++) {
                    View child = listView.getChildAt(a);
                    if (child instanceof GroupCreateUserCell) {
                        ((GroupCreateUserCell) child).update(mask);
                    }
                }
            }
        }
    } else if (id == NotificationCenter.chatDidCreated) {
        removeSelfFromStack();
    }
}
 
Example 5
Source File: ContactsActivity.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void didReceivedNotification(int id, int account, Object... args) {
    if (id == NotificationCenter.contactsDidLoaded) {
        if (listViewAdapter != null) {
            listViewAdapter.notifyDataSetChanged();
        }
    } else if (id == NotificationCenter.updateInterfaces) {
        int mask = (Integer)args[0];
        if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0 || (mask & MessagesController.UPDATE_MASK_NAME) != 0 || (mask & MessagesController.UPDATE_MASK_STATUS) != 0) {
            updateVisibleRows(mask);
        }
    } else if (id == NotificationCenter.encryptedChatCreated) {
        if (createSecretChat && creatingChat) {
            TLRPC.EncryptedChat encryptedChat = (TLRPC.EncryptedChat)args[0];
            Bundle args2 = new Bundle();
            args2.putInt("enc_id", encryptedChat.id);
            NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.closeChats);
            presentFragment(new ChatActivity(args2), true);
        }
    } else if (id == NotificationCenter.closeChats) {
        if (!creatingChat) {
            removeSelfFromStack();
        }
    }
}
 
Example 6
Source File: FilterUsersActivity.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void didReceivedNotification(int id, int account, Object... args) {
    if (id == NotificationCenter.contactsDidLoad) {
        if (emptyView != null) {
            emptyView.showTextView();
        }
        if (adapter != null) {
            adapter.notifyDataSetChanged();
        }
    } else if (id == NotificationCenter.updateInterfaces) {
        if (listView != null) {
            int mask = (Integer) args[0];
            int count = listView.getChildCount();
            if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0 || (mask & MessagesController.UPDATE_MASK_NAME) != 0 || (mask & MessagesController.UPDATE_MASK_STATUS) != 0) {
                for (int a = 0; a < count; a++) {
                    View child = listView.getChildAt(a);
                    if (child instanceof GroupCreateUserCell) {
                        ((GroupCreateUserCell) child).update(mask);
                    }
                }
            }
        }
    } else if (id == NotificationCenter.chatDidCreated) {
        removeSelfFromStack();
    }
}
 
Example 7
Source File: BlockedUsersActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void didReceivedNotification(int id, int account, Object... args) {
    if (id == NotificationCenter.updateInterfaces) {
        int mask = (Integer) args[0];
        if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0 || (mask & MessagesController.UPDATE_MASK_NAME) != 0) {
            updateVisibleRows(mask);
        }
    } else if (id == NotificationCenter.blockedUsersDidLoaded) {
        emptyView.showTextView();
        if (listViewAdapter != null) {
            listViewAdapter.notifyDataSetChanged();
        }
    }
}
 
Example 8
Source File: BlockedUsersActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void didReceivedNotification(int id, int account, Object... args) {
    if (id == NotificationCenter.updateInterfaces) {
        int mask = (Integer) args[0];
        if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0 || (mask & MessagesController.UPDATE_MASK_NAME) != 0) {
            updateVisibleRows(mask);
        }
    } else if (id == NotificationCenter.blockedUsersDidLoaded) {
        emptyView.showTextView();
        if (listViewAdapter != null) {
            listViewAdapter.notifyDataSetChanged();
        }
    }
}
 
Example 9
Source File: GroupCreateFinalActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void didReceivedNotification(int id, int account, Object... args) {
    if (id == NotificationCenter.updateInterfaces) {
        if (listView == null) {
            return;
        }
        int mask = (Integer) args[0];
        if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0 || (mask & MessagesController.UPDATE_MASK_NAME) != 0 || (mask & MessagesController.UPDATE_MASK_STATUS) != 0) {
            int count = listView.getChildCount();
            for (int a = 0; a < count; a++) {
                View child = listView.getChildAt(a);
                if (child instanceof GroupCreateUserCell) {
                    ((GroupCreateUserCell) child).update(mask);
                }
            }
        }
    } else if (id == NotificationCenter.chatDidFailCreate) {
        reqId = 0;
        donePressed = false;
        showEditDoneProgress(false);
        if (editText != null) {
            editText.setEnabled(true);
        }
    } else if (id == NotificationCenter.chatDidCreated) {
        reqId = 0;
        int chat_id = (Integer) args[0];
        NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.closeChats);
        Bundle args2 = new Bundle();
        args2.putInt("chat_id", chat_id);
        presentFragment(new ChatActivity(args2), true);
        if (uploadedAvatar != null) {
            MessagesController.getInstance(currentAccount).changeChatAvatar(chat_id, uploadedAvatar);
        }
    }
}
 
Example 10
Source File: BlockedUsersActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void didReceivedNotification(int id, int account, Object... args) {
    if (id == NotificationCenter.updateInterfaces) {
        int mask = (Integer) args[0];
        if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0 || (mask & MessagesController.UPDATE_MASK_NAME) != 0) {
            updateVisibleRows(mask);
        }
    } else if (id == NotificationCenter.blockedUsersDidLoaded) {
        emptyView.showTextView();
        if (listViewAdapter != null) {
            listViewAdapter.notifyDataSetChanged();
        }
    }
}
 
Example 11
Source File: PrivacyUsersActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void didReceivedNotification(int id, int account, Object... args) {
    if (id == NotificationCenter.updateInterfaces) {
        int mask = (Integer) args[0];
        if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0 || (mask & MessagesController.UPDATE_MASK_NAME) != 0) {
            updateVisibleRows(mask);
        }
    }
}
 
Example 12
Source File: BlockedUsersActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void didReceivedNotification(int id, int account, Object... args) {
    if (id == NotificationCenter.updateInterfaces) {
        int mask = (Integer) args[0];
        if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0 || (mask & MessagesController.UPDATE_MASK_NAME) != 0) {
            updateVisibleRows(mask);
        }
    } else if (id == NotificationCenter.blockedUsersDidLoaded) {
        emptyView.showTextView();
        if (listViewAdapter != null) {
            listViewAdapter.notifyDataSetChanged();
        }
    }
}
 
Example 13
Source File: PrivacyUsersActivity.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void didReceivedNotification(int id, int account, Object... args) {
    if (id == NotificationCenter.updateInterfaces) {
        int mask = (Integer) args[0];
        if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0 || (mask & MessagesController.UPDATE_MASK_NAME) != 0) {
            updateVisibleRows(mask);
        }
    } else if (id == NotificationCenter.blockedUsersDidLoad) {
        emptyView.showTextView();
        updateRows();
    }
}
 
Example 14
Source File: PollVotesAlert.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
public void update(int mask) {
    TLRPC.FileLocation photo = null;
    String newName = null;
    if (currentUser != null && currentUser.photo != null) {
        photo = currentUser.photo.photo_small;
    }

    if (mask != 0) {
        boolean continueUpdate = false;
        if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0) {
            if (lastAvatar != null && photo == null || lastAvatar == null && photo != null || lastAvatar != null && photo != null && (lastAvatar.volume_id != photo.volume_id || lastAvatar.local_id != photo.local_id)) {
                continueUpdate = true;
            }
        }
        if (currentUser != null && !continueUpdate && (mask & MessagesController.UPDATE_MASK_STATUS) != 0) {
            int newStatus = 0;
            if (currentUser.status != null) {
                newStatus = currentUser.status.expires;
            }
            if (newStatus != lastStatus) {
                continueUpdate = true;
            }
        }
        if (!continueUpdate && lastName != null && (mask & MessagesController.UPDATE_MASK_NAME) != 0) {
            if (currentUser != null) {
                newName = UserObject.getUserName(currentUser);
            }
            if (!newName.equals(lastName)) {
                continueUpdate = true;
            }
        }
        if (!continueUpdate) {
            return;
        }
    }

    avatarDrawable.setInfo(currentUser);
    if (currentUser.status != null) {
        lastStatus = currentUser.status.expires;
    } else {
        lastStatus = 0;
    }

    if (currentUser != null) {
        lastName = newName == null ? UserObject.getUserName(currentUser) : newName;
    } else {
        lastName = "";
    }
    nameTextView.setText(lastName);

    lastAvatar = photo;
    if (currentUser != null) {
        avatarImageView.setImage(ImageLocation.getForUser(currentUser, false), "50_50", avatarDrawable, currentUser);
    } else {
        avatarImageView.setImageDrawable(avatarDrawable);
    }
}
 
Example 15
Source File: PollVotesAlert.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
public void update(int mask) {
    TLRPC.FileLocation photo = null;
    String newName = null;
    if (currentUser != null && currentUser.photo != null) {
        photo = currentUser.photo.photo_small;
    }

    if (mask != 0) {
        boolean continueUpdate = false;
        if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0) {
            if (lastAvatar != null && photo == null || lastAvatar == null && photo != null || lastAvatar != null && photo != null && (lastAvatar.volume_id != photo.volume_id || lastAvatar.local_id != photo.local_id)) {
                continueUpdate = true;
            }
        }
        if (currentUser != null && !continueUpdate && (mask & MessagesController.UPDATE_MASK_STATUS) != 0) {
            int newStatus = 0;
            if (currentUser.status != null) {
                newStatus = currentUser.status.expires;
            }
            if (newStatus != lastStatus) {
                continueUpdate = true;
            }
        }
        if (!continueUpdate && lastName != null && (mask & MessagesController.UPDATE_MASK_NAME) != 0) {
            if (currentUser != null) {
                newName = UserObject.getUserName(currentUser);
            }
            if (!newName.equals(lastName)) {
                continueUpdate = true;
            }
        }
        if (!continueUpdate) {
            return;
        }
    }

    avatarDrawable.setInfo(currentUser);
    if (currentUser.status != null) {
        lastStatus = currentUser.status.expires;
    } else {
        lastStatus = 0;
    }

    if (currentUser != null) {
        lastName = newName == null ? UserObject.getUserName(currentUser) : newName;
    } else {
        lastName = "";
    }
    nameTextView.setText(lastName);

    lastAvatar = photo;
    if (currentUser != null) {
        avatarImageView.setImage(ImageLocation.getForUser(currentUser, false), "50_50", avatarDrawable, currentUser);
    } else {
        avatarImageView.setImageDrawable(avatarDrawable);
    }
}
 
Example 16
Source File: ProfileSearchCell.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
public void update(int mask) {
    TLRPC.FileLocation photo = null;
    if (user != null) {
        avatarDrawable.setInfo(user);
        if (savedMessages) {
            avatarDrawable.setSavedMessages(1);
        } else if (user.photo != null) {
            photo = user.photo.photo_small;
        }
    } else if (chat != null) {
        if (chat.photo != null) {
            photo = chat.photo.photo_small;
        }
        avatarDrawable.setInfo(chat);
    } else {
        avatarDrawable.setInfo(0, null, null, false);
    }

    if (mask != 0) {
        boolean continueUpdate = false;
        if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0 && user != null || (mask & MessagesController.UPDATE_MASK_CHAT_AVATAR) != 0 && chat != null) {
            if (lastAvatar != null && photo == null || lastAvatar == null && photo != null && lastAvatar != null && photo != null && (lastAvatar.volume_id != photo.volume_id || lastAvatar.local_id != photo.local_id)) {
                continueUpdate = true;
            }
        }
        if (!continueUpdate && (mask & MessagesController.UPDATE_MASK_STATUS) != 0 && user != null) {
            int newStatus = 0;
            if (user.status != null) {
                newStatus = user.status.expires;
            }
            if (newStatus != lastStatus) {
                continueUpdate = true;
            }
        }
        if (!continueUpdate && ((mask & MessagesController.UPDATE_MASK_NAME) != 0 && user != null) || (mask & MessagesController.UPDATE_MASK_CHAT_NAME) != 0 && chat != null) {
            String newName;
            if (user != null) {
                newName = user.first_name + user.last_name;
            } else {
                newName = chat.title;
            }
            if (!newName.equals(lastName)) {
                continueUpdate = true;
            }
        }
        if (!continueUpdate && drawCount && (mask & MessagesController.UPDATE_MASK_READ_DIALOG_MESSAGE) != 0) {
            TLRPC.TL_dialog dialog = MessagesController.getInstance(currentAccount).dialogs_dict.get(dialog_id);
            if (dialog != null && dialog.unread_count != lastUnreadCount) {
                continueUpdate = true;
            }
        }

        if (!continueUpdate) {
            return;
        }
    }

    if (user != null) {
        if (user.status != null) {
            lastStatus = user.status.expires;
        } else {
            lastStatus = 0;
        }
        lastName = user.first_name + user.last_name;
    } else if (chat != null) {
        lastName = chat.title;
    }

    lastAvatar = photo;
    avatarImage.setImage(photo, "50_50", avatarDrawable, null, 0);

    if (getMeasuredWidth() != 0 || getMeasuredHeight() != 0) {
        buildLayout();
    } else {
        requestLayout();
    }
    postInvalidate();
}
 
Example 17
Source File: ProfileSearchCell.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
public void update(int mask) {
    TLRPC.FileLocation photo = null;
    if (user != null) {
        avatarDrawable.setInfo(user);
        if (savedMessages) {
            avatarDrawable.setAvatarType(AvatarDrawable.AVATAR_TYPE_SAVED);
            avatarImage.setImage(null, null, avatarDrawable, null, null, 0);
        } else {
            if (user.photo != null) {
                photo = user.photo.photo_small;
            }
            avatarImage.setImage(ImageLocation.getForUser(user, false), "50_50", avatarDrawable, null, user, 0);
        }
    } else if (chat != null) {
        if (chat.photo != null) {
            photo = chat.photo.photo_small;
        }
        avatarDrawable.setInfo(chat);
        avatarImage.setImage(ImageLocation.getForChat(chat, false), "50_50", avatarDrawable, null, chat, 0);
    } else {
        avatarDrawable.setInfo(0, null, null);
        avatarImage.setImage(null, null, avatarDrawable, null, null, 0);
    }

    if (mask != 0) {
        boolean continueUpdate = false;
        if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0 && user != null || (mask & MessagesController.UPDATE_MASK_CHAT_AVATAR) != 0 && chat != null) {
            if (lastAvatar != null && photo == null || lastAvatar == null && photo != null || lastAvatar != null && photo != null && (lastAvatar.volume_id != photo.volume_id || lastAvatar.local_id != photo.local_id)) {
                continueUpdate = true;
            }
        }
        if (!continueUpdate && (mask & MessagesController.UPDATE_MASK_STATUS) != 0 && user != null) {
            int newStatus = 0;
            if (user.status != null) {
                newStatus = user.status.expires;
            }
            if (newStatus != lastStatus) {
                continueUpdate = true;
            }
        }
        if (!continueUpdate && ((mask & MessagesController.UPDATE_MASK_NAME) != 0 && user != null) || (mask & MessagesController.UPDATE_MASK_CHAT_NAME) != 0 && chat != null) {
            String newName;
            if (user != null) {
                newName = user.first_name + user.last_name;
            } else {
                newName = chat.title;
            }
            if (!newName.equals(lastName)) {
                continueUpdate = true;
            }
        }
        if (!continueUpdate && drawCount && (mask & MessagesController.UPDATE_MASK_READ_DIALOG_MESSAGE) != 0) {
            TLRPC.Dialog dialog = MessagesController.getInstance(currentAccount).dialogs_dict.get(dialog_id);
            if (dialog != null && dialog.unread_count != lastUnreadCount) {
                continueUpdate = true;
            }
        }

        if (!continueUpdate) {
            return;
        }
    }

    if (user != null) {
        if (user.status != null) {
            lastStatus = user.status.expires;
        } else {
            lastStatus = 0;
        }
        lastName = user.first_name + user.last_name;
    } else if (chat != null) {
        lastName = chat.title;
    }

    lastAvatar = photo;

    if (getMeasuredWidth() != 0 || getMeasuredHeight() != 0) {
        buildLayout();
    } else {
        requestLayout();
    }
    postInvalidate();
}
 
Example 18
Source File: ChatAttachAlertContactsLayout.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
public void update(int mask) {
    TLRPC.FileLocation photo = null;
    String newName = null;
    if (currentUser != null && currentUser.photo != null) {
        photo = currentUser.photo.photo_small;
    }

    if (mask != 0) {
        boolean continueUpdate = false;
        if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0) {
            if (lastAvatar != null && photo == null || lastAvatar == null && photo != null || lastAvatar != null && photo != null && (lastAvatar.volume_id != photo.volume_id || lastAvatar.local_id != photo.local_id)) {
                continueUpdate = true;
            }
        }
        if (currentUser != null && !continueUpdate && (mask & MessagesController.UPDATE_MASK_STATUS) != 0) {
            int newStatus = 0;
            if (currentUser.status != null) {
                newStatus = currentUser.status.expires;
            }
            if (newStatus != lastStatus) {
                continueUpdate = true;
            }
        }
        if (!continueUpdate && currentName == null && lastName != null && (mask & MessagesController.UPDATE_MASK_NAME) != 0) {
            if (currentUser != null) {
                newName = UserObject.getUserName(currentUser);
            }
            if (!newName.equals(lastName)) {
                continueUpdate = true;
            }
        }
        if (!continueUpdate) {
            return;
        }
    }

    if (currentUser != null) {
        avatarDrawable.setInfo(currentUser);
        if (currentUser.status != null) {
            lastStatus = currentUser.status.expires;
        } else {
            lastStatus = 0;
        }
    } else if (currentName != null) {
        avatarDrawable.setInfo(currentId, currentName.toString(), null);
    } else {
        avatarDrawable.setInfo(currentId, "#", null);
    }

    if (currentName != null) {
        lastName = null;
        nameTextView.setText(currentName);
    } else {
        if (currentUser != null) {
            lastName = newName == null ? UserObject.getUserName(currentUser) : newName;
        } else {
            lastName = "";
        }
        nameTextView.setText(lastName);
    }
    if (currentStatus != null) {
        statusTextView.setText(currentStatus);
    } else if (currentUser != null) {
        if (TextUtils.isEmpty(currentUser.phone)) {
            statusTextView.setText(LocaleController.getString("NumberUnknown", R.string.NumberUnknown));
        } else {
            statusTextView.setText(PhoneFormat.getInstance().format("+" + currentUser.phone));
        }
    }

    lastAvatar = photo;
    if (currentUser != null) {
        avatarImageView.setImage(ImageLocation.getForUser(currentUser, false), "50_50", avatarDrawable, currentUser);
    } else {
        avatarImageView.setImageDrawable(avatarDrawable);
    }
}
 
Example 19
Source File: ManageChatUserCell.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
public void update(int mask) {
    if (currentUser == null) {
        return;
    }
    TLRPC.FileLocation photo = null;
    String newName = null;
    if (currentUser.photo != null) {
        photo = currentUser.photo.photo_small;
    }

    if (mask != 0) {
        boolean continueUpdate = false;
        if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0) {
            if (lastAvatar != null && photo == null || lastAvatar == null && photo != null && lastAvatar != null && photo != null && (lastAvatar.volume_id != photo.volume_id || lastAvatar.local_id != photo.local_id)) {
                continueUpdate = true;
            }
        }
        if (currentUser != null && !continueUpdate && (mask & MessagesController.UPDATE_MASK_STATUS) != 0) {
            int newStatus = 0;
            if (currentUser.status != null) {
                newStatus = currentUser.status.expires;
            }
            if (newStatus != lastStatus) {
                continueUpdate = true;
            }
        }
        if (!continueUpdate && currentName == null && lastName != null && (mask & MessagesController.UPDATE_MASK_NAME) != 0) {
            newName = UserObject.getUserName(currentUser);
            if (!newName.equals(lastName)) {
                continueUpdate = true;
            }
        }
        if (!continueUpdate) {
            return;
        }
    }

    avatarDrawable.setInfo(currentUser);
    if (currentUser.status != null) {
        lastStatus = currentUser.status.expires;
    } else {
        lastStatus = 0;
    }

    if (currentName != null) {
        lastName = null;
        nameTextView.setText(currentName);
    } else {
        lastName = newName == null ? UserObject.getUserName(currentUser) : newName;
        nameTextView.setText(lastName);
    }
    if (currrntStatus != null) {
        statusTextView.setTextColor(statusColor);
        statusTextView.setText(currrntStatus);
    } else if (currentUser != null) {
        if (currentUser.bot) {
            statusTextView.setTextColor(statusColor);
            if (currentUser.bot_chat_history || isAdmin) {
                statusTextView.setText(LocaleController.getString("BotStatusRead", R.string.BotStatusRead));
            } else {
                statusTextView.setText(LocaleController.getString("BotStatusCantRead", R.string.BotStatusCantRead));
            }
        } else {
            if (currentUser.id == UserConfig.getInstance(currentAccount).getClientUserId() || currentUser.status != null && currentUser.status.expires > ConnectionsManager.getInstance(currentAccount).getCurrentTime() || MessagesController.getInstance(currentAccount).onlinePrivacy.containsKey(currentUser.id)) {
                statusTextView.setTextColor(statusOnlineColor);
                statusTextView.setText(LocaleController.getString("Online", R.string.Online));
            } else {
                statusTextView.setTextColor(statusColor);
                statusTextView.setText(LocaleController.formatUserStatus(currentAccount, currentUser));
            }
        }
    }
    avatarImageView.setImage(photo, "50_50", avatarDrawable);
}
 
Example 20
Source File: GroupCreateUserCell.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
public void update(int mask) {
    if (currentUser == null) {
        return;
    }
    TLRPC.FileLocation photo = null;
    String newName = null;
    if (currentUser.photo != null) {
        photo = currentUser.photo.photo_small;
    }

    if (mask != 0) {
        boolean continueUpdate = false;
        if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0) {
            if (lastAvatar != null && photo == null || lastAvatar == null && photo != null && lastAvatar != null && photo != null && (lastAvatar.volume_id != photo.volume_id || lastAvatar.local_id != photo.local_id)) {
                continueUpdate = true;
            }
        }
        if (currentUser != null && currentStatus == null && !continueUpdate && (mask & MessagesController.UPDATE_MASK_STATUS) != 0) {
            int newStatus = 0;
            if (currentUser.status != null) {
                newStatus = currentUser.status.expires;
            }
            if (newStatus != lastStatus) {
                continueUpdate = true;
            }
        }
        if (!continueUpdate && currentName == null && lastName != null && (mask & MessagesController.UPDATE_MASK_NAME) != 0) {
            newName = UserObject.getUserName(currentUser);
            if (!newName.equals(lastName)) {
                continueUpdate = true;
            }
        }
        if (!continueUpdate) {
            return;
        }
    }

    avatarDrawable.setInfo(currentUser);
    lastStatus = currentUser.status != null ? currentUser.status.expires : 0;

    if (currentName != null) {
        lastName = null;
        nameTextView.setText(currentName, true);
    } else {
        lastName = newName == null ? UserObject.getUserName(currentUser) : newName;
        nameTextView.setText(lastName);
    }

    if (currentStatus != null) {
        statusTextView.setText(currentStatus, true);
        statusTextView.setTag(Theme.key_groupcreate_offlineText);
        statusTextView.setTextColor(Theme.getColor(Theme.key_groupcreate_offlineText));
    } else {
        if (currentUser.bot) {
            statusTextView.setTag(Theme.key_groupcreate_offlineText);
            statusTextView.setTextColor(Theme.getColor(Theme.key_groupcreate_offlineText));
            statusTextView.setText(LocaleController.getString("Bot", R.string.Bot));
        } else {
            if (currentUser.id == UserConfig.getInstance(currentAccount).getClientUserId() || currentUser.status != null && currentUser.status.expires > ConnectionsManager.getInstance(currentAccount).getCurrentTime() || MessagesController.getInstance(currentAccount).onlinePrivacy.containsKey(currentUser.id)) {
                statusTextView.setTag(Theme.key_groupcreate_offlineText);
                statusTextView.setTextColor(Theme.getColor(Theme.key_groupcreate_onlineText));
                statusTextView.setText(LocaleController.getString("Online", R.string.Online));
            } else {
                statusTextView.setTag(Theme.key_groupcreate_offlineText);
                statusTextView.setTextColor(Theme.getColor(Theme.key_groupcreate_offlineText));
                statusTextView.setText(LocaleController.formatUserStatus(currentAccount, currentUser));
            }
        }
    }

    avatarImageView.setImage(photo, "50_50", avatarDrawable);
}