Java Code Examples for org.telegram.messenger.FileLoader#getDocumentFileName()
The following examples show how to use
org.telegram.messenger.FileLoader#getDocumentFileName() .
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: OtherDocumentPlaceholderDrawable.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
public OtherDocumentPlaceholderDrawable(Context context, View view, MessageObject messageObject) { docPaint.setTextSize(AndroidUtilities.dp(14)); namePaint.setTextSize(AndroidUtilities.dp(19)); sizePaint.setTextSize(AndroidUtilities.dp(15)); buttonPaint.setTextSize(AndroidUtilities.dp(15)); percentPaint.setTextSize(AndroidUtilities.dp(15)); openPaint.setTextSize(AndroidUtilities.dp(15)); progressPaint.setStrokeWidth(AndroidUtilities.dp(2)); parentView = view; parentMessageObject = messageObject; TAG = DownloadController.getInstance(messageObject.currentAccount).generateObserverTag(); TLRPC.Document document = messageObject.getDocument(); if (document != null) { fileName = FileLoader.getDocumentFileName(messageObject.getDocument()); if (TextUtils.isEmpty(fileName)) { fileName = "name"; } int idx; ext = (idx = fileName.lastIndexOf('.')) == -1 ? "" : fileName.substring(idx + 1).toUpperCase(); int w = (int) Math.ceil(docPaint.measureText(ext)); if (w > AndroidUtilities.dp(40)) { ext = TextUtils.ellipsize(ext, docPaint, AndroidUtilities.dp(40), TextUtils.TruncateAt.END).toString(); } thumbDrawable = context.getResources().getDrawable(AndroidUtilities.getThumbForNameOrMime(fileName, messageObject.getDocument().mime_type, true)).mutate(); fileSize = AndroidUtilities.formatFileSize(document.size); w = (int) Math.ceil(namePaint.measureText(fileName)); if (w > AndroidUtilities.dp(320)) { fileName = TextUtils.ellipsize(fileName, namePaint, AndroidUtilities.dp(320), TextUtils.TruncateAt.END).toString(); } } checkFileExist(); }
Example 2
Source File: OtherDocumentPlaceholderDrawable.java From Telegram with GNU General Public License v2.0 | 5 votes |
public OtherDocumentPlaceholderDrawable(Context context, View view, MessageObject messageObject) { docPaint.setTextSize(AndroidUtilities.dp(14)); namePaint.setTextSize(AndroidUtilities.dp(19)); sizePaint.setTextSize(AndroidUtilities.dp(15)); buttonPaint.setTextSize(AndroidUtilities.dp(15)); percentPaint.setTextSize(AndroidUtilities.dp(15)); openPaint.setTextSize(AndroidUtilities.dp(15)); progressPaint.setStrokeWidth(AndroidUtilities.dp(2)); parentView = view; parentMessageObject = messageObject; TAG = DownloadController.getInstance(messageObject.currentAccount).generateObserverTag(); TLRPC.Document document = messageObject.getDocument(); if (document != null) { fileName = FileLoader.getDocumentFileName(messageObject.getDocument()); if (TextUtils.isEmpty(fileName)) { fileName = "name"; } int idx; ext = (idx = fileName.lastIndexOf('.')) == -1 ? "" : fileName.substring(idx + 1).toUpperCase(); int w = (int) Math.ceil(docPaint.measureText(ext)); if (w > AndroidUtilities.dp(40)) { ext = TextUtils.ellipsize(ext, docPaint, AndroidUtilities.dp(40), TextUtils.TruncateAt.END).toString(); } thumbDrawable = context.getResources().getDrawable(AndroidUtilities.getThumbForNameOrMime(fileName, messageObject.getDocument().mime_type, true)).mutate(); fileSize = AndroidUtilities.formatFileSize(document.size); w = (int) Math.ceil(namePaint.measureText(fileName)); if (w > AndroidUtilities.dp(320)) { fileName = TextUtils.ellipsize(fileName, namePaint, AndroidUtilities.dp(320), TextUtils.TruncateAt.END).toString(); } } checkFileExist(); }
Example 3
Source File: SharedDocumentCell.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
public void setDocument(MessageObject messageObject, boolean divider) { needDivider = divider; message = messageObject; loaded = false; loading = false; if (messageObject != null && messageObject.getDocument() != null) { int idx; String name = null; if (messageObject.isMusic()) { TLRPC.Document document; if (messageObject.type == 0) { document = messageObject.messageOwner.media.webpage.document; } else { document = messageObject.messageOwner.media.document; } 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(messageObject.getDocument()); if (name == null) { name = fileName; } nameTextView.setText(name); placeholderImageView.setVisibility(VISIBLE); extTextView.setVisibility(VISIBLE); placeholderImageView.setImageResource(getThumbForNameOrMime(fileName, messageObject.getDocument().mime_type)); extTextView.setText((idx = fileName.lastIndexOf('.')) == -1 ? "" : fileName.substring(idx + 1).toLowerCase()); if (messageObject.getDocument().thumb instanceof TLRPC.TL_photoSizeEmpty || messageObject.getDocument().thumb == null) { thumbImageView.setVisibility(INVISIBLE); thumbImageView.setImageBitmap(null); } else { thumbImageView.setVisibility(VISIBLE); thumbImageView.setImage(messageObject.getDocument().thumb.location, "40_40", (Drawable) null); } long date = (long) messageObject.messageOwner.date * 1000; dateTextView.setText(String.format("%s, %s", AndroidUtilities.formatFileSize(messageObject.getDocument().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); thumbImageView.setVisibility(INVISIBLE); thumbImageView.setImageBitmap(null); } setWillNotDraw(!needDivider); progressView.setProgress(0, false); updateFileExistIcon(); }
Example 4
Source File: SharedDocumentCell.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
public void setDocument(MessageObject messageObject, boolean divider) { needDivider = divider; message = messageObject; loaded = false; loading = false; if (messageObject != null && messageObject.getDocument() != null) { int idx; String name = null; if (messageObject.isMusic()) { TLRPC.Document document; if (messageObject.type == 0) { document = messageObject.messageOwner.media.webpage.document; } else { document = messageObject.messageOwner.media.document; } 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(messageObject.getDocument()); if (name == null) { name = fileName; } nameTextView.setText(name); placeholderImageView.setVisibility(VISIBLE); extTextView.setVisibility(VISIBLE); placeholderImageView.setImageResource(getThumbForNameOrMime(fileName, messageObject.getDocument().mime_type)); extTextView.setText((idx = fileName.lastIndexOf('.')) == -1 ? "" : fileName.substring(idx + 1).toLowerCase()); if (messageObject.getDocument().thumb instanceof TLRPC.TL_photoSizeEmpty || messageObject.getDocument().thumb == null) { thumbImageView.setVisibility(INVISIBLE); thumbImageView.setImageBitmap(null); } else { thumbImageView.setVisibility(VISIBLE); thumbImageView.setImage(messageObject.getDocument().thumb.location, "40_40", (Drawable) null); } long date = (long) messageObject.messageOwner.date * 1000; dateTextView.setText(String.format("%s, %s", AndroidUtilities.formatFileSize(messageObject.getDocument().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); thumbImageView.setVisibility(INVISIBLE); thumbImageView.setImageBitmap(null); } setWillNotDraw(!needDivider); progressView.setProgress(0, false); updateFileExistIcon(); }
Example 5
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 6
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(); }