Java Code Examples for org.telegram.tgnet.TLRPC#TL_dialog
The following examples show how to use
org.telegram.tgnet.TLRPC#TL_dialog .
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: HintDialogCell.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
public void checkUnreadCounter(int mask) { if (mask != 0 && (mask & MessagesController.UPDATE_MASK_READ_DIALOG_MESSAGE) == 0 && (mask & MessagesController.UPDATE_MASK_NEW_MESSAGE) == 0) { return; } TLRPC.TL_dialog dialog = MessagesController.getInstance(currentAccount).dialogs_dict.get(dialog_id); if (dialog != null && dialog.unread_count != 0) { if (lastUnreadCount != dialog.unread_count) { lastUnreadCount = dialog.unread_count; String countString = String.format("%d", dialog.unread_count); countWidth = Math.max(AndroidUtilities.dp(12), (int) Math.ceil(Theme.dialogs_countTextPaint.measureText(countString))); countLayout = new StaticLayout(countString, Theme.dialogs_countTextPaint, countWidth, Layout.Alignment.ALIGN_CENTER, 1.0f, 0.0f, false); if (mask != 0) { invalidate(); } } } else if (countLayout != null) { if (mask != 0) { invalidate(); } lastUnreadCount = 0; countLayout = null; } }
Example 2
Source File: DialogObject.java From Telegram with GNU General Public License v2.0 | 6 votes |
public static void initDialog(TLRPC.Dialog dialog) { if (dialog == null || dialog.id != 0) { return; } if (dialog instanceof TLRPC.TL_dialog) { if (dialog.peer == null) { return; } if (dialog.peer.user_id != 0) { dialog.id = dialog.peer.user_id; } else if (dialog.peer.chat_id != 0) { dialog.id = -dialog.peer.chat_id; } else { dialog.id = -dialog.peer.channel_id; } } else if (dialog instanceof TLRPC.TL_dialogFolder) { TLRPC.TL_dialogFolder dialogFolder = (TLRPC.TL_dialogFolder) dialog; dialog.id = makeFolderDialogId(dialogFolder.folder.id); } }
Example 3
Source File: DialogCell.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
public void checkCurrentDialogIndex() { if (index < getDialogsArray().size()) { TLRPC.TL_dialog dialog = getDialogsArray().get(index); TLRPC.DraftMessage newDraftMessage = DataQuery.getInstance(currentAccount).getDraft(currentDialogId); MessageObject newMessageObject = MessagesController.getInstance(currentAccount).dialogMessage.get(dialog.id); if (currentDialogId != dialog.id || message != null && message.getId() != dialog.top_message || newMessageObject != null && newMessageObject.messageOwner.edit_date != currentEditDate || unreadCount != dialog.unread_count || mentionCount != dialog.unread_mentions_count || markUnread != dialog.unread_mark || message != newMessageObject || message == null && newMessageObject != null || newDraftMessage != draftMessage || drawPin != dialog.pinned) { currentDialogId = dialog.id; update(0); } } }
Example 4
Source File: DialogCell.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
public void checkCurrentDialogIndex() { if (index < getDialogsArray().size()) { TLRPC.TL_dialog dialog = getDialogsArray().get(index); TLRPC.DraftMessage newDraftMessage = DataQuery.getInstance(currentAccount).getDraft(currentDialogId); MessageObject newMessageObject = MessagesController.getInstance(currentAccount).dialogMessage.get(dialog.id); if (currentDialogId != dialog.id || message != null && message.getId() != dialog.top_message || newMessageObject != null && newMessageObject.messageOwner.edit_date != currentEditDate || unreadCount != dialog.unread_count || mentionCount != dialog.unread_mentions_count || markUnread != dialog.unread_mark || message != newMessageObject || message == null && newMessageObject != null || newDraftMessage != draftMessage || drawPin != dialog.pinned) { currentDialogId = dialog.id; update(0); } } }
Example 5
Source File: DialogsAdapter.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@Override public int getItemCount() { showContacts = false; ArrayList<TLRPC.TL_dialog> array = getDialogsArray(); int dialogsCount = array.size(); if (dialogsCount == 0 && MessagesController.getInstance(currentAccount).loadingDialogs) { return 0; } int count = dialogsCount; if (!MessagesController.getInstance(currentAccount).dialogsEndReached || dialogsCount == 0) { count++; } if (hasHints) { count += 2 + MessagesController.getInstance(currentAccount).hintDialogs.size(); } else if (dialogsType == MessagesController.DialogType.All && dialogsCount == 0) { if (ContactsController.getInstance(currentAccount).contacts.isEmpty() && ContactsController.getInstance(currentAccount).isLoadingContacts()) { return 0; } if (!ContactsController.getInstance(currentAccount).contacts.isEmpty()) { count += ContactsController.getInstance(currentAccount).contacts.size() + 2; showContacts = true; } } currentCount = count; return count; }
Example 6
Source File: DialogsAdapter.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public TLObject getItem(int i) { if (showContacts) { i -= 3; if (i < 0 || i >= ContactsController.getInstance(currentAccount).contacts.size()) { return null; } return MessagesController.getInstance(currentAccount).getUser(ContactsController.getInstance(currentAccount).contacts.get(i).user_id); } ArrayList<TLRPC.TL_dialog> arrayList = getDialogsArray(); if (hasHints) { int count = MessagesController.getInstance(currentAccount).hintDialogs.size(); if (i < 2 + count) { return MessagesController.getInstance(currentAccount).hintDialogs.get(i - 1); } else { i -= count + 2; } } if (i < 0 || i >= arrayList.size()) { return null; } return arrayList.get(i); }
Example 7
Source File: DialogsSearchAdapter.java From TelePlus-Android 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 = DataQuery.getInstance(currentAccount).hints.get(position); TLRPC.TL_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 = ContactsController.formatName(user.first_name, user.last_name); } else if (chat != null) { name = chat.title; } cell.setDialog(did, true, name); }
Example 8
Source File: DialogsActivity.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private ArrayList<TLRPC.TL_dialog> getDialogsArray() { if (dialogsAdapter != null) return dialogsAdapter.getDialogsArray(); return null; }
Example 9
Source File: ShareAlert.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@Override public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { ShareDialogCell cell = (ShareDialogCell) holder.itemView; TLRPC.TL_dialog dialog = getItem(position); cell.setDialog((int) dialog.id, selectedDialogs.indexOfKey(dialog.id) >= 0, null); }
Example 10
Source File: ShareAlert.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public TLRPC.TL_dialog getItem(int i) { ArrayList<TLRPC.TL_dialog> dialogs = getDialogs(); if (dialogs == null || (i < 0 || i >= dialogs.size())) return null; return dialogs.get(i); }
Example 11
Source File: ShareAlert.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private ArrayList<TLRPC.TL_dialog> getDialogs() { if (changed || dialogsList == null) { changed = false; dialogsList = new ArrayList<>(); ArrayList<TLRPC.TL_dialog> dialogs = MessagesController.getDialogs(currentAccount, dialogsType); for (TLRPC.TL_dialog dialog : dialogs) { int lower_id = (int) dialog.id; int high_id = (int) (dialog.id >> 32); if (lower_id != 0 && high_id != 1) { if (lower_id > 0) { dialogsList.add(dialog); } else { TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(-lower_id); if (!(chat == null || ChatObject.isNotInChat(chat) || ChatObject.isChannel(chat) && !chat.creator && (chat.admin_rights == null || !chat.admin_rights.post_messages) && !chat.megagroup)) { dialogsList.add(dialog); } } } } } return dialogsList; }
Example 12
Source File: ShareAlert.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@Override public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { ShareDialogCell cell = (ShareDialogCell) holder.itemView; TLRPC.TL_dialog dialog = getItem(position); cell.setDialog((int) dialog.id, selectedDialogs.indexOfKey(dialog.id) >= 0, null); }
Example 13
Source File: ProfileSearchCell.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
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 14
Source File: DialogObject.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
public static boolean isChannel(TLRPC.TL_dialog dialog) { return dialog != null && (dialog.flags & 1) != 0; }
Example 15
Source File: DialogObject.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
public static boolean isChannel(TLRPC.TL_dialog dialog) { return dialog != null && (dialog.flags & 1) != 0; }
Example 16
Source File: ProfileSearchCell.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
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: DialogCell.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
private ArrayList<TLRPC.TL_dialog> getDialogsArray() { return MessagesController.getDialogs(currentAccount, dialogsType); }
Example 18
Source File: DialogsAdapter.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
public ArrayList<TLRPC.TL_dialog> getDialogsArray() { return MessagesController.getDialogs(currentAccount, dialogsType); }
Example 19
Source File: DialogsAdapter.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
public ArrayList<TLRPC.TL_dialog> getDialogsArray() { return MessagesController.getDialogs(currentAccount, dialogsType); }
Example 20
Source File: SecretChatHelper.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
protected void processUpdateEncryption(TLRPC.TL_updateEncryption update, ConcurrentHashMap<Integer, TLRPC.User> usersDict) { final TLRPC.EncryptedChat newChat = update.chat; long dialog_id = ((long) newChat.id) << 32; TLRPC.EncryptedChat existingChat = MessagesController.getInstance(currentAccount).getEncryptedChatDB(newChat.id, false); if (newChat instanceof TLRPC.TL_encryptedChatRequested && existingChat == null) { int user_id = newChat.participant_id; if (user_id == UserConfig.getInstance(currentAccount).getClientUserId()) { user_id = newChat.admin_id; } TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(user_id); if (user == null) { user = usersDict.get(user_id); } newChat.user_id = user_id; final TLRPC.TL_dialog dialog = new TLRPC.TL_dialog(); dialog.id = dialog_id; dialog.unread_count = 0; dialog.top_message = 0; dialog.last_message_date = update.date; MessagesController.getInstance(currentAccount).putEncryptedChat(newChat, false); AndroidUtilities.runOnUIThread(() -> { MessagesController.getInstance(currentAccount).dialogs_dict.put(dialog.id, dialog); MessagesController.getInstance(currentAccount).dialogs.add(dialog); MessagesController.getInstance(currentAccount).sortDialogs(null); NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.dialogsNeedReload); }); MessagesStorage.getInstance(currentAccount).putEncryptedChat(newChat, user, dialog); acceptSecretChat(newChat); } else if (newChat instanceof TLRPC.TL_encryptedChat) { if (existingChat != null && existingChat instanceof TLRPC.TL_encryptedChatWaiting && (existingChat.auth_key == null || existingChat.auth_key.length == 1)) { newChat.a_or_b = existingChat.a_or_b; newChat.user_id = existingChat.user_id; processAcceptedSecretChat(newChat); } else if (existingChat == null && startingSecretChat) { delayedEncryptedChatUpdates.add(update); } } else { final TLRPC.EncryptedChat exist = existingChat; if (exist != null) { newChat.user_id = exist.user_id; newChat.auth_key = exist.auth_key; newChat.key_create_date = exist.key_create_date; newChat.key_use_count_in = exist.key_use_count_in; newChat.key_use_count_out = exist.key_use_count_out; newChat.ttl = exist.ttl; newChat.seq_in = exist.seq_in; newChat.seq_out = exist.seq_out; newChat.admin_id = exist.admin_id; newChat.mtproto_seq = exist.mtproto_seq; } AndroidUtilities.runOnUIThread(() -> { if (exist != null) { MessagesController.getInstance(currentAccount).putEncryptedChat(newChat, false); } MessagesStorage.getInstance(currentAccount).updateEncryptedChat(newChat); NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.encryptedChatUpdated, newChat); }); } }