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

The following examples show how to use org.telegram.messenger.MessagesController#UPDATE_MASK_CHAT_AVATAR . 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: 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 2
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 3
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 4
Source File: ProfileSearchCell.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;
    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();
}