Java Code Examples for org.telegram.tgnet.TLRPC#PhotoSize
The following examples show how to use
org.telegram.tgnet.TLRPC#PhotoSize .
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: StickersAdapter.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
private boolean checkStickerFilesExistAndDownload() { if (stickers == null) { return false; } stickersToLoad.clear(); int size = Math.min(6, stickers.size()); for (int a = 0; a < size; a++) { StickerResult result = stickers.get(a); TLRPC.PhotoSize thumb = FileLoader.getClosestPhotoSizeWithSize(result.sticker.thumbs, 90); if (thumb instanceof TLRPC.TL_photoSize) { File f = FileLoader.getPathToAttach(thumb, "webp", true); if (!f.exists()) { stickersToLoad.add(FileLoader.getAttachFileName(thumb, "webp")); FileLoader.getInstance(currentAccount).loadFile(ImageLocation.getForDocument(thumb, result.sticker), result.parent, "webp", 1, 1); } } } return stickersToLoad.isEmpty(); }
Example 2
Source File: ChannelCreateActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
@Override public void didUploadPhoto(final TLRPC.InputFile file, final TLRPC.PhotoSize bigSize, final TLRPC.PhotoSize smallSize) { AndroidUtilities.runOnUIThread(() -> { if (file != null) { uploadedAvatar = file; if (createAfterUpload) { try { if (progressDialog != null && progressDialog.isShowing()) { progressDialog.dismiss(); progressDialog = null; } } catch (Exception e) { FileLog.e(e); } donePressed = false; doneButton.performClick(); } showAvatarProgress(false, true); } else { avatar = smallSize.location; avatarBig = bigSize.location; avatarImage.setImage(ImageLocation.getForLocal(avatar), "50_50", avatarDrawable, null); showAvatarProgress(true, false); } }); }
Example 3
Source File: ImageLocation.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
public static ImageLocation getForPhoto(TLRPC.PhotoSize photoSize, TLRPC.Photo photo) { if (photoSize instanceof TLRPC.TL_photoStrippedSize) { ImageLocation imageLocation = new ImageLocation(); imageLocation.photoSize = photoSize; return imageLocation; } else if (photoSize == null || photo == null) { return null; } int dc_id; if (photo.dc_id != 0) { dc_id = photo.dc_id; } else { dc_id = photoSize.location.dc_id; } return getForPhoto(photoSize.location, photoSize.size, photo, null, null, false, dc_id, null, photoSize.type); }
Example 4
Source File: SharedAudioCell.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
public void setMessageObject(MessageObject messageObject, boolean divider) { needDivider = divider; currentMessageObject = messageObject; TLRPC.Document document = messageObject.getDocument(); TLRPC.PhotoSize thumb = document != null ? FileLoader.getClosestPhotoSizeWithSize(document.thumbs, 240) : null; if (thumb instanceof TLRPC.TL_photoSize) { radialProgress.setImageOverlay(thumb, document, messageObject); } else { String artworkUrl = messageObject.getArtworkUrl(true); if (!TextUtils.isEmpty(artworkUrl)) { radialProgress.setImageOverlay(artworkUrl); } else { radialProgress.setImageOverlay(null, null, null); } } updateButtonState(false, false); requestLayout(); }
Example 5
Source File: GroupCreateFinalActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
@Override public void didUploadPhoto(final TLRPC.InputFile file, final TLRPC.PhotoSize bigSize, final TLRPC.PhotoSize smallSize) { AndroidUtilities.runOnUIThread(() -> { if (file != null) { uploadedAvatar = file; if (createAfterUpload) { if (delegate != null) { delegate.didStartChatCreation(); } MessagesController.getInstance(currentAccount).createChat(editText.getText().toString(), selectedContacts, null, chatType, currentGroupCreateLocation, currentGroupCreateAddress, GroupCreateFinalActivity.this); } showAvatarProgress(false, true); avatarEditor.setImageDrawable(null); } else { avatar = smallSize.location; avatarBig = bigSize.location; avatarImage.setImage(ImageLocation.getForLocal(avatar), "50_50", avatarDrawable, null); showAvatarProgress(true, false); } }); }
Example 6
Source File: ChatEditActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
@Override public void didUploadPhoto(final TLRPC.InputFile file, final TLRPC.PhotoSize bigSize, final TLRPC.PhotoSize smallSize) { AndroidUtilities.runOnUIThread(() -> { if (file != null) { uploadedAvatar = file; if (createAfterUpload) { try { if (progressDialog != null && progressDialog.isShowing()) { progressDialog.dismiss(); progressDialog = null; } } catch (Exception e) { FileLog.e(e); } donePressed = false; doneButton.performClick(); } showAvatarProgress(false, true); } else { avatar = smallSize.location; avatarBig = bigSize.location; avatarImage.setImage(ImageLocation.getForLocal(avatar), "50_50", avatarDrawable, currentChat); showAvatarProgress(true, false); } }); }
Example 7
Source File: ChannelCreateActivity.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
@Override public void didUploadedPhoto(final TLRPC.InputFile file, final TLRPC.PhotoSize small, final TLRPC.PhotoSize big, final TLRPC.TL_secureFile secureFile) { AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { uploadedAvatar = file; avatar = small.location; avatarImage.setImage(avatar, "50_50", avatarDrawable); if (createAfterUpload) { try { if (progressDialog != null && progressDialog.isShowing()) { progressDialog.dismiss(); progressDialog = null; } } catch (Exception e) { FileLog.e(e); } donePressed = false; doneButton.performClick(); } } }); }
Example 8
Source File: StatisticPostInfoCell.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
public void setData(StatisticActivity.RecentPostInfo postInfo) { MessageObject messageObject = postInfo.message; if (messageObject.photoThumbs != null) { TLRPC.PhotoSize size = FileLoader.getClosestPhotoSizeWithSize(messageObject.photoThumbs, AndroidUtilities.getPhotoSize()); TLRPC.PhotoSize thumbSize = FileLoader.getClosestPhotoSizeWithSize(messageObject.photoThumbs,50); imageView.setImage( ImageLocation.getForObject(size, messageObject.photoThumbsObject), "50_50", ImageLocation.getForObject(thumbSize, messageObject.photoThumbsObject), "b1", 0, messageObject); imageView.setRoundRadius(AndroidUtilities.dp(4)); } else if (chat.chat_photo.sizes.size() > 0) { imageView.setImage(ImageLocation.getForPhoto(chat.chat_photo.sizes.get(0), chat.chat_photo), "50_50", null, null, chat); imageView.setRoundRadius(AndroidUtilities.dp(46) >> 1); } String text; if (messageObject.isMusic()) { text = String.format("%s, %s", messageObject.getMusicTitle().trim(), messageObject.getMusicAuthor().trim()); } else { text = messageObject.caption != null ? messageObject.caption.toString() : messageObject.messageText.toString(); } message.setText(text.replace("\n", " ").trim()); views.setText(String.format(LocaleController.getPluralString("Views", postInfo.counters.views), AndroidUtilities.formatCount(postInfo.counters.views))); date.setText(LocaleController.formatDateAudio(postInfo.message.messageOwner.date, false)); shares.setText(String.format(LocaleController.getPluralString("Shares", postInfo.counters.forwards), AndroidUtilities.formatCount(postInfo.counters.forwards))); }
Example 9
Source File: StickerCell.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
public void setSticker(TLRPC.Document document, Object parent, int side) { parentObject = parent; if (document != null) { TLRPC.PhotoSize thumb = FileLoader.getClosestPhotoSizeWithSize(document.thumbs, 90); if (MessageObject.canAutoplayAnimatedSticker(document)) { if (thumb != null) { imageView.setImage(ImageLocation.getForDocument(document), "80_80", ImageLocation.getForDocument(thumb, document), null, 0, parentObject); } else { imageView.setImage(ImageLocation.getForDocument(document), "80_80", null, null, parentObject); } } else { imageView.setImage(ImageLocation.getForDocument(thumb, document), null, "webp", null, parentObject); } } sticker = document; if (side == -1) { setBackgroundResource(R.drawable.stickers_back_left); setPadding(AndroidUtilities.dp(7), 0, 0, 0); } else if (side == 0) { setBackgroundResource(R.drawable.stickers_back_center); setPadding(0, 0, 0, 0); } else if (side == 1) { setBackgroundResource(R.drawable.stickers_back_right); setPadding(0, 0, AndroidUtilities.dp(7), 0); } else if (side == 2) { setBackgroundResource(R.drawable.stickers_back_all); setPadding(AndroidUtilities.dp(3), 0, AndroidUtilities.dp(3), 0); } Drawable background = getBackground(); if (background != null) { background.setAlpha(230); background.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chat_stickersHintPanel), PorterDuff.Mode.MULTIPLY)); } }
Example 10
Source File: GroupCreateFinalActivity.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@Override public void didUploadedPhoto(final TLRPC.InputFile file, final TLRPC.PhotoSize small, final TLRPC.PhotoSize big, final TLRPC.TL_secureFile secureFile) { AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { uploadedAvatar = file; avatar = small.location; avatarImage.setImage(avatar, "50_50", avatarDrawable); if (createAfterUpload) { MessagesController.getInstance(currentAccount).createChat(editText.getText().toString(), selectedContacts, null, chatType, GroupCreateFinalActivity.this); } } }); }
Example 11
Source File: PatternCell.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
public void setPattern(TLRPC.TL_wallPaper wallPaper) { currentPattern = wallPaper; if (wallPaper != null) { TLRPC.PhotoSize thumb = FileLoader.getClosestPhotoSizeWithSize(wallPaper.document.thumbs, 100); setImage(ImageLocation.getForDocument(thumb, wallPaper.document), "100_100", null, null, "jpg", 0, 1, wallPaper); } else { setImageDrawable(null); } updateSelected(false); }
Example 12
Source File: ImageLoader.java From Telegram with GNU General Public License v2.0 | 4 votes |
public static TLRPC.PhotoSize scaleAndSaveImage(Bitmap bitmap, Bitmap.CompressFormat compressFormat, float maxWidth, float maxHeight, int quality, boolean cache, int minWidth, int minHeight) { return scaleAndSaveImage(null, bitmap, compressFormat, maxWidth, maxHeight, quality, cache, minWidth, minHeight, false); }
Example 13
Source File: RadialProgress2.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
public void setImageOverlay(TLRPC.PhotoSize image, TLRPC.Document document, Object parentObject) { overlayImageView.setImage(ImageLocation.getForDocument(image, document), String.format(Locale.US, "%d_%d", circleRadius * 2, circleRadius * 2), null, null, parentObject, 1); }
Example 14
Source File: ImageLoader.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
public static TLRPC.PhotoSize scaleAndSaveImage(Bitmap bitmap, float maxWidth, float maxHeight, int quality, boolean cache) { return scaleAndSaveImage(null, bitmap, Bitmap.CompressFormat.JPEG, maxWidth, maxHeight, quality, cache, 0, 0, false); }
Example 15
Source File: FileLoader.java From Telegram with GNU General Public License v2.0 | 4 votes |
public void cancelLoadFile(TLRPC.PhotoSize photo) { cancelLoadFile(null, null, null, photo.location, null); }
Example 16
Source File: FileLoader.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
public static TLRPC.PhotoSize getClosestPhotoSizeWithSize(ArrayList<TLRPC.PhotoSize> sizes, int side) { return getClosestPhotoSizeWithSize(sizes, side, false); }
Example 17
Source File: FileLoader.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
public static TLRPC.PhotoSize getClosestPhotoSizeWithSize(ArrayList<TLRPC.PhotoSize> sizes, int side) { return getClosestPhotoSizeWithSize(sizes, side, false); }
Example 18
Source File: FileLoader.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
public void cancelLoadFile(TLRPC.PhotoSize photo) { cancelLoadFile(null, null, null, photo.location, null); }
Example 19
Source File: ImageLoader.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
public static TLRPC.PhotoSize scaleAndSaveImage(Bitmap bitmap, float maxWidth, float maxHeight, int quality, boolean cache, int minWidth, int minHeight) { return scaleAndSaveImage(null, bitmap, Bitmap.CompressFormat.JPEG, maxWidth, maxHeight, quality, cache, minWidth, minHeight, false); }
Example 20
Source File: ImageLoader.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
private static TLRPC.PhotoSize scaleAndSaveImageInternal(Bitmap bitmap, int w, int h, float photoW, float photoH, float scaleFactor, int quality, boolean cache, boolean scaleAnyway) throws Exception { Bitmap scaledBitmap; if (scaleFactor > 1 || scaleAnyway) { scaledBitmap = Bitmaps.createScaledBitmap(bitmap, w, h, true); } else { scaledBitmap = bitmap; } TLRPC.TL_fileLocation location = new TLRPC.TL_fileLocation(); location.volume_id = Integer.MIN_VALUE; location.dc_id = Integer.MIN_VALUE; location.local_id = SharedConfig.getLastLocalId(); TLRPC.PhotoSize size = new TLRPC.TL_photoSize(); size.location = location; size.w = scaledBitmap.getWidth(); size.h = scaledBitmap.getHeight(); if (size.w <= 100 && size.h <= 100) { size.type = "s"; } else if (size.w <= 320 && size.h <= 320) { size.type = "m"; } else if (size.w <= 800 && size.h <= 800) { size.type = "x"; } else if (size.w <= 1280 && size.h <= 1280) { size.type = "y"; } else { size.type = "w"; } String fileName = location.volume_id + "_" + location.local_id + ".jpg"; final File cacheFile = new File(FileLoader.getDirectory(FileLoader.MEDIA_DIR_CACHE), fileName); FileOutputStream stream = new FileOutputStream(cacheFile); scaledBitmap.compress(Bitmap.CompressFormat.JPEG, quality, stream); if (cache) { ByteArrayOutputStream stream2 = new ByteArrayOutputStream(); scaledBitmap.compress(Bitmap.CompressFormat.JPEG, quality, stream2); size.bytes = stream2.toByteArray(); size.size = size.bytes.length; stream2.close(); } else { size.size = (int) stream.getChannel().size(); } stream.close(); if (scaledBitmap != bitmap) { scaledBitmap.recycle(); } return size; }