org.telegram.tgnet.TLRPC Java Examples
The following examples show how to use
org.telegram.tgnet.TLRPC.
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 TelePlus-Android with GNU General Public License v2.0 | 6 votes |
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 #2
Source File: ChatUsersActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
private void updateParticipantWithRights(TLRPC.ChannelParticipant channelParticipant, TLRPC.TL_chatAdminRights rightsAdmin, TLRPC.TL_chatBannedRights rightsBanned, int user_id, boolean withDelegate) { boolean delegateCalled = false; for (int a = 0; a < 3; a++) { SparseArray<TLObject> map; if (a == 0) { map = contactsMap; } else if (a == 1) { map = botsMap; } else { map = participantsMap; } TLObject p = map.get(channelParticipant.user_id); if (p instanceof TLRPC.ChannelParticipant) { channelParticipant = (TLRPC.ChannelParticipant) p; channelParticipant.admin_rights = rightsAdmin; channelParticipant.banned_rights = rightsBanned; if (withDelegate) { channelParticipant.promoted_by = getUserConfig().getClientUserId(); } } if (withDelegate && p != null && !delegateCalled && delegate != null) { delegateCalled = true; delegate.didAddParticipantToList(user_id, p); } } }
Example #3
Source File: ChannelAdminLogActivity.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
private String getMessageContent(MessageObject messageObject, int previousUid, boolean name) { String str = ""; if (name) { if (previousUid != messageObject.messageOwner.from_id) { if (messageObject.messageOwner.from_id > 0) { TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(messageObject.messageOwner.from_id); if (user != null) { str = ContactsController.formatName(user.first_name, user.last_name) + ":\n"; } } else if (messageObject.messageOwner.from_id < 0) { TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(-messageObject.messageOwner.from_id); if (chat != null) { str = chat.title + ":\n"; } } } } if (messageObject.type == 0 && messageObject.messageOwner.message != null) { str += messageObject.messageOwner.message; } else if (messageObject.messageOwner.media != null && messageObject.messageOwner.message != null) { str += messageObject.messageOwner.message; } else { str += messageObject.messageText; } return str; }
Example #4
Source File: FilterTabsView.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
public void setIsEditing(boolean value) { isEditing = value; editingForwardAnimation = true; listView.invalidateViews(); invalidate(); if (!isEditing && orderChanged) { MessagesStorage.getInstance(UserConfig.selectedAccount).saveDialogFiltersOrder(); TLRPC.TL_messages_updateDialogFiltersOrder req = new TLRPC.TL_messages_updateDialogFiltersOrder(); ArrayList<MessagesController.DialogFilter> filters = MessagesController.getInstance(UserConfig.selectedAccount).dialogFilters; for (int a = 0, N = filters.size(); a < N; a++) { MessagesController.DialogFilter filter = filters.get(a); req.order.add(filters.get(a).id); } ConnectionsManager.getInstance(UserConfig.selectedAccount).sendRequest(req, (response, error) -> { }); orderChanged = false; } }
Example #5
Source File: ChatAttachAlert.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
@Override public PhotoViewer.PlaceProviderObject getPlaceForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int index) { PhotoAttachPhotoCell cell = getCellForIndex(index); if (cell != null) { int coords[] = new int[2]; cell.getImageView().getLocationInWindow(coords); if (Build.VERSION.SDK_INT < 26) { coords[0] -= getLeftInset(); } PhotoViewer.PlaceProviderObject object = new PhotoViewer.PlaceProviderObject(); object.viewX = coords[0]; object.viewY = coords[1]; object.parentView = attachPhotoRecyclerView; object.imageReceiver = cell.getImageView().getImageReceiver(); object.thumb = object.imageReceiver.getBitmapSafe(); object.scale = cell.getImageView().getScaleX(); cell.showCheck(false); return object; } return null; }
Example #6
Source File: SecretChatHelper.java From Telegram with GNU General Public License v2.0 | 6 votes |
private TLRPC.Message createDeleteMessage(int mid, int seq_out, int seq_in, long random_id, TLRPC.EncryptedChat encryptedChat) { TLRPC.TL_messageService newMsg = new TLRPC.TL_messageService(); newMsg.action = new TLRPC.TL_messageEncryptedAction(); newMsg.action.encryptedAction = new TLRPC.TL_decryptedMessageActionDeleteMessages(); newMsg.action.encryptedAction.random_ids.add(random_id); newMsg.local_id = newMsg.id = mid; newMsg.from_id = getUserConfig().getClientUserId(); newMsg.unread = true; newMsg.out = true; newMsg.flags = TLRPC.MESSAGE_FLAG_HAS_FROM_ID; newMsg.dialog_id = ((long) encryptedChat.id) << 32; newMsg.to_id = new TLRPC.TL_peerUser(); newMsg.send_state = MessageObject.MESSAGE_SEND_STATE_SENDING; newMsg.seq_in = seq_in; newMsg.seq_out = seq_out; if (encryptedChat.participant_id == getUserConfig().getClientUserId()) { newMsg.to_id.user_id = encryptedChat.admin_id; } else { newMsg.to_id.user_id = encryptedChat.participant_id; } newMsg.date = 0; newMsg.random_id = random_id; return newMsg; }
Example #7
Source File: WebFile.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
public static WebFile createWithGeoPoint(double lat, double _long, long access_hash, int w, int h, int zoom, int scale) { WebFile webFile = new WebFile(); TLRPC.TL_inputWebFileGeoPointLocation location = new TLRPC.TL_inputWebFileGeoPointLocation(); webFile.location = location; location.geo_point = webFile.geo_point = new TLRPC.TL_inputGeoPoint(); location.access_hash = access_hash; webFile.geo_point.lat = lat; webFile.geo_point._long = _long; location.w = webFile.w = w; location.h = webFile.h = h; location.zoom = webFile.zoom = zoom; location.scale = webFile.scale = scale; webFile.mime_type = "image/png"; webFile.url = String.format(Locale.US, "maps_%.6f_%.6f_%d_%d_%d_%d.png", lat, _long, w, h, zoom, scale); webFile.attributes = new ArrayList<>(); return webFile; }
Example #8
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 #9
Source File: FileRefController.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
private byte[] getFileReference(TLRPC.User user, TLRPC.InputFileLocation location, boolean[] needReplacement, TLRPC.InputFileLocation[] replacement) { if (user == null || user.photo == null || !(location instanceof TLRPC.TL_inputFileLocation)) { return null; } byte[] result = getFileReference(user.photo.photo_small, location, needReplacement); if (getPeerReferenceReplacement(user, null, false, location, replacement, needReplacement)) { return new byte[0]; } if (result == null) { result = getFileReference(user.photo.photo_big, location, needReplacement); if (getPeerReferenceReplacement(user, null, true, location, replacement, needReplacement)) { return new byte[0]; } } return result; }
Example #10
Source File: PollVotesAlert.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
public void setData(TLRPC.User user, int num, boolean divider) { currentUser = user; needDivider = divider; drawPlaceholder = user == null; placeholderNum = num; if (user == null) { nameTextView.setText(""); avatarImageView.setImageDrawable(null); } else { update(0); } if (animators != null) { animators.add(ObjectAnimator.ofFloat(avatarImageView, View.ALPHA, 0.0f, 1.0f)); animators.add(ObjectAnimator.ofFloat(nameTextView, View.ALPHA, 0.0f, 1.0f)); animators.add(ObjectAnimator.ofFloat(this, USER_CELL_PROPERTY, 1.0f, 0.0f)); } else if (!drawPlaceholder) { placeholderAlpha = 0.0f; } }
Example #11
Source File: GroupInviteActivity.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
@Override public void didReceivedNotification(int id, int account, Object... args) { if (id == NotificationCenter.chatInfoDidLoaded) { TLRPC.ChatFull info = (TLRPC.ChatFull) args[0]; int guid = (int) args[1]; if (info.id == chat_id && guid == classGuid) { invite = MessagesController.getInstance(currentAccount).getExportedInvite(chat_id); if (!(invite instanceof TLRPC.TL_chatInviteExported)) { generateLink(false); } else { loading = false; if (listAdapter != null) { listAdapter.notifyDataSetChanged(); } } } } }
Example #12
Source File: ImageLoader.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
public static void fillPhotoSizeWithBytes(TLRPC.PhotoSize photoSize) { if (photoSize == null || photoSize.bytes != null) { return; } File file = FileLoader.getPathToAttach(photoSize, true); try { RandomAccessFile f = new RandomAccessFile(file, "r"); int len = (int) f.length(); if (len < 20000) { photoSize.bytes = new byte[(int) f.length()]; f.readFully(photoSize.bytes, 0, photoSize.bytes.length); } } catch (Throwable e) { FileLog.e(e); } }
Example #13
Source File: PhotoPaintView.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
public ArrayList<TLRPC.InputDocument> getMasks() { ArrayList<TLRPC.InputDocument> result = null; int count = entitiesView.getChildCount(); for (int a = 0; a < count; a++) { View child = entitiesView.getChildAt(a); if (child instanceof StickerView) { TLRPC.Document document = ((StickerView) child).getSticker(); if (result == null) { result = new ArrayList<>(); } TLRPC.TL_inputDocument inputDocument = new TLRPC.TL_inputDocument(); inputDocument.id = document.id; inputDocument.access_hash = document.access_hash; result.add(inputDocument); } } return result; }
Example #14
Source File: ContactsController.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
private int getContactsHash(ArrayList<TLRPC.TL_contact> contacts) { long acc = 0; contacts = new ArrayList<>(contacts); Collections.sort(contacts, new Comparator<TLRPC.TL_contact>() { @Override public int compare(TLRPC.TL_contact tl_contact, TLRPC.TL_contact tl_contact2) { if (tl_contact.user_id > tl_contact2.user_id) { return 1; } else if (tl_contact.user_id < tl_contact2.user_id) { return -1; } return 0; } }); int count = contacts.size(); for (int a = -1; a < count; a++) { if (a == -1) { acc = ((acc * 20261) + 0x80000000L + UserConfig.getInstance(currentAccount).contactsSavedCount) % 0x80000000L; } else { TLRPC.TL_contact set = contacts.get(a); acc = ((acc * 20261) + 0x80000000L + set.user_id) % 0x80000000L; } } return (int) acc; }
Example #15
Source File: GroupInviteActivity.java From Telegram with GNU General Public License v2.0 | 6 votes |
@Override public void didReceivedNotification(int id, int account, Object... args) { if (id == NotificationCenter.chatInfoDidLoad) { TLRPC.ChatFull info = (TLRPC.ChatFull) args[0]; int guid = (int) args[1]; if (info.id == chat_id && guid == classGuid) { invite = MessagesController.getInstance(currentAccount).getExportedInvite(chat_id); if (!(invite instanceof TLRPC.TL_chatInviteExported)) { generateLink(false); } else { loading = false; if (listAdapter != null) { listAdapter.notifyDataSetChanged(); } } } } }
Example #16
Source File: ChannelAdminLogActivity.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
private void loadAdmins() { TLRPC.TL_channels_getParticipants req = new TLRPC.TL_channels_getParticipants(); req.channel = MessagesController.getInputChannel(currentChat); req.filter = new TLRPC.TL_channelParticipantsAdmins(); req.offset = 0; req.limit = 200; int reqId = ConnectionsManager.getInstance(currentAccount).sendRequest(req, new RequestDelegate() { @Override public void run(final TLObject response, final TLRPC.TL_error error) { AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { if (error == null) { TLRPC.TL_channels_channelParticipants res = (TLRPC.TL_channels_channelParticipants) response; MessagesController.getInstance(currentAccount).putUsers(res.users, false); admins = res.participants; if (visibleDialog instanceof AdminLogFilterAlert) { ((AdminLogFilterAlert) visibleDialog).setCurrentAdmins(admins); } } } }); } }); ConnectionsManager.getInstance(currentAccount).bindRequestToGuid(reqId, classGuid); }
Example #17
Source File: TrendingStickersLayout.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
@Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { switch (holder.getItemViewType()) { case 0: TLRPC.Document sticker = (TLRPC.Document) cache.get(position); ((StickerEmojiCell) holder.itemView).setSticker(sticker, positionsToSets.get(position), false); break; case 1: ((EmptyCell) holder.itemView).setHeight(AndroidUtilities.dp(82)); break; case 2: case 5: bindStickerSetCell(holder.itemView, position, false); break; case 4: ((GraySectionCell) holder.itemView).setText(LocaleController.getString("OtherStickers", R.string.OtherStickers)); break; } }
Example #18
Source File: ThemePreviewActivity.java From Telegram with GNU General Public License v2.0 | 6 votes |
private void selectPattern(int position) { TLRPC.TL_wallPaper wallPaper; if (position >= 0 && position < patterns.size()) { wallPaper = (TLRPC.TL_wallPaper) patterns.get(position); } else { wallPaper = lastSelectedPattern; } if (wallPaper == null) { return; } backgroundImage.setImage(ImageLocation.getForDocument(wallPaper.document), imageFilter, null, null, "jpg", wallPaper.document.size, 1, wallPaper); selectedPattern = wallPaper; if (screenType == SCREEN_TYPE_ACCENT_COLOR) { isMotion = checkBoxView[0].isChecked(); } else { isMotion = checkBoxView[2].isChecked(); } updateButtonState(false, true); }
Example #19
Source File: ChatUsersActivity.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
@Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { switch (holder.getItemViewType()) { case 0: ManageChatUserCell userCell = (ManageChatUserCell) holder.itemView; userCell.setTag(position); TLRPC.ChatParticipant participant = getItem(position); TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(participant.user_id); if (user != null) { userCell.setData(user, null, null); } break; case 1: TextInfoPrivacyCell privacyCell = (TextInfoPrivacyCell) holder.itemView; if (position == participantsInfoRow) { privacyCell.setText(""); } break; } }
Example #20
Source File: ImageLoader.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private void replaceImageInCacheInternal(final String oldKey, final String newKey, final TLRPC.FileLocation newLocation) { ArrayList<String> arr = memCache.getFilterKeys(oldKey); if (arr != null) { for (int a = 0; a < arr.size(); a++) { String filter = arr.get(a); String oldK = oldKey + "@" + filter; String newK = newKey + "@" + filter; performReplace(oldK, newK); NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.didReplacedPhotoInMemCache, oldK, newK, newLocation); } } else { performReplace(oldKey, newKey); NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.didReplacedPhotoInMemCache, oldKey, newKey, newLocation); } }
Example #21
Source File: MediaController.java From Telegram with GNU General Public License v2.0 | 5 votes |
public void setLastVisibleMessageIds(int account, long enterTime, long leaveTime, TLRPC.User user, TLRPC.EncryptedChat encryptedChat, ArrayList<Long> visibleMessages, int visibleMessage) { lastChatEnterTime = enterTime; lastChatLeaveTime = leaveTime; lastChatAccount = account; lastSecretChat = encryptedChat; lastUser = user; lastMessageId = visibleMessage; lastChatVisibleMessages = visibleMessages; }
Example #22
Source File: PaymentInfoCell.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
public void setInvoice(TLRPC.TL_messageMediaInvoice invoice, String botname) { nameTextView.setText(invoice.title); detailTextView.setText(invoice.description); detailExTextView.setText(botname); int maxPhotoWidth; if (AndroidUtilities.isTablet()) { maxPhotoWidth = (int) (AndroidUtilities.getMinTabletSide() * 0.7f); } else { maxPhotoWidth = (int) (Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) * 0.7f); } int width = 640; int height = 360; float scale = width / (float) (maxPhotoWidth - AndroidUtilities.dp(2)); width /= scale; height /= scale; if (invoice.photo != null && invoice.photo.mime_type.startsWith("image/")) { nameTextView.setLayoutParams(LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 10 : 123, 9, LocaleController.isRTL ? 123 : 10, 0)); detailTextView.setLayoutParams(LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 10 : 123, 33, LocaleController.isRTL ? 123 : 10, 0)); detailExTextView.setLayoutParams(LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 10 : 123, 90, LocaleController.isRTL ? 123 : 10, 0)); imageView.setVisibility(VISIBLE); String filter = String.format(Locale.US, "%d_%d", width, height); imageView.getImageReceiver().setImage(ImageLocation.getForWebFile(WebFile.createWithWebDocument(invoice.photo)), filter, null, null, -1, null, invoice, 1); } else { nameTextView.setLayoutParams(LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 17, 9, 17, 0)); detailTextView.setLayoutParams(LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 17, 33, 17, 0)); detailExTextView.setLayoutParams(LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 17, 90, 17, 0)); imageView.setVisibility(GONE); } }
Example #23
Source File: PrivacySettingsActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
@Override public void onFragmentDestroy() { super.onFragmentDestroy(); getNotificationCenter().removeObserver(this, NotificationCenter.privacyRulesUpdated); getNotificationCenter().removeObserver(this, NotificationCenter.blockedUsersDidLoad); getNotificationCenter().removeObserver(this, NotificationCenter.didSetOrRemoveTwoStepPassword); if (currentSync != newSync) { getUserConfig().syncContacts = newSync; getUserConfig().saveConfig(false); if (newSync) { getContactsController().forceImportContacts(); if (getParentActivity() != null) { Toast.makeText(getParentActivity(), LocaleController.getString("SyncContactsAdded", R.string.SyncContactsAdded), Toast.LENGTH_SHORT).show(); } } } if (newSuggest != currentSuggest) { if (!newSuggest) { getMediaDataController().clearTopPeers(); } getUserConfig().suggestContacts = newSuggest; getUserConfig().saveConfig(false); TLRPC.TL_contacts_toggleTopPeers req = new TLRPC.TL_contacts_toggleTopPeers(); req.enabled = newSuggest; getConnectionsManager().sendRequest(req, (response, error) -> { }); } }
Example #24
Source File: TwoStepVerificationActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
public void setCurrentPasswordParams(TLRPC.TL_account_password password, byte[] passwordHash, long secretId, byte[] secret) { currentPassword = password; currentPasswordHash = passwordHash; currentSecret = secret; currentSecretId = secretId; passwordEntered = currentPasswordHash != null && currentPasswordHash.length > 0 || !currentPassword.has_password; }
Example #25
Source File: SearchAdapterHelper.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
public void mergeResults(ArrayList<TLObject> localResults) { localSearchResults = localResults; if (globalSearchMap.size() == 0 || localResults == null) { return; } int count = localResults.size(); for (int a = 0; a < count; a++) { TLObject obj = localResults.get(a); if (obj instanceof TLRPC.User) { TLRPC.User user = (TLRPC.User) obj; TLRPC.User u = (TLRPC.User) globalSearchMap.get(user.id); if (u != null) { globalSearch.remove(u); localServerSearch.remove(u); globalSearchMap.remove(u.id); } TLObject participant = groupSearchMap.get(user.id); if (participant != null) { groupSearch.remove(participant); groupSearchMap.remove(user.id); } Object object = phoneSearchMap.get(user.id); if (object != null) { phonesSearch.remove(object); phoneSearchMap.remove(user.id); } } else if (obj instanceof TLRPC.Chat) { TLRPC.Chat chat = (TLRPC.Chat) obj; TLRPC.Chat c = (TLRPC.Chat) globalSearchMap.get(-chat.id); if (c != null) { globalSearch.remove(c); localServerSearch.remove(c); globalSearchMap.remove(-c.id); } } } }
Example #26
Source File: EmojiView.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@Override public int getItemViewType(int position) { Object object = cache.get(position); if (object != null) { if (object instanceof TLRPC.Document) { return 0; } else { return 2; } } return 1; }
Example #27
Source File: MediaActivity.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@Override public PhotoViewer.PlaceProviderObject getPlaceForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int index) { if (messageObject == null || mediaPages[0].selectedType != 0) { return null; } int count = mediaPages[0].listView.getChildCount(); for (int a = 0; a < count; a++) { View view = mediaPages[0].listView.getChildAt(a); if (view instanceof SharedPhotoVideoCell) { SharedPhotoVideoCell cell = (SharedPhotoVideoCell) view; for (int i = 0; i < 6; i++) { MessageObject message = cell.getMessageObject(i); if (message == null) { break; } BackupImageView imageView = cell.getImageView(i); if (message.getId() == messageObject.getId()) { int coords[] = new int[2]; imageView.getLocationInWindow(coords); PhotoViewer.PlaceProviderObject object = new PhotoViewer.PlaceProviderObject(); object.viewX = coords[0]; object.viewY = coords[1] - (Build.VERSION.SDK_INT >= 21 ? 0 : AndroidUtilities.statusBarHeight); object.parentView = mediaPages[0].listView; object.imageReceiver = imageView.getImageReceiver(); object.thumb = object.imageReceiver.getBitmapSafe(); object.parentView.getLocationInWindow(coords); object.clipTopAddition = AndroidUtilities.dp(40); return object; } } } } return null; }
Example #28
Source File: ContactsController.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private void performWriteContactsToPhoneBookInternal(ArrayList<TLRPC.TL_contact> contactsArray) { Cursor cursor = null; try { if (!hasContactsPermission()) { return; } Uri rawContactUri = ContactsContract.RawContacts.CONTENT_URI.buildUpon().appendQueryParameter(ContactsContract.RawContacts.ACCOUNT_NAME, systemAccount.name).appendQueryParameter(ContactsContract.RawContacts.ACCOUNT_TYPE, systemAccount.type).build(); cursor = ApplicationLoader.applicationContext.getContentResolver().query(rawContactUri, new String[]{BaseColumns._ID, ContactsContract.RawContacts.SYNC2}, null, null, null); SparseLongArray bookContacts = new SparseLongArray(); if (cursor != null) { while (cursor.moveToNext()) { bookContacts.put(cursor.getInt(1), cursor.getLong(0)); } cursor.close(); cursor = null; for (int a = 0; a < contactsArray.size(); a++) { TLRPC.TL_contact u = contactsArray.get(a); if (bookContacts.indexOfKey(u.user_id) < 0) { TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(u.user_id); addContactToPhoneBook(user, false); } } } } catch (Exception e) { FileLog.e(e); } finally { if (cursor != null) { cursor.close(); } } }
Example #29
Source File: WallpapersListActivity.java From Telegram with GNU General Public License v2.0 | 5 votes |
private String getWallPaperSlug(Object object) { if (object instanceof TLRPC.TL_wallPaper) { return ((TLRPC.TL_wallPaper) object).slug; } else if (object instanceof ColorWallpaper) { return ((ColorWallpaper) object).slug; } else if (object instanceof FileWallpaper) { return ((FileWallpaper) object).slug; } else { return null; } }
Example #30
Source File: ChannelAdminLogActivity.java From Telegram with GNU General Public License v2.0 | 5 votes |
private void addCanBanUser(Bundle bundle, int uid) { if (!currentChat.megagroup || admins == null || !ChatObject.canBlockUsers(currentChat)) { return; } for (int a = 0; a < admins.size(); a++) { TLRPC.ChannelParticipant channelParticipant = admins.get(a); if (channelParticipant.user_id == uid) { if (!channelParticipant.can_edit) { return; } break; } } bundle.putInt("ban_chat_id", currentChat.id); }