Java Code Examples for org.telegram.ui.Cells.UserCell#setData()
The following examples show how to use
org.telegram.ui.Cells.UserCell#setData() .
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: PhonebookSearchAdapter.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
@Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { if (holder.getItemViewType() == 0) { UserCell userCell = (UserCell) holder.itemView; Object object = getItem(position); TLRPC.User user = null; if (object instanceof ContactsController.Contact) { ContactsController.Contact contact = (ContactsController.Contact) object; if (contact.user != null) { user = contact.user; } else { userCell.setCurrentId(contact.contact_id); userCell.setData(null, searchResultNames.get(position), contact.phones.isEmpty() ? "" : PhoneFormat.getInstance().format(contact.phones.get(0)), 0); } } else { user = (TLRPC.User) object; } if (user != null) { userCell.setData(user, searchResultNames.get(position), PhoneFormat.getInstance().format("+" + user.phone), 0); } } }
Example 2
Source File: PhonebookAdapter.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
@Override public void onBindViewHolder(int section, int position, RecyclerView.ViewHolder holder) { switch (holder.getItemViewType()) { case 0: UserCell userCell = (UserCell) holder.itemView; Object object = getItem(section, position); TLRPC.User user = null; if (object instanceof ContactsController.Contact) { ContactsController.Contact contact = (ContactsController.Contact) object; if (contact.user != null) { user = contact.user; } else { userCell.setCurrentId(contact.contact_id); userCell.setData(null, ContactsController.formatName(contact.first_name, contact.last_name), contact.phones.isEmpty() ? "" : PhoneFormat.getInstance().format(contact.phones.get(0)), 0); } } else { user = (TLRPC.User) object; } if (user != null) { userCell.setData(user, null, PhoneFormat.getInstance().format("+" + user.phone), 0); } break; } }
Example 3
Source File: PhonebookSearchAdapter.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
@Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { if (holder.getItemViewType() == 0) { UserCell userCell = (UserCell) holder.itemView; Object object = getItem(position); TLRPC.User user = null; if (object instanceof ContactsController.Contact) { ContactsController.Contact contact = (ContactsController.Contact) object; if (contact.user != null) { user = contact.user; } else { userCell.setCurrentId(contact.contact_id); userCell.setData(null, searchResultNames.get(position), contact.phones.isEmpty() ? "" : PhoneFormat.getInstance().format(contact.phones.get(0)), 0); } } else { user = (TLRPC.User) object; } if (user != null) { userCell.setData(user, searchResultNames.get(position), PhoneFormat.getInstance().format("+" + user.phone), 0); } } }
Example 4
Source File: PhonebookAdapter.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
@Override public void onBindViewHolder(int section, int position, RecyclerView.ViewHolder holder) { switch (holder.getItemViewType()) { case 0: UserCell userCell = (UserCell) holder.itemView; Object object = getItem(section, position); TLRPC.User user = null; if (object instanceof ContactsController.Contact) { ContactsController.Contact contact = (ContactsController.Contact) object; if (contact.user != null) { user = contact.user; } else { userCell.setCurrentId(contact.contact_id); userCell.setData(null, ContactsController.formatName(contact.first_name, contact.last_name), contact.phones.isEmpty() ? "" : PhoneFormat.getInstance().format(contact.phones.get(0)), 0); } } else { user = (TLRPC.User) object; } if (user != null) { userCell.setData(user, null, PhoneFormat.getInstance().format("+" + user.phone), 0); } break; } }
Example 5
Source File: SetAdminsActivity.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { switch (holder.getItemViewType()) { case 0: TextCheckCell checkCell = (TextCheckCell) holder.itemView; chat = MessagesController.getInstance(currentAccount).getChat(chat_id); checkCell.setTextAndCheck(LocaleController.getString("SetAdminsAll", R.string.SetAdminsAll), chat != null && !chat.admins_enabled, false); break; case 1: TextInfoPrivacyCell privacyCell = (TextInfoPrivacyCell) holder.itemView; if (position == allAdminsInfoRow) { if (chat.admins_enabled) { privacyCell.setText(LocaleController.getString("SetAdminsNotAllInfo", R.string.SetAdminsNotAllInfo)); } else { privacyCell.setText(LocaleController.getString("SetAdminsAllInfo", R.string.SetAdminsAllInfo)); } if (usersStartRow != -1) { privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow)); } else { privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow)); } } else if (position == usersEndRow) { privacyCell.setText(""); privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow)); } break; case 2: UserCell userCell = (UserCell) holder.itemView; TLRPC.ChatParticipant part = participants.get(position - usersStartRow); TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(part.user_id); userCell.setData(user, null, null, 0); chat = MessagesController.getInstance(currentAccount).getChat(chat_id); userCell.setChecked(!(part instanceof TLRPC.TL_chatParticipant) || chat != null && !chat.admins_enabled, false); userCell.setCheckDisabled(chat == null || !chat.admins_enabled || part.user_id == UserConfig.getInstance(currentAccount).getClientUserId()); break; } }
Example 6
Source File: SetAdminsActivity.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { switch (holder.getItemViewType()) { case 0: TextCheckCell checkCell = (TextCheckCell) holder.itemView; chat = MessagesController.getInstance(currentAccount).getChat(chat_id); checkCell.setTextAndCheck(LocaleController.getString("SetAdminsAll", R.string.SetAdminsAll), chat != null && !chat.admins_enabled, false); break; case 1: TextInfoPrivacyCell privacyCell = (TextInfoPrivacyCell) holder.itemView; if (position == allAdminsInfoRow) { if (chat.admins_enabled) { privacyCell.setText(LocaleController.getString("SetAdminsNotAllInfo", R.string.SetAdminsNotAllInfo)); } else { privacyCell.setText(LocaleController.getString("SetAdminsAllInfo", R.string.SetAdminsAllInfo)); } if (usersStartRow != -1) { privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow)); } else { privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow)); } } else if (position == usersEndRow) { privacyCell.setText(""); privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow)); } break; case 2: UserCell userCell = (UserCell) holder.itemView; TLRPC.ChatParticipant part = participants.get(position - usersStartRow); TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(part.user_id); userCell.setData(user, null, null, 0); chat = MessagesController.getInstance(currentAccount).getChat(chat_id); userCell.setChecked(!(part instanceof TLRPC.TL_chatParticipant) || chat != null && !chat.admins_enabled, false); userCell.setCheckDisabled(chat == null || !chat.admins_enabled || part.user_id == UserConfig.getInstance(currentAccount).getClientUserId()); break; } }
Example 7
Source File: ContactsAdapter.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
@Override public void onBindViewHolder(int section, int position, RecyclerView.ViewHolder holder) { switch (holder.getItemViewType()) { case 0: UserCell userCell = (UserCell) holder.itemView; HashMap<String, ArrayList<TLRPC.TL_contact>> usersSectionsDict = onlyUsers == 2 ? ContactsController.getInstance(currentAccount).usersMutualSectionsDict : ContactsController.getInstance(currentAccount).usersSectionsDict; ArrayList<String> sortedUsersSectionsArray = onlyUsers == 2 ? ContactsController.getInstance(currentAccount).sortedUsersMutualSectionsArray : ContactsController.getInstance(currentAccount).sortedUsersSectionsArray; ArrayList<TLRPC.TL_contact> arr = usersSectionsDict.get(sortedUsersSectionsArray.get(section - (onlyUsers != 0 && !isAdmin ? 0 : 1))); TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(arr.get(position).user_id); userCell.setData(user, null, null, 0); if (checkedMap != null) { userCell.setChecked(checkedMap.indexOfKey(user.id) >= 0, !scrolling); } if (ignoreUsers != null) { if (ignoreUsers.indexOfKey(user.id) >= 0) { userCell.setAlpha(0.5f); } else { userCell.setAlpha(1.0f); } } break; case 1: TextCell textCell = (TextCell) holder.itemView; if (section == 0) { if (needPhonebook) { textCell.setTextAndIcon(LocaleController.getString("InviteFriends", R.string.InviteFriends), R.drawable.menu_invite); } else if (isAdmin) { textCell.setTextAndIcon(LocaleController.getString("InviteToGroupByLink", R.string.InviteToGroupByLink), R.drawable.menu_invite); } else { if (position == 0) { textCell.setTextAndIcon(LocaleController.getString("NewGroup", R.string.NewGroup), R.drawable.menu_newgroup); } else if (position == 1) { textCell.setTextAndIcon(LocaleController.getString("NewSecretChat", R.string.NewSecretChat), R.drawable.menu_secret); } else if (position == 2) { textCell.setTextAndIcon(LocaleController.getString("NewChannel", R.string.NewChannel), R.drawable.menu_broadcast); } } } else { ContactsController.Contact contact = ContactsController.getInstance(currentAccount).phoneBookContacts.get(position); if (contact.first_name != null && contact.last_name != null) { textCell.setText(contact.first_name + " " + contact.last_name); } else if (contact.first_name != null && contact.last_name == null) { textCell.setText(contact.first_name); } else { textCell.setText(contact.last_name); } } break; } }
Example 8
Source File: ContactsAdapter.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
@Override public void onBindViewHolder(int section, int position, RecyclerView.ViewHolder holder) { switch (holder.getItemViewType()) { case 0: UserCell userCell = (UserCell) holder.itemView; HashMap<String, ArrayList<TLRPC.TL_contact>> usersSectionsDict = onlyUsers == 2 ? ContactsController.getInstance(currentAccount).usersMutualSectionsDict : ContactsController.getInstance(currentAccount).usersSectionsDict; ArrayList<String> sortedUsersSectionsArray = onlyUsers == 2 ? ContactsController.getInstance(currentAccount).sortedUsersMutualSectionsArray : ContactsController.getInstance(currentAccount).sortedUsersSectionsArray; ArrayList<TLRPC.TL_contact> arr = usersSectionsDict.get(sortedUsersSectionsArray.get(section - (onlyUsers != 0 && !isAdmin ? 0 : 1))); TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(arr.get(position).user_id); userCell.setData(user, null, null, 0); if (checkedMap != null) { userCell.setChecked(checkedMap.indexOfKey(user.id) >= 0, !scrolling); } if (ignoreUsers != null) { if (ignoreUsers.indexOfKey(user.id) >= 0) { userCell.setAlpha(0.5f); } else { userCell.setAlpha(1.0f); } } break; case 1: TextCell textCell = (TextCell) holder.itemView; if (section == 0) { if (needPhonebook) { textCell.setTextAndIcon(LocaleController.getString("InviteFriends", R.string.InviteFriends), R.drawable.menu_invite); } else if (isAdmin) { textCell.setTextAndIcon(LocaleController.getString("InviteToGroupByLink", R.string.InviteToGroupByLink), R.drawable.menu_invite); } else { if (position == 0) { textCell.setTextAndIcon(LocaleController.getString("NewGroup", R.string.NewGroup), R.drawable.menu_newgroup); } else if (position == 1) { textCell.setTextAndIcon(LocaleController.getString("NewSecretChat", R.string.NewSecretChat), R.drawable.menu_secret); } else if (position == 2) { textCell.setTextAndIcon(LocaleController.getString("NewChannel", R.string.NewChannel), R.drawable.menu_broadcast); } } } else { ContactsController.Contact contact = ContactsController.getInstance(currentAccount).phoneBookContacts.get(position); if (contact.first_name != null && contact.last_name != null) { textCell.setText(contact.first_name + " " + contact.last_name); } else if (contact.first_name != null && contact.last_name == null) { textCell.setText(contact.first_name); } else { textCell.setText(contact.last_name); } } break; } }
Example 9
Source File: ContactsAdapter.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
@Override public void onBindViewHolder(int section, int position, RecyclerView.ViewHolder holder) { switch (holder.getItemViewType()) { case 0: UserCell userCell = (UserCell) holder.itemView; userCell.setAvatarPadding(sortType == 2 || disableSections ? 6 : 58); ArrayList<TLRPC.TL_contact> arr; if (sortType == 2) { arr = onlineContacts; } else { HashMap<String, ArrayList<TLRPC.TL_contact>> usersSectionsDict = onlyUsers == 2 ? ContactsController.getInstance(currentAccount).usersMutualSectionsDict : ContactsController.getInstance(currentAccount).usersSectionsDict; ArrayList<String> sortedUsersSectionsArray = onlyUsers == 2 ? ContactsController.getInstance(currentAccount).sortedUsersMutualSectionsArray : ContactsController.getInstance(currentAccount).sortedUsersSectionsArray; arr = usersSectionsDict.get(sortedUsersSectionsArray.get(section - (onlyUsers != 0 && !isAdmin ? 0 : 1))); } TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(arr.get(position).user_id); userCell.setData(user, null, null, 0); if (checkedMap != null) { userCell.setChecked(checkedMap.indexOfKey(user.id) >= 0, !scrolling); } if (ignoreUsers != null) { if (ignoreUsers.indexOfKey(user.id) >= 0) { userCell.setAlpha(0.5f); } else { userCell.setAlpha(1.0f); } } break; case 1: TextCell textCell = (TextCell) holder.itemView; if (section == 0) { if (needPhonebook) { if (position == 0) { textCell.setTextAndIcon(LocaleController.getString("InviteFriends", R.string.InviteFriends), R.drawable.menu_invite, false); } else if (position == 1) { textCell.setTextAndIcon(LocaleController.getString("AddPeopleNearby", R.string.AddPeopleNearby), R.drawable.menu_location, false); } } else if (isAdmin) { if (isChannel) { textCell.setTextAndIcon(LocaleController.getString("ChannelInviteViaLink", R.string.ChannelInviteViaLink), R.drawable.profile_link, false); } else { textCell.setTextAndIcon(LocaleController.getString("InviteToGroupByLink", R.string.InviteToGroupByLink), R.drawable.profile_link, false); } } else { if (position == 0) { textCell.setTextAndIcon(LocaleController.getString("NewGroup", R.string.NewGroup), R.drawable.menu_groups, false); } else if (position == 1) { textCell.setTextAndIcon(LocaleController.getString("NewSecretChat", R.string.NewSecretChat), R.drawable.menu_secret, false); } else if (position == 2) { textCell.setTextAndIcon(LocaleController.getString("NewChannel", R.string.NewChannel), R.drawable.menu_broadcast, false); } } } else { ContactsController.Contact contact = ContactsController.getInstance(currentAccount).phoneBookContacts.get(position); if (contact.first_name != null && contact.last_name != null) { textCell.setText(contact.first_name + " " + contact.last_name, false); } else if (contact.first_name != null && contact.last_name == null) { textCell.setText(contact.first_name, false); } else { textCell.setText(contact.last_name, false); } } break; case 2: GraySectionCell sectionCell = (GraySectionCell) holder.itemView; if (sortType == 0) { sectionCell.setText(LocaleController.getString("Contacts", R.string.Contacts)); } else if (sortType == 1) { sectionCell.setText(LocaleController.getString("SortedByName", R.string.SortedByName)); } else { sectionCell.setText(LocaleController.getString("SortedByLastSeen", R.string.SortedByLastSeen)); } break; } }
Example 10
Source File: ContactsAdapter.java From Telegram with GNU General Public License v2.0 | 4 votes |
@Override public void onBindViewHolder(int section, int position, RecyclerView.ViewHolder holder) { switch (holder.getItemViewType()) { case 0: UserCell userCell = (UserCell) holder.itemView; userCell.setAvatarPadding(sortType == 2 || disableSections ? 6 : 58); ArrayList<TLRPC.TL_contact> arr; if (sortType == 2) { arr = onlineContacts; } else { HashMap<String, ArrayList<TLRPC.TL_contact>> usersSectionsDict = onlyUsers == 2 ? ContactsController.getInstance(currentAccount).usersMutualSectionsDict : ContactsController.getInstance(currentAccount).usersSectionsDict; ArrayList<String> sortedUsersSectionsArray = onlyUsers == 2 ? ContactsController.getInstance(currentAccount).sortedUsersMutualSectionsArray : ContactsController.getInstance(currentAccount).sortedUsersSectionsArray; arr = usersSectionsDict.get(sortedUsersSectionsArray.get(section - (onlyUsers != 0 && !isAdmin ? 0 : 1))); } TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(arr.get(position).user_id); userCell.setData(user, null, null, 0); if (checkedMap != null) { userCell.setChecked(checkedMap.indexOfKey(user.id) >= 0, !scrolling); } if (ignoreUsers != null) { if (ignoreUsers.indexOfKey(user.id) >= 0) { userCell.setAlpha(0.5f); } else { userCell.setAlpha(1.0f); } } break; case 1: TextCell textCell = (TextCell) holder.itemView; if (section == 0) { if (needPhonebook) { if (position == 0) { textCell.setTextAndIcon(LocaleController.getString("InviteFriends", R.string.InviteFriends), R.drawable.menu_invite, false); } else if (position == 1) { textCell.setTextAndIcon(LocaleController.getString("AddPeopleNearby", R.string.AddPeopleNearby), R.drawable.menu_location, false); } } else if (isAdmin) { if (isChannel) { textCell.setTextAndIcon(LocaleController.getString("ChannelInviteViaLink", R.string.ChannelInviteViaLink), R.drawable.profile_link, false); } else { textCell.setTextAndIcon(LocaleController.getString("InviteToGroupByLink", R.string.InviteToGroupByLink), R.drawable.profile_link, false); } } else { if (position == 0) { textCell.setTextAndIcon(LocaleController.getString("NewGroup", R.string.NewGroup), R.drawable.menu_groups, false); } else if (position == 1) { textCell.setTextAndIcon(LocaleController.getString("NewSecretChat", R.string.NewSecretChat), R.drawable.menu_secret, false); } else if (position == 2) { textCell.setTextAndIcon(LocaleController.getString("NewChannel", R.string.NewChannel), R.drawable.menu_broadcast, false); } } } else { ContactsController.Contact contact = ContactsController.getInstance(currentAccount).phoneBookContacts.get(position); if (contact.first_name != null && contact.last_name != null) { textCell.setText(contact.first_name + " " + contact.last_name, false); } else if (contact.first_name != null && contact.last_name == null) { textCell.setText(contact.first_name, false); } else { textCell.setText(contact.last_name, false); } } break; case 2: GraySectionCell sectionCell = (GraySectionCell) holder.itemView; if (sortType == 0) { sectionCell.setText(LocaleController.getString("Contacts", R.string.Contacts)); } else if (sortType == 1) { sectionCell.setText(LocaleController.getString("SortedByName", R.string.SortedByName)); } else { sectionCell.setText(LocaleController.getString("SortedByLastSeen", R.string.SortedByLastSeen)); } break; } }