org.telegram.messenger.UserObject Java Examples

The following examples show how to use org.telegram.messenger.UserObject. 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: ChatAvatarContainer.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
public void setUserAvatar(TLRPC.User user) {
    TLRPC.FileLocation newPhoto = null;
    avatarDrawable.setInfo(user);
    if (UserObject.isUserSelf(user)) {
        avatarDrawable.setAvatarType(AvatarDrawable.AVATAR_TYPE_SAVED);
        avatarDrawable.setSmallSize(true);
        if (avatarImageView != null) {
            avatarImageView.setImage(null, null, avatarDrawable, user);
        }
    } else {
        avatarDrawable.setSmallSize(false);
        if (avatarImageView != null) {
            avatarImageView.setImage(ImageLocation.getForUser(user, false), "50_50", avatarDrawable, user);
        }
    }
}
 
Example #2
Source File: ChatAvatarContainer.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
public void setUserAvatar(TLRPC.User user) {
    TLRPC.FileLocation newPhoto = null;
    avatarDrawable.setInfo(user);
    if (UserObject.isUserSelf(user)) {
        avatarDrawable.setAvatarType(AvatarDrawable.AVATAR_TYPE_SAVED);
        avatarDrawable.setSmallSize(true);
        if (avatarImageView != null) {
            avatarImageView.setImage(null, null, avatarDrawable, user);
        }
    } else {
        avatarDrawable.setSmallSize(false);
        if (avatarImageView != null) {
            avatarImageView.setImage(ImageLocation.getForUser(user, false), "50_50", avatarDrawable, user);
        }
    }
}
 
Example #3
Source File: DrawerProfileCell.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public void setUser(TLRPC.User user, boolean accounts) {
    if (user == null) {
        return;
    }
    TLRPC.FileLocation photo = null;
    if (user.photo != null) {
        photo = user.photo.photo_small;
    }
    accountsShowed = accounts;
    arrowView.setImageResource(accountsShowed ? R.drawable.collapse_up : R.drawable.collapse_down);
    nameTextView.setText(UserObject.getUserName(user));
    phoneTextView.setText(PhoneFormat.getInstance().format("+" + user.phone));
    AvatarDrawable avatarDrawable = new AvatarDrawable(user);
    avatarDrawable.setColor(Theme.getColor(Theme.key_avatar_backgroundInProfileBlue));
    avatarImageView.setImage(photo, "50_50", avatarDrawable);
}
 
Example #4
Source File: MentionCell.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public void setUser(TLRPC.User user) {
    if (user == null) {
        nameTextView.setText("");
        usernameTextView.setText("");
        imageView.setImageDrawable(null);
        return;
    }
    avatarDrawable.setInfo(user);
    if (user.photo != null && user.photo.photo_small != null) {
        imageView.setImage(user.photo.photo_small, "50_50", avatarDrawable);
    } else {
        imageView.setImageDrawable(avatarDrawable);
    }
    nameTextView.setText(UserObject.getUserName(user));
    if (user.username != null) {
        usernameTextView.setText("@" + user.username);
    } else {
        usernameTextView.setText("");
    }
    imageView.setVisibility(VISIBLE);
    usernameTextView.setVisibility(VISIBLE);
}
 
Example #5
Source File: ChatAvatarContainer.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public void checkAndUpdateAvatar() {
    if (parentFragment == null) {
        return;
    }
    TLRPC.FileLocation newPhoto = null;
    TLRPC.User user = parentFragment.getCurrentUser();
    TLRPC.Chat chat = parentFragment.getCurrentChat();
    if (user != null) {
        avatarDrawable.setInfo(user);
        if (UserObject.isUserSelf(user)) {
            avatarDrawable.setSavedMessages(2);
        } else if (user.photo != null) {
            newPhoto = user.photo.photo_small;
        }
    } else if (chat != null) {
        if (chat.photo != null) {
            newPhoto = chat.photo.photo_small;
        }
        avatarDrawable.setInfo(chat);
    }
    if (avatarImageView != null) {
        avatarImageView.setImage(newPhoto, "50_50", avatarDrawable);
    }
}
 
