Java Code Examples for org.telegram.messenger.UserObject#getFirstName()
The following examples show how to use
org.telegram.messenger.UserObject#getFirstName() .
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: DialogsSearchAdapter.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
@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 2
Source File: DialogsSearchAdapter.java From Telegram with GNU General Public License v2.0 | 5 votes |
@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 3
Source File: GroupCreateSpan.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
public GroupCreateSpan(Context context, TLRPC.User user, ContactsController.Contact contact) { super(context); currentContact = contact; deleteDrawable = getResources().getDrawable(R.drawable.delete); textPaint.setTextSize(AndroidUtilities.dp(14)); avatarDrawable = new AvatarDrawable(); avatarDrawable.setTextSize(AndroidUtilities.dp(12)); if (user != null) { avatarDrawable.setInfo(user); uid = user.id; } else { avatarDrawable.setInfo(0, contact.first_name, contact.last_name, false); uid = contact.contact_id; key = contact.key; } imageReceiver = new ImageReceiver(); imageReceiver.setRoundRadius(AndroidUtilities.dp(16)); imageReceiver.setParentView(this); imageReceiver.setImageCoords(0, 0, AndroidUtilities.dp(32), AndroidUtilities.dp(32)); int maxNameWidth; if (AndroidUtilities.isTablet()) { maxNameWidth = AndroidUtilities.dp(530 - 32 - 18 - 57 * 2) / 2; } else { maxNameWidth = (Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) - AndroidUtilities.dp(32 + 18 + 57 * 2)) / 2; } String firstName; if (user != null) { firstName = UserObject.getFirstName(user); } else { if (!TextUtils.isEmpty(contact.first_name)) { firstName = contact.first_name; } else { firstName = contact.last_name; } } CharSequence name = TextUtils.ellipsize(firstName.replace('\n', ' '), textPaint, maxNameWidth, TextUtils.TruncateAt.END); nameLayout = new StaticLayout(name, textPaint, 1000, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); if (nameLayout.getLineCount() > 0) { textWidth = (int) Math.ceil(nameLayout.getLineWidth(0)); textX = -nameLayout.getLineLeft(0); } TLRPC.FileLocation photo = null; if (user != null && user.photo != null) { photo = user.photo.photo_small; } imageReceiver.setImage(photo, null, "50_50", avatarDrawable, null, null, 0, null, 1); updateColors(); }
Example 4
Source File: GroupCreateSpan.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
public GroupCreateSpan(Context context, TLRPC.User user, ContactsController.Contact contact) { super(context); currentContact = contact; deleteDrawable = getResources().getDrawable(R.drawable.delete); textPaint.setTextSize(AndroidUtilities.dp(14)); avatarDrawable = new AvatarDrawable(); avatarDrawable.setTextSize(AndroidUtilities.dp(12)); if (user != null) { avatarDrawable.setInfo(user); uid = user.id; } else { avatarDrawable.setInfo(0, contact.first_name, contact.last_name, false); uid = contact.contact_id; key = contact.key; } imageReceiver = new ImageReceiver(); imageReceiver.setRoundRadius(AndroidUtilities.dp(16)); imageReceiver.setParentView(this); imageReceiver.setImageCoords(0, 0, AndroidUtilities.dp(32), AndroidUtilities.dp(32)); int maxNameWidth; if (AndroidUtilities.isTablet()) { maxNameWidth = AndroidUtilities.dp(530 - 32 - 18 - 57 * 2) / 2; } else { maxNameWidth = (Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) - AndroidUtilities.dp(32 + 18 + 57 * 2)) / 2; } String firstName; if (user != null) { firstName = UserObject.getFirstName(user); } else { if (!TextUtils.isEmpty(contact.first_name)) { firstName = contact.first_name; } else { firstName = contact.last_name; } } CharSequence name = TextUtils.ellipsize(firstName.replace('\n', ' '), textPaint, maxNameWidth, TextUtils.TruncateAt.END); nameLayout = new StaticLayout(name, textPaint, 1000, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); if (nameLayout.getLineCount() > 0) { textWidth = (int) Math.ceil(nameLayout.getLineWidth(0)); textX = -nameLayout.getLineLeft(0); } TLRPC.FileLocation photo = null; if (user != null && user.photo != null) { photo = user.photo.photo_small; } imageReceiver.setImage(photo, null, "50_50", avatarDrawable, null, null, 0, null, 1); updateColors(); }