Java Code Examples for org.telegram.messenger.FileLoader#getClosestPhotoSizeWithSize()
The following examples show how to use
org.telegram.messenger.FileLoader#getClosestPhotoSizeWithSize() .
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: SharedAudioCell.java From Telegram 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 2
Source File: AudioPlayerCell.java From Telegram with GNU General Public License v2.0 | 6 votes |
public void setMessageObject(MessageObject messageObject) { currentMessageObject = messageObject; TLRPC.Document document = messageObject.getDocument(); TLRPC.PhotoSize thumb = document != null ? FileLoader.getClosestPhotoSizeWithSize(document.thumbs, 90) : 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); } } requestLayout(); updateButtonState(false, false); }
Example 3
Source File: StatisticPostInfoCell.java From Telegram 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 4
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 5
Source File: StickersAdapter.java From Telegram 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 6
Source File: ChatActionCell.java From Telegram with GNU General Public License v2.0 | 5 votes |
public void setMessageObject(MessageObject messageObject) { if (currentMessageObject == messageObject && (hasReplyMessage || messageObject.replyMessageObject == null)) { return; } currentMessageObject = messageObject; hasReplyMessage = messageObject.replyMessageObject != null; previousWidth = 0; if (currentMessageObject.type == 11) { int id = 0; if (messageObject.messageOwner.to_id != null) { if (messageObject.messageOwner.to_id.chat_id != 0) { id = messageObject.messageOwner.to_id.chat_id; } else if (messageObject.messageOwner.to_id.channel_id != 0) { id = messageObject.messageOwner.to_id.channel_id; } else { id = messageObject.messageOwner.to_id.user_id; if (id == UserConfig.getInstance(currentAccount).getClientUserId()) { id = messageObject.messageOwner.from_id; } } } avatarDrawable.setInfo(id, null, null); if (currentMessageObject.messageOwner.action instanceof TLRPC.TL_messageActionUserUpdatedPhoto) { imageReceiver.setImage(null, null, avatarDrawable, null, currentMessageObject, 0); } else { TLRPC.PhotoSize photo = FileLoader.getClosestPhotoSizeWithSize(currentMessageObject.photoThumbs, AndroidUtilities.dp(64)); if (photo != null) { imageReceiver.setImage(ImageLocation.getForObject(photo, currentMessageObject.photoThumbsObject), "50_50", avatarDrawable, null, currentMessageObject, 0); } else { imageReceiver.setImageBitmap(avatarDrawable); } } imageReceiver.setVisible(!PhotoViewer.isShowingImage(currentMessageObject), false); } else { imageReceiver.setImageBitmap((Bitmap) null); } requestLayout(); }
Example 7
Source File: PatternCell.java From Telegram 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 8
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 9
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 10
Source File: StickerCell.java From Telegram 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 11
Source File: StickerView.java From Telegram with GNU General Public License v2.0 | 5 votes |
public StickerView(Context context, Point position, float angle, float scale, Size baseSize, TLRPC.Document sticker, Object parentObject) { super(context, position); setRotation(angle); setScale(scale); this.sticker = sticker; this.baseSize = baseSize; this.parentObject = parentObject; for (int a = 0; a < sticker.attributes.size(); a++) { TLRPC.DocumentAttribute attribute = sticker.attributes.get(a); if (attribute instanceof TLRPC.TL_documentAttributeSticker) { if (attribute.mask_coords != null) { anchor = attribute.mask_coords.n; } break; } } containerView = new FrameLayoutDrawer(context); addView(containerView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT)); centerImage.setAspectFit(true); centerImage.setInvalidateAll(true); centerImage.setParentView(containerView); TLRPC.PhotoSize thumb = FileLoader.getClosestPhotoSizeWithSize(sticker.thumbs, 90); centerImage.setImage(ImageLocation.getForDocument(sticker), null, ImageLocation.getForDocument(thumb, sticker), null, "webp", parentObject, 1); updatePosition(); }
Example 12
Source File: SharedPhotoVideoCell.java From Telegram with GNU General Public License v2.0 | 5 votes |
public void setMessageObject(MessageObject messageObject) { currentMessageObject = messageObject; imageView.getImageReceiver().setVisible(!PhotoViewer.isShowingImage(messageObject), false); if (messageObject.isVideo()) { videoInfoContainer.setVisibility(VISIBLE); videoTextView.setText(AndroidUtilities.formatShortDuration(messageObject.getDuration())); TLRPC.Document document = messageObject.getDocument(); TLRPC.PhotoSize thumb = FileLoader.getClosestPhotoSizeWithSize(document.thumbs, 50); TLRPC.PhotoSize qualityThumb = FileLoader.getClosestPhotoSizeWithSize(document.thumbs, 320); if (thumb == qualityThumb) { qualityThumb = null; } if (thumb != null) { imageView.setImage(ImageLocation.getForDocument(qualityThumb, document), "100_100", ImageLocation.getForDocument(thumb, document), "b", ApplicationLoader.applicationContext.getResources().getDrawable(R.drawable.photo_placeholder_in), null, null, 0, messageObject); } else { imageView.setImageResource(R.drawable.photo_placeholder_in); } } else if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaPhoto && messageObject.messageOwner.media.photo != null && !messageObject.photoThumbs.isEmpty()) { videoInfoContainer.setVisibility(INVISIBLE); TLRPC.PhotoSize currentPhotoObject = FileLoader.getClosestPhotoSizeWithSize(messageObject.photoThumbs, 320); TLRPC.PhotoSize currentPhotoObjectThumb = FileLoader.getClosestPhotoSizeWithSize(messageObject.photoThumbs, 50); if (messageObject.mediaExists || DownloadController.getInstance(currentAccount).canDownloadMedia(messageObject)) { if (currentPhotoObject == currentPhotoObjectThumb) { currentPhotoObjectThumb = null; } imageView.getImageReceiver().setImage(ImageLocation.getForObject(currentPhotoObject, messageObject.photoThumbsObject), "100_100", ImageLocation.getForObject(currentPhotoObjectThumb, messageObject.photoThumbsObject), "b", currentPhotoObject.size, null, messageObject, messageObject.shouldEncryptPhotoOrVideo() ? 2 : 1); } else { imageView.setImage(null, null, ImageLocation.getForObject(currentPhotoObjectThumb, messageObject.photoThumbsObject), "b", ApplicationLoader.applicationContext.getResources().getDrawable(R.drawable.photo_placeholder_in), null, null, 0, messageObject); } } else { videoInfoContainer.setVisibility(INVISIBLE); imageView.setImageResource(R.drawable.photo_placeholder_in); } }
Example 13
Source File: SharedPhotoVideoCell.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
public void setMessageObject(MessageObject messageObject) { currentMessageObject = messageObject; imageView.getImageReceiver().setVisible(!PhotoViewer.isShowingImage(messageObject), false); if (messageObject.isVideo()) { videoInfoContainer.setVisibility(VISIBLE); videoTextView.setText(AndroidUtilities.formatShortDuration(messageObject.getDuration())); TLRPC.Document document = messageObject.getDocument(); TLRPC.PhotoSize thumb = FileLoader.getClosestPhotoSizeWithSize(document.thumbs, 50); TLRPC.PhotoSize qualityThumb = FileLoader.getClosestPhotoSizeWithSize(document.thumbs, 320); if (thumb == qualityThumb) { qualityThumb = null; } if (thumb != null) { imageView.setImage(ImageLocation.getForDocument(qualityThumb, document), "100_100", ImageLocation.getForDocument(thumb, document), "b", ApplicationLoader.applicationContext.getResources().getDrawable(R.drawable.photo_placeholder_in), null, null, 0, messageObject); } else { imageView.setImageResource(R.drawable.photo_placeholder_in); } } else if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaPhoto && messageObject.messageOwner.media.photo != null && !messageObject.photoThumbs.isEmpty()) { videoInfoContainer.setVisibility(INVISIBLE); TLRPC.PhotoSize currentPhotoObject = FileLoader.getClosestPhotoSizeWithSize(messageObject.photoThumbs, 320); TLRPC.PhotoSize currentPhotoObjectThumb = FileLoader.getClosestPhotoSizeWithSize(messageObject.photoThumbs, 50); if (messageObject.mediaExists || DownloadController.getInstance(currentAccount).canDownloadMedia(messageObject)) { if (currentPhotoObject == currentPhotoObjectThumb) { currentPhotoObjectThumb = null; } imageView.getImageReceiver().setImage(ImageLocation.getForObject(currentPhotoObject, messageObject.photoThumbsObject), "100_100", ImageLocation.getForObject(currentPhotoObjectThumb, messageObject.photoThumbsObject), "b", currentPhotoObject.size, null, messageObject, messageObject.shouldEncryptPhotoOrVideo() ? 2 : 1); } else { imageView.setImage(null, null, ImageLocation.getForObject(currentPhotoObjectThumb, messageObject.photoThumbsObject), "b", ApplicationLoader.applicationContext.getResources().getDrawable(R.drawable.photo_placeholder_in), null, null, 0, messageObject); } } else { videoInfoContainer.setVisibility(INVISIBLE); imageView.setImageResource(R.drawable.photo_placeholder_in); } }
Example 14
Source File: StickerView.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
public StickerView(Context context, Point position, float angle, float scale, Size baseSize, TLRPC.Document sticker, Object parentObject) { super(context, position); setRotation(angle); setScale(scale); this.sticker = sticker; this.baseSize = baseSize; this.parentObject = parentObject; for (int a = 0; a < sticker.attributes.size(); a++) { TLRPC.DocumentAttribute attribute = sticker.attributes.get(a); if (attribute instanceof TLRPC.TL_documentAttributeSticker) { if (attribute.mask_coords != null) { anchor = attribute.mask_coords.n; } break; } } containerView = new FrameLayoutDrawer(context); addView(containerView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT)); centerImage.setAspectFit(true); centerImage.setInvalidateAll(true); centerImage.setParentView(containerView); TLRPC.PhotoSize thumb = FileLoader.getClosestPhotoSizeWithSize(sticker.thumbs, 90); centerImage.setImage(ImageLocation.getForDocument(sticker), null, ImageLocation.getForDocument(thumb, sticker), null, "webp", parentObject, 1); updatePosition(); }
Example 15
Source File: SharedDocumentCell.java From Telegram with GNU General Public License v2.0 | 4 votes |
public void setDocument(MessageObject messageObject, boolean divider) { needDivider = divider; message = messageObject; loaded = false; loading = false; TLRPC.Document document = messageObject.getDocument(); if (messageObject != null && document != null) { int idx; String name = null; if (messageObject.isMusic()) { for (int a = 0; a < document.attributes.size(); a++) { TLRPC.DocumentAttribute attribute = document.attributes.get(a); if (attribute instanceof TLRPC.TL_documentAttributeAudio) { if (attribute.performer != null && attribute.performer.length() != 0 || attribute.title != null && attribute.title.length() != 0) { name = messageObject.getMusicAuthor() + " - " + messageObject.getMusicTitle(); } } } } String fileName = FileLoader.getDocumentFileName(document); if (name == null) { name = fileName; } nameTextView.setText(name); placeholderImageView.setVisibility(VISIBLE); extTextView.setVisibility(VISIBLE); placeholderImageView.setImageResource(AndroidUtilities.getThumbForNameOrMime(fileName, document.mime_type, false)); extTextView.setText((idx = fileName.lastIndexOf('.')) == -1 ? "" : fileName.substring(idx + 1).toLowerCase()); TLRPC.PhotoSize bigthumb = FileLoader.getClosestPhotoSizeWithSize(document.thumbs, 320); TLRPC.PhotoSize thumb = FileLoader.getClosestPhotoSizeWithSize(document.thumbs, 40); if (thumb == bigthumb) { bigthumb = null; } if (thumb instanceof TLRPC.TL_photoSizeEmpty || thumb == null) { thumbImageView.setVisibility(INVISIBLE); thumbImageView.setImageBitmap(null); extTextView.setAlpha(1.0f); placeholderImageView.setAlpha(1.0f); } else { thumbImageView.getImageReceiver().setNeedsQualityThumb(bigthumb == null); thumbImageView.getImageReceiver().setShouldGenerateQualityThumb(bigthumb == null); thumbImageView.setVisibility(VISIBLE); thumbImageView.setImage(ImageLocation.getForDocument(bigthumb, document), "40_40", ImageLocation.getForDocument(thumb, document), "40_40_b", null, 0, 1, messageObject); } long date = (long) messageObject.messageOwner.date * 1000; dateTextView.setText(String.format("%s, %s", AndroidUtilities.formatFileSize(document.size), LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, LocaleController.getInstance().formatterYear.format(new Date(date)), LocaleController.getInstance().formatterDay.format(new Date(date))))); } else { nameTextView.setText(""); extTextView.setText(""); dateTextView.setText(""); placeholderImageView.setVisibility(VISIBLE); extTextView.setVisibility(VISIBLE); extTextView.setAlpha(1.0f); placeholderImageView.setAlpha(1.0f); thumbImageView.setVisibility(INVISIBLE); thumbImageView.setImageBitmap(null); } setWillNotDraw(!needDivider); progressView.setProgress(0, false); updateFileExistIcon(); }
Example 16
Source File: StickerEmojiCell.java From Telegram with GNU General Public License v2.0 | 4 votes |
public void setSticker(TLRPC.Document document, Object parent, String emoji, boolean showEmoji) { if (document != null) { sticker = document; parentObject = parent; 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 { if (thumb != null) { imageView.setImage(ImageLocation.getForDocument(thumb, document), null, "webp", null, parentObject); } else { imageView.setImage(ImageLocation.getForDocument(document), null, "webp", null, parentObject); } } if (emoji != null) { emojiTextView.setText(Emoji.replaceEmoji(emoji, emojiTextView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(16), false)); emojiTextView.setVisibility(VISIBLE); } else if (showEmoji) { boolean set = false; for (int a = 0; a < document.attributes.size(); a++) { TLRPC.DocumentAttribute attribute = document.attributes.get(a); if (attribute instanceof TLRPC.TL_documentAttributeSticker) { if (attribute.alt != null && attribute.alt.length() > 0) { emojiTextView.setText(Emoji.replaceEmoji(attribute.alt, emojiTextView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(16), false)); set = true; } break; } } if (!set) { emojiTextView.setText(Emoji.replaceEmoji(MediaDataController.getInstance(currentAccount).getEmojiForSticker(sticker.id), emojiTextView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(16), false)); } emojiTextView.setVisibility(VISIBLE); } else { emojiTextView.setVisibility(INVISIBLE); } } }
Example 17
Source File: SharedDocumentCell.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
public void setDocument(MessageObject messageObject, boolean divider) { needDivider = divider; message = messageObject; loaded = false; loading = false; TLRPC.Document document = messageObject.getDocument(); if (messageObject != null && document != null) { int idx; String name = null; if (messageObject.isMusic()) { for (int a = 0; a < document.attributes.size(); a++) { TLRPC.DocumentAttribute attribute = document.attributes.get(a); if (attribute instanceof TLRPC.TL_documentAttributeAudio) { if (attribute.performer != null && attribute.performer.length() != 0 || attribute.title != null && attribute.title.length() != 0) { name = messageObject.getMusicAuthor() + " - " + messageObject.getMusicTitle(); } } } } String fileName = FileLoader.getDocumentFileName(document); if (name == null) { name = fileName; } nameTextView.setText(name); placeholderImageView.setVisibility(VISIBLE); extTextView.setVisibility(VISIBLE); placeholderImageView.setImageResource(AndroidUtilities.getThumbForNameOrMime(fileName, document.mime_type, false)); extTextView.setText((idx = fileName.lastIndexOf('.')) == -1 ? "" : fileName.substring(idx + 1).toLowerCase()); TLRPC.PhotoSize bigthumb = FileLoader.getClosestPhotoSizeWithSize(document.thumbs, 320); TLRPC.PhotoSize thumb = FileLoader.getClosestPhotoSizeWithSize(document.thumbs, 40); if (thumb == bigthumb) { bigthumb = null; } if (thumb instanceof TLRPC.TL_photoSizeEmpty || thumb == null) { thumbImageView.setVisibility(INVISIBLE); thumbImageView.setImageBitmap(null); extTextView.setAlpha(1.0f); placeholderImageView.setAlpha(1.0f); } else { thumbImageView.getImageReceiver().setNeedsQualityThumb(bigthumb == null); thumbImageView.getImageReceiver().setShouldGenerateQualityThumb(bigthumb == null); thumbImageView.setVisibility(VISIBLE); thumbImageView.setImage(ImageLocation.getForDocument(bigthumb, document), "40_40", ImageLocation.getForDocument(thumb, document), "40_40_b", null, 0, 1, messageObject); } long date = (long) messageObject.messageOwner.date * 1000; dateTextView.setText(String.format("%s, %s", AndroidUtilities.formatFileSize(document.size), LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, LocaleController.getInstance().formatterYear.format(new Date(date)), LocaleController.getInstance().formatterDay.format(new Date(date))))); } else { nameTextView.setText(""); extTextView.setText(""); dateTextView.setText(""); placeholderImageView.setVisibility(VISIBLE); extTextView.setVisibility(VISIBLE); extTextView.setAlpha(1.0f); placeholderImageView.setAlpha(1.0f); thumbImageView.setVisibility(INVISIBLE); thumbImageView.setImageBitmap(null); } setWillNotDraw(!needDivider); progressView.setProgress(0, false); updateFileExistIcon(); }
Example 18
Source File: SharedPhotoVideoCell.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
public void setItem(int a, int index, MessageObject messageObject) { messageObjects[a] = messageObject; indeces[a] = index; if (messageObject != null) { photoVideoViews[a].setVisibility(VISIBLE); PhotoVideoView photoVideoView = photoVideoViews[a]; photoVideoView.imageView.getImageReceiver().setParentMessageObject(messageObject); photoVideoView.imageView.getImageReceiver().setVisible(!PhotoViewer.isShowingImage(messageObject), false); if (messageObject.isVideo()) { photoVideoView.videoInfoContainer.setVisibility(VISIBLE); int duration = 0; for (int b = 0; b < messageObject.getDocument().attributes.size(); b++) { TLRPC.DocumentAttribute attribute = messageObject.getDocument().attributes.get(b); if (attribute instanceof TLRPC.TL_documentAttributeVideo) { duration = attribute.duration; break; } } int minutes = duration / 60; int seconds = duration - minutes * 60; photoVideoView.videoTextView.setText(String.format("%d:%02d", minutes, seconds)); if (messageObject.getDocument().thumb != null) { TLRPC.FileLocation location = messageObject.getDocument().thumb.location; photoVideoView.imageView.setImage(null, null, null, ApplicationLoader.applicationContext.getResources().getDrawable(R.drawable.photo_placeholder_in), null, location, "b", null, 0); } else { photoVideoView.imageView.setImageResource(R.drawable.photo_placeholder_in); } } else if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaPhoto && messageObject.messageOwner.media.photo != null && !messageObject.photoThumbs.isEmpty()) { photoVideoView.videoInfoContainer.setVisibility(INVISIBLE); TLRPC.PhotoSize photoSize = FileLoader.getClosestPhotoSizeWithSize(messageObject.photoThumbs, 80); photoVideoView.imageView.setImage(null, null, null, ApplicationLoader.applicationContext.getResources().getDrawable(R.drawable.photo_placeholder_in), null, photoSize.location, "b", null, 0); } else { photoVideoView.videoInfoContainer.setVisibility(INVISIBLE); photoVideoView.imageView.setImageResource(R.drawable.photo_placeholder_in); } } else { photoVideoViews[a].clearAnimation(); photoVideoViews[a].setVisibility(INVISIBLE); messageObjects[a] = null; } }
Example 19
Source File: ChatActionCell.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
public void setMessageObject(MessageObject messageObject) { if (currentMessageObject == messageObject && (hasReplyMessage || messageObject.replyMessageObject == null)) { return; } currentMessageObject = messageObject; hasReplyMessage = messageObject.replyMessageObject != null; previousWidth = 0; if (currentMessageObject.type == 11) { int id = 0; if (messageObject.messageOwner.to_id != null) { if (messageObject.messageOwner.to_id.chat_id != 0) { id = messageObject.messageOwner.to_id.chat_id; } else if (messageObject.messageOwner.to_id.channel_id != 0) { id = messageObject.messageOwner.to_id.channel_id; } else { id = messageObject.messageOwner.to_id.user_id; if (id == UserConfig.getInstance(currentAccount).getClientUserId()) { id = messageObject.messageOwner.from_id; } } } avatarDrawable.setInfo(id, null, null, false); if (currentMessageObject.messageOwner.action instanceof TLRPC.TL_messageActionUserUpdatedPhoto) { imageReceiver.setImage(currentMessageObject.messageOwner.action.newUserPhoto.photo_small, "50_50", avatarDrawable, null, 0); } else { TLRPC.PhotoSize photo = FileLoader.getClosestPhotoSizeWithSize(currentMessageObject.photoThumbs, AndroidUtilities.dp(64)); if (photo != null) { imageReceiver.setImage(photo.location, "50_50", avatarDrawable, null, 0); } else { imageReceiver.setImageBitmap(avatarDrawable); } } imageReceiver.setVisible(!PhotoViewer.isShowingImage(currentMessageObject), false); } else { imageReceiver.setImageBitmap((Bitmap) null); } requestLayout(); }
Example 20
Source File: SharedPhotoVideoCell.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
public void setItem(int a, int index, MessageObject messageObject) { messageObjects[a] = messageObject; indeces[a] = index; if (messageObject != null) { photoVideoViews[a].setVisibility(VISIBLE); PhotoVideoView photoVideoView = photoVideoViews[a]; photoVideoView.imageView.getImageReceiver().setParentMessageObject(messageObject); photoVideoView.imageView.getImageReceiver().setVisible(!PhotoViewer.isShowingImage(messageObject), false); if (messageObject.isVideo()) { photoVideoView.videoInfoContainer.setVisibility(VISIBLE); int duration = 0; for (int b = 0; b < messageObject.getDocument().attributes.size(); b++) { TLRPC.DocumentAttribute attribute = messageObject.getDocument().attributes.get(b); if (attribute instanceof TLRPC.TL_documentAttributeVideo) { duration = attribute.duration; break; } } int minutes = duration / 60; int seconds = duration - minutes * 60; photoVideoView.videoTextView.setText(String.format("%d:%02d", minutes, seconds)); if (messageObject.getDocument().thumb != null) { TLRPC.FileLocation location = messageObject.getDocument().thumb.location; photoVideoView.imageView.setImage(null, null, null, ApplicationLoader.applicationContext.getResources().getDrawable(R.drawable.photo_placeholder_in), null, location, "b", null, 0); } else { photoVideoView.imageView.setImageResource(R.drawable.photo_placeholder_in); } } else if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaPhoto && messageObject.messageOwner.media.photo != null && !messageObject.photoThumbs.isEmpty()) { photoVideoView.videoInfoContainer.setVisibility(INVISIBLE); TLRPC.PhotoSize photoSize = FileLoader.getClosestPhotoSizeWithSize(messageObject.photoThumbs, 80); photoVideoView.imageView.setImage(null, null, null, ApplicationLoader.applicationContext.getResources().getDrawable(R.drawable.photo_placeholder_in), null, photoSize.location, "b", null, 0); } else { photoVideoView.videoInfoContainer.setVisibility(INVISIBLE); photoVideoView.imageView.setImageResource(R.drawable.photo_placeholder_in); } } else { photoVideoViews[a].clearAnimation(); photoVideoViews[a].setVisibility(INVISIBLE); messageObjects[a] = null; } }