Example #6
Source File: SettingsActivity.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
private void updateUserData() {
    TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(UserConfig.getInstance(currentAccount).getClientUserId());
    TLRPC.FileLocation photo = null;
    TLRPC.FileLocation photoBig = null;
    if (user.photo != null) {
        photo = user.photo.photo_small;
        photoBig = user.photo.photo_big;
    }
    avatarDrawable = new AvatarDrawable(user, true);

    avatarDrawable.setColor(Theme.getColor(Theme.key_avatar_backgroundInProfileBlue));
    if (avatarImage != null) {
        avatarImage.setImage(photo, "50_50", avatarDrawable);
        avatarImage.getImageReceiver().setVisible(!PhotoViewer.isShowingImage(photoBig), false);

        nameTextView.setText(UserObject.getUserName(user));
        onlineTextView.setText(LocaleController.getString("Online", R.string.Online));

        avatarImage.getImageReceiver().setVisible(!PhotoViewer.isShowingImage(photoBig), false);
    }
}
 
Example #7
Source File: SettingsActivity.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
private void updateUserData() {
    TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(UserConfig.getInstance(currentAccount).getClientUserId());
    TLRPC.FileLocation photo = null;
    TLRPC.FileLocation photoBig = null;
    if (user.photo != null) {
        photo = user.photo.photo_small;
        photoBig = user.photo.photo_big;
    }
    avatarDrawable = new AvatarDrawable(user, true);

    avatarDrawable.setColor(Theme.getColor(Theme.key_avatar_backgroundInProfileBlue));
    if (avatarImage != null) {
        avatarImage.setImage(photo, "50_50", avatarDrawable);
        avatarImage.getImageReceiver().setVisible(!PhotoViewer.isShowingImage(photoBig), false);

        nameTextView.setText(UserObject.getUserName(user));
        onlineTextView.setText(LocaleController.getString("Online", R.string.Online));

        avatarImage.getImageReceiver().setVisible(!PhotoViewer.isShowingImage(photoBig), false);
    }
}
 
Example #8
Source File: MentionCell.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public void setUser(TLRPC.User user) {
    if (user == null) {
        nameTextView.setText("");
        usernameTextView.setText("");
        imageView.setImageDrawable(null);
        return;
    }
    avatarDrawable.setInfo(user);
    if (user.photo != null && user.photo.photo_small != null) {
        imageView.setImage(user.photo.photo_small, "50_50", avatarDrawable);
    } else {
        imageView.setImageDrawable(avatarDrawable);
    }
    nameTextView.setText(UserObject.getUserName(user));
    if (user.username != null) {
        usernameTextView.setText("@" + user.username);
    } else {
        usernameTextView.setText("");
    }
    imageView.setVisibility(VISIBLE);
    usernameTextView.setVisibility(VISIBLE);
}
 
Example #9
Source File: DrawerProfileCell.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public void setUser(TLRPC.User user, boolean accounts) {
    if (user == null) {
        return;
    }
    TLRPC.FileLocation photo = null;
    if (user.photo != null) {
        photo = user.photo.photo_small;
    }
    accountsShowed = accounts;
    arrowView.setImageResource(accountsShowed ? R.drawable.collapse_up : R.drawable.collapse_down);
    nameTextView.setText(UserObject.getUserName(user));
    phoneTextView.setText(PhoneFormat.getInstance().format("+" + user.phone));
    AvatarDrawable avatarDrawable = new AvatarDrawable(user);
    avatarDrawable.setColor(Theme.getColor(Theme.key_avatar_backgroundInProfileBlue));
    avatarImageView.setImage(photo, "50_50", avatarDrawable);
}
 
Example #10
Source File: MentionCell.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
public void setUser(TLRPC.User user) {
    if (user == null) {
        nameTextView.setText("");
        usernameTextView.setText("");
        imageView.setImageDrawable(null);
        return;
    }
    avatarDrawable.setInfo(user);
    if (user.photo != null && user.photo.photo_small != null) {
        imageView.setImage(ImageLocation.getForUser(user, false), "50_50", avatarDrawable, user);
    } else {
        imageView.setImageDrawable(avatarDrawable);
    }
    nameTextView.setText(UserObject.getUserName(user));
    if (user.username != null) {
        usernameTextView.setText("@" + user.username);
    } else {
        usernameTextView.setText("");
    }
    imageView.setVisibility(VISIBLE);
    usernameTextView.setVisibility(VISIBLE);
}
 
Example #11
Source File: ChatAvatarContainer.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public void checkAndUpdateAvatar() {
    if (parentFragment == null) {
        return;
    }
    TLRPC.FileLocation newPhoto = null;
    TLRPC.User user = parentFragment.getCurrentUser();
    TLRPC.Chat chat = parentFragment.getCurrentChat();
    if (user != null) {
        avatarDrawable.setInfo(user);
        if (UserObject.isUserSelf(user)) {
            avatarDrawable.setSavedMessages(2);
        } else if (user.photo != null) {
            newPhoto = user.photo.photo_small;
        }
    } else if (chat != null) {
        if (chat.photo != null) {
            newPhoto = chat.photo.photo_small;
        }
        avatarDrawable.setInfo(chat);
    }
    if (avatarImageView != null) {
        avatarImageView.setImage(newPhoto, "50_50", avatarDrawable);
    }
}
 
Example #12
Source File: ContactAddActivity.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
private void updateAvatarLayout() {
    if (nameTextView == null) {
        return;
    }
    TLRPC.User user = getMessagesController().getUser(user_id);
    if (user == null) {
        return;
    }
    if (TextUtils.isEmpty(user.phone)) {
        nameTextView.setText(LocaleController.getString("MobileHidden", R.string.MobileHidden));
        infoTextView.setText(AndroidUtilities.replaceTags(LocaleController.formatString("MobileHiddenExceptionInfo", R.string.MobileHiddenExceptionInfo, UserObject.getFirstName(user))));
    } else {
        nameTextView.setText(PhoneFormat.getInstance().format("+" + user.phone));
        if (needAddException) {
            infoTextView.setText(AndroidUtilities.replaceTags(LocaleController.formatString("MobileVisibleInfo", R.string.MobileVisibleInfo, UserObject.getFirstName(user))));
        }
    }
    onlineTextView.setText(LocaleController.formatUserStatus(currentAccount, user));
    avatarImage.setImage(ImageLocation.getForUser(user, false), "50_50", avatarDrawable = new AvatarDrawable(user), user);
}
 
Example #13
Source File: SettingsActivity.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
private void updateUserData() {
    TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(UserConfig.getInstance(currentAccount).getClientUserId());
    if (user == null) {
        return;
    }
    TLRPC.FileLocation photoBig = null;
    if (user.photo != null) {
        photoBig = user.photo.photo_big;
    }
    avatarDrawable = new AvatarDrawable(user, true);

    avatarDrawable.setColor(Theme.getColor(Theme.key_avatar_backgroundInProfileBlue));
    if (avatarImage != null) {
        avatarImage.setImage(ImageLocation.getForUser(user, false), "50_50", avatarDrawable, user);
        avatarImage.getImageReceiver().setVisible(!PhotoViewer.isShowingImage(photoBig), false);

        nameTextView.setText(UserObject.getUserName(user));
        onlineTextView.setText(LocaleController.getString("Online", R.string.Online));

        avatarImage.getImageReceiver().setVisible(!PhotoViewer.isShowingImage(photoBig), false);
    }
}
 
Example #14
Source File: MentionCell.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
public void setUser(TLRPC.User user) {
    if (user == null) {
        nameTextView.setText("");
        usernameTextView.setText("");
        imageView.setImageDrawable(null);
        return;
    }
    avatarDrawable.setInfo(user);
    if (user.photo != null && user.photo.photo_small != null) {
        imageView.setImage(ImageLocation.getForUser(user, false), "50_50", avatarDrawable, user);
    } else {
        imageView.setImageDrawable(avatarDrawable);
    }
    nameTextView.setText(UserObject.getUserName(user));
    if (user.username != null) {
        usernameTextView.setText("@" + user.username);
    } else {
        usernameTextView.setText("");
    }
    imageView.setVisibility(VISIBLE);
    usernameTextView.setVisibility(VISIBLE);
}
 
Example #15
Source File: SettingsActivity.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
private void updateUserData() {
    TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(UserConfig.getInstance(currentAccount).getClientUserId());
    if (user == null) {
        return;
    }
    TLRPC.FileLocation photoBig = null;
    if (user.photo != null) {
        photoBig = user.photo.photo_big;
    }
    avatarDrawable = new AvatarDrawable(user, true);

    avatarDrawable.setColor(Theme.getColor(Theme.key_avatar_backgroundInProfileBlue));
    if (avatarImage != null) {
        avatarImage.setImage(ImageLocation.getForUser(user, false), "50_50", avatarDrawable, user);
        avatarImage.getImageReceiver().setVisible(!PhotoViewer.isShowingImage(photoBig), false);

        nameTextView.setText(UserObject.getUserName(user));
        onlineTextView.setText(LocaleController.getString("Online", R.string.Online));

        avatarImage.getImageReceiver().setVisible(!PhotoViewer.isShowingImage(photoBig), false);
    }
}
 
Example #16
Source File: ContactAddActivity.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
private void updateAvatarLayout() {
    if (nameTextView == null) {
        return;
    }
    TLRPC.User user = getMessagesController().getUser(user_id);
    if (user == null) {
        return;
    }
    if (TextUtils.isEmpty(user.phone)) {
        nameTextView.setText(LocaleController.getString("MobileHidden", R.string.MobileHidden));
        infoTextView.setText(AndroidUtilities.replaceTags(LocaleController.formatString("MobileHiddenExceptionInfo", R.string.MobileHiddenExceptionInfo, UserObject.getFirstName(user))));
    } else {
        nameTextView.setText(PhoneFormat.getInstance().format("+" + user.phone));
        if (needAddException) {
            infoTextView.setText(AndroidUtilities.replaceTags(LocaleController.formatString("MobileVisibleInfo", R.string.MobileVisibleInfo, UserObject.getFirstName(user))));
        }
    }
    onlineTextView.setText(LocaleController.formatUserStatus(currentAccount, user));
    avatarImage.setImage(ImageLocation.getForUser(user, false), "50_50", avatarDrawable = new AvatarDrawable(user), user);
}
 
Example #17
Source File: ChatAvatarContainer.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
public void checkAndUpdateAvatar() {
    if (parentFragment == null) {
        return;
    }
    TLRPC.User user = parentFragment.getCurrentUser();
    TLRPC.Chat chat = parentFragment.getCurrentChat();
    if (user != null) {
        avatarDrawable.setInfo(user);
        if (UserObject.isUserSelf(user)) {
            avatarDrawable.setSmallSize(true);
            avatarDrawable.setAvatarType(AvatarDrawable.AVATAR_TYPE_SAVED);
            if (avatarImageView != null) {
                avatarImageView.setImage(null, null, avatarDrawable, user);
            }
        } else {
            avatarDrawable.setSmallSize(false);
            if (avatarImageView != null) {
                avatarImageView.setImage(ImageLocation.getForUser(user, false), "50_50", avatarDrawable, user);
            }
        }
    } else if (chat != null) {
        avatarDrawable.setInfo(chat);
        if (avatarImageView != null) {
            avatarImageView.setImage(ImageLocation.getForChat(chat, false), "50_50", avatarDrawable, chat);
        }
    }
}
 
Example #18
Source File: ChatAvatarContainer.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public void checkAndUpdateAvatar() {
    if (parentFragment == null) {
        return;
    }
    TLRPC.User user = parentFragment.getCurrentUser();
    TLRPC.Chat chat = parentFragment.getCurrentChat();
    if (user != null) {
        avatarDrawable.setInfo(user);
        if (UserObject.isUserSelf(user)) {
            avatarDrawable.setSmallSize(true);
            avatarDrawable.setAvatarType(AvatarDrawable.AVATAR_TYPE_SAVED);
            if (avatarImageView != null) {
                avatarImageView.setImage(null, null, avatarDrawable, user);
            }
        } else {
            avatarDrawable.setSmallSize(false);
            if (avatarImageView != null) {
                avatarImageView.setImage(ImageLocation.getForUser(user, false), "50_50", avatarDrawable, user);
            }
        }
    } else if (chat != null) {
        avatarDrawable.setInfo(chat);
        if (avatarImageView != null) {
            avatarImageView.setImage(ImageLocation.getForChat(chat, false), "50_50", avatarDrawable, chat);
        }
    }
}
 
Example #19
Source File: ShareDialogCell.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
public void setDialog(int uid, boolean checked, CharSequence name) {
    TLRPC.FileLocation photo = null;
    if (uid > 0) {
        TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(uid);
        avatarDrawable.setInfo(user);
        if (UserObject.isUserSelf(user)) {
            nameTextView.setText(LocaleController.getString("SavedMessages", R.string.SavedMessages));
            avatarDrawable.setSavedMessages(1);
        } else {
            if (name != null) {
                nameTextView.setText(name);
            } else if (user != null) {
                nameTextView.setText(ContactsController.formatName(user.first_name, user.last_name));
            } else {
                nameTextView.setText("");
            }
            if (user != null && user.photo != null) {
                photo = user.photo.photo_small;
            }
        }
    } else {
        TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(-uid);
        if (name != null) {
            nameTextView.setText(name);
        } else if (chat != null) {
            nameTextView.setText(chat.title);
        } else {
            nameTextView.setText("");
        }
        avatarDrawable.setInfo(chat);
        if (chat != null && chat.photo != null) {
            photo = chat.photo.photo_small;
        }
    }
    imageView.setImage(photo, "50_50", avatarDrawable);
    checkBox.setChecked(checked, false);
}
 
Example #20
Source File: PopupNotificationActivity.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
private void updateSubtitle() {
    if (actionBar == null || currentMessageObject == null) {
        return;
    }
    if (currentChat != null || currentUser == null) {
        return;
    }
    if (currentUser.id / 1000 != 777 && currentUser.id / 1000 != 333 && ContactsController.getInstance(currentMessageObject.currentAccount).contactsDict.get(currentUser.id) == null && (ContactsController.getInstance(currentMessageObject.currentAccount).contactsDict.size() != 0 || !ContactsController.getInstance(currentMessageObject.currentAccount).isLoadingContacts())) {
        if (currentUser.phone != null && currentUser.phone.length() != 0) {
            nameTextView.setText(PhoneFormat.getInstance().format("+" + currentUser.phone));
        } else {
            nameTextView.setText(UserObject.getUserName(currentUser));
        }
    } else {
        nameTextView.setText(UserObject.getUserName(currentUser));
    }
    if (currentUser != null && currentUser.id == 777000) {
        onlineTextView.setText(LocaleController.getString("ServiceNotifications", R.string.ServiceNotifications));
    } else {
        CharSequence printString = MessagesController.getInstance(currentMessageObject.currentAccount).printingStrings.get(currentMessageObject.getDialogId());
        if (printString == null || printString.length() == 0) {
            lastPrintString = null;
            setTypingAnimation(false);
            TLRPC.User user = MessagesController.getInstance(currentMessageObject.currentAccount).getUser(currentUser.id);
            if (user != null) {
                currentUser = user;
            }
            onlineTextView.setText(LocaleController.formatUserStatus(currentMessageObject.currentAccount, currentUser));
        } else {
            lastPrintString = printString;
            onlineTextView.setText(printString);
            setTypingAnimation(true);
        }
    }
}
 
Example #21
Source File: PopupNotificationActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private void updateSubtitle() {
    if (actionBar == null || currentMessageObject == null) {
        return;
    }
    if (currentChat != null || currentUser == null) {
        return;
    }
    if (currentUser.id / 1000 != 777 && currentUser.id / 1000 != 333 && ContactsController.getInstance(currentMessageObject.currentAccount).contactsDict.get(currentUser.id) == null && (ContactsController.getInstance(currentMessageObject.currentAccount).contactsDict.size() != 0 || !ContactsController.getInstance(currentMessageObject.currentAccount).isLoadingContacts())) {
        if (currentUser.phone != null && currentUser.phone.length() != 0) {
            nameTextView.setText(PhoneFormat.getInstance().format("+" + currentUser.phone));
        } else {
            nameTextView.setText(UserObject.getUserName(currentUser));
        }
    } else {
        nameTextView.setText(UserObject.getUserName(currentUser));
    }
    if (currentUser != null && currentUser.id == 777000) {
        onlineTextView.setText(LocaleController.getString("ServiceNotifications", R.string.ServiceNotifications));
    } else {
        CharSequence printString = MessagesController.getInstance(currentMessageObject.currentAccount).printingStrings.get(currentMessageObject.getDialogId());
        if (printString == null || printString.length() == 0) {
            lastPrintString = null;
            setTypingAnimation(false);
            TLRPC.User user = MessagesController.getInstance(currentMessageObject.currentAccount).getUser(currentUser.id);
            if (user != null) {
                currentUser = user;
            }
            onlineTextView.setText(LocaleController.formatUserStatus(currentMessageObject.currentAccount, currentUser));
        } else {
            lastPrintString = printString;
            onlineTextView.setText(printString);
            setTypingAnimation(true);
        }
    }
}
 
Example #22
Source File: AvatarDrawable.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
public AvatarDrawable(TLRPC.User user, boolean profile) {
    this();
    isProfile = profile;
    if (user != null) {
        setInfo(user.id, user.first_name, user.last_name, null);
        drawDeleted = UserObject.isDeleted(user);
    }
}
 
Example #23
Source File: HintDialogCell.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
public void setDialog(int uid, boolean counter, CharSequence name) {
    dialog_id = uid;
    if (uid > 0) {
        currentUser = MessagesController.getInstance(currentAccount).getUser(uid);
        if (name != null) {
            nameTextView.setText(name);
        } else if (currentUser != null) {
            nameTextView.setText(UserObject.getFirstName(currentUser));
        } else {
            nameTextView.setText("");
        }
        avatarDrawable.setInfo(currentUser);
        imageView.setImage(ImageLocation.getForUser(currentUser, false), "50_50", avatarDrawable, currentUser);
    } else {
        TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(-uid);
        if (name != null) {
            nameTextView.setText(name);
        } else if (chat != null) {
            nameTextView.setText(chat.title);
        } else {
            nameTextView.setText("");
        }
        avatarDrawable.setInfo(chat);
        currentUser = null;
        imageView.setImage(ImageLocation.getForChat(chat, false), "50_50", avatarDrawable, chat);
    }
    if (counter) {
        update(0);
    } else {
        countLayout = null;
    }
}
 
Example #24
Source File: DialogsSearchAdapter.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    HintDialogCell cell = (HintDialogCell) holder.itemView;

    TLRPC.TL_topPeer peer = MediaDataController.getInstance(currentAccount).hints.get(position);
    TLRPC.Dialog dialog = new TLRPC.TL_dialog();
    TLRPC.Chat chat = null;
    TLRPC.User user = null;
    int did = 0;
    if (peer.peer.user_id != 0) {
        did = peer.peer.user_id;
        user = MessagesController.getInstance(currentAccount).getUser(peer.peer.user_id);
    } else if (peer.peer.channel_id != 0) {
        did = -peer.peer.channel_id;
        chat = MessagesController.getInstance(currentAccount).getChat(peer.peer.channel_id);
    } else if (peer.peer.chat_id != 0) {
        did = -peer.peer.chat_id;
        chat = MessagesController.getInstance(currentAccount).getChat(peer.peer.chat_id);
    }
    cell.setTag(did);
    String name = "";
    if (user != null) {
        name = UserObject.getFirstName(user);
    } else if (chat != null) {
        name = chat.title;
    }
    cell.setDialog(did, true, name);
}
 
Example #25
Source File: ShareDialogCell.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
public void setDialog(int uid, boolean checked, CharSequence name) {
    TLRPC.FileLocation photo = null;
    if (uid > 0) {
        TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(uid);
        avatarDrawable.setInfo(user);
        if (UserObject.isUserSelf(user)) {
            nameTextView.setText(LocaleController.getString("SavedMessages", R.string.SavedMessages));
            avatarDrawable.setSavedMessages(1);
        } else {
            if (name != null) {
                nameTextView.setText(name);
            } else if (user != null) {
                nameTextView.setText(ContactsController.formatName(user.first_name, user.last_name));
            } else {
                nameTextView.setText("");
            }
            if (user != null && user.photo != null) {
                photo = user.photo.photo_small;
            }
        }
    } else {
        TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(-uid);
        if (name != null) {
            nameTextView.setText(name);
        } else if (chat != null) {
            nameTextView.setText(chat.title);
        } else {
            nameTextView.setText("");
        }
        avatarDrawable.setInfo(chat);
        if (chat != null && chat.photo != null) {
            photo = chat.photo.photo_small;
        }
    }
    imageView.setImage(photo, "50_50", avatarDrawable);
    checkBox.setChecked(checked, false);
}
 
Example #26
Source File: AvatarDrawable.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public AvatarDrawable(TLRPC.User user, boolean profile) {
    this();
    isProfile = profile;
    if (user != null) {
        setInfo(user.id, user.first_name, user.last_name, null);
        drawDeleted = UserObject.isDeleted(user);
    }
}
 
Example #27
Source File: HintDialogCell.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public void setDialog(int uid, boolean counter, CharSequence name) {
    dialog_id = uid;
    if (uid > 0) {
        currentUser = MessagesController.getInstance(currentAccount).getUser(uid);
        if (name != null) {
            nameTextView.setText(name);
        } else if (currentUser != null) {
            nameTextView.setText(UserObject.getFirstName(currentUser));
        } else {
            nameTextView.setText("");
        }
        avatarDrawable.setInfo(currentUser);
        imageView.setImage(ImageLocation.getForUser(currentUser, false), "50_50", avatarDrawable, currentUser);
    } else {
        TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(-uid);
        if (name != null) {
            nameTextView.setText(name);
        } else if (chat != null) {
            nameTextView.setText(chat.title);
        } else {
            nameTextView.setText("");
        }
        avatarDrawable.setInfo(chat);
        currentUser = null;
        imageView.setImage(ImageLocation.getForChat(chat, false), "50_50", avatarDrawable, chat);
    }
    if (counter) {
        update(0);
    } else {
        countLayout = null;
    }
}
 
Example #28
Source File: DrawerProfileCell.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public void setUser(TLRPC.User user, boolean accounts) {
    if (user == null) {
        return;
    }
    accountsShown = accounts;
    setArrowState(false);
    nameTextView.setText(UserObject.getUserName(user));
    phoneTextView.setText(PhoneFormat.getInstance().format("+" + user.phone));
    AvatarDrawable avatarDrawable = new AvatarDrawable(user);
    avatarDrawable.setColor(Theme.getColor(Theme.key_avatar_backgroundInProfileBlue));
    avatarImageView.setImage(ImageLocation.getForUser(user, false), "50_50", avatarDrawable, user);

    applyBackground(true);
}
 
Example #29
Source File: ShareDialogCell.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public void setDialog(int uid, boolean checked, CharSequence name) {
    if (uid > 0) {
        user = MessagesController.getInstance(currentAccount).getUser(uid);
        avatarDrawable.setInfo(user);
        if (UserObject.isUserSelf(user)) {
            nameTextView.setText(LocaleController.getString("SavedMessages", R.string.SavedMessages));
            avatarDrawable.setAvatarType(AvatarDrawable.AVATAR_TYPE_SAVED);
            imageView.setImage(null, null, avatarDrawable, user);
        } else {
            if (name != null) {
                nameTextView.setText(name);
            } else if (user != null) {
                nameTextView.setText(ContactsController.formatName(user.first_name, user.last_name));
            } else {
                nameTextView.setText("");
            }
            imageView.setImage(ImageLocation.getForUser(user, false), "50_50", avatarDrawable, user);
        }
    } else {
        user = null;
        TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(-uid);
        if (name != null) {
            nameTextView.setText(name);
        } else if (chat != null) {
            nameTextView.setText(chat.title);
        } else {
            nameTextView.setText("");
        }
        avatarDrawable.setInfo(chat);
        imageView.setImage(ImageLocation.getForChat(chat, false), "50_50", avatarDrawable, chat);
    }
    checkBox.setChecked(checked, false);
}
 
Example #30
Source File: PopupNotificationActivity.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private void updateSubtitle() {
    if (actionBar == null || currentMessageObject == null) {
        return;
    }
    if (currentChat != null || currentUser == null) {
        return;
    }
    if (currentUser.id / 1000 != 777 && currentUser.id / 1000 != 333 && ContactsController.getInstance(currentMessageObject.currentAccount).contactsDict.get(currentUser.id) == null && (ContactsController.getInstance(currentMessageObject.currentAccount).contactsDict.size() != 0 || !ContactsController.getInstance(currentMessageObject.currentAccount).isLoadingContacts())) {
        if (currentUser.phone != null && currentUser.phone.length() != 0) {
            nameTextView.setText(PhoneFormat.getInstance().format("+" + currentUser.phone));
        } else {
            nameTextView.setText(UserObject.getUserName(currentUser));
        }
    } else {
        nameTextView.setText(UserObject.getUserName(currentUser));
    }
    if (currentUser != null && currentUser.id == 777000) {
        onlineTextView.setText(LocaleController.getString("ServiceNotifications", R.string.ServiceNotifications));
    } else {
        CharSequence printString = MessagesController.getInstance(currentMessageObject.currentAccount).printingStrings.get(currentMessageObject.getDialogId());
        if (printString == null || printString.length() == 0) {
            lastPrintString = null;
            setTypingAnimation(false);
            TLRPC.User user = MessagesController.getInstance(currentMessageObject.currentAccount).getUser(currentUser.id);
            if (user != null) {
                currentUser = user;
            }
            onlineTextView.setText(LocaleController.formatUserStatus(currentMessageObject.currentAccount, currentUser));
        } else {
            lastPrintString = printString;
            onlineTextView.setText(printString);
            setTypingAnimation(true);
        }
    }
}