Java Code Examples for org.telegram.tgnet.TLRPC#TL_documentAttributeAudio
The following examples show how to use
org.telegram.tgnet.TLRPC#TL_documentAttributeAudio .
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: PopupAudioView.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public void updateProgress() { if (currentMessageObject == null) { return; } if (!seekBar.isDragging()) { seekBar.setProgress(currentMessageObject.audioProgress); } int duration = 0; if (!MediaController.getInstance().isPlayingMessage(currentMessageObject)) { for (int a = 0; a < currentMessageObject.getDocument().attributes.size(); a++) { TLRPC.DocumentAttribute attribute = currentMessageObject.getDocument().attributes.get(a); if (attribute instanceof TLRPC.TL_documentAttributeAudio) { duration = attribute.duration; break; } } } else { duration = currentMessageObject.audioProgressSec; } String timeString = String.format("%02d:%02d", duration / 60, duration % 60); if (lastTimeString == null || lastTimeString != null && !lastTimeString.equals(timeString)) { timeWidth = (int)Math.ceil(timePaint.measureText(timeString)); timeLayout = new StaticLayout(timeString, timePaint, timeWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); } invalidate(); }
Example 2
Source File: PopupAudioView.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public void updateProgress() { if (currentMessageObject == null) { return; } if (!seekBar.isDragging()) { seekBar.setProgress(currentMessageObject.audioProgress); } int duration = 0; if (!MediaController.getInstance().isPlayingMessage(currentMessageObject)) { for (int a = 0; a < currentMessageObject.getDocument().attributes.size(); a++) { TLRPC.DocumentAttribute attribute = currentMessageObject.getDocument().attributes.get(a); if (attribute instanceof TLRPC.TL_documentAttributeAudio) { duration = attribute.duration; break; } } } else { duration = currentMessageObject.audioProgressSec; } String timeString = String.format("%02d:%02d", duration / 60, duration % 60); if (lastTimeString == null || lastTimeString != null && !lastTimeString.equals(timeString)) { timeWidth = (int)Math.ceil(timePaint.measureText(timeString)); timeLayout = new StaticLayout(timeString, timePaint, timeWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); } invalidate(); }
Example 3
Source File: PopupAudioView.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
public void updateProgress() { if (currentMessageObject == null) { return; } if (!seekBar.isDragging()) { seekBar.setProgress(currentMessageObject.audioProgress); } int duration = 0; if (!MediaController.getInstance().isPlayingMessage(currentMessageObject)) { for (int a = 0; a < currentMessageObject.getDocument().attributes.size(); a++) { TLRPC.DocumentAttribute attribute = currentMessageObject.getDocument().attributes.get(a); if (attribute instanceof TLRPC.TL_documentAttributeAudio) { duration = attribute.duration; break; } } } else { duration = currentMessageObject.audioProgressSec; } String timeString = AndroidUtilities.formatLongDuration(duration); if (lastTimeString == null || lastTimeString != null && !lastTimeString.equals(timeString)) { timeWidth = (int)Math.ceil(timePaint.measureText(timeString)); timeLayout = new StaticLayout(timeString, timePaint, timeWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); } invalidate(); }
Example 4
Source File: PopupAudioView.java From Telegram with GNU General Public License v2.0 | 5 votes |
public void updateProgress() { if (currentMessageObject == null) { return; } if (!seekBar.isDragging()) { seekBar.setProgress(currentMessageObject.audioProgress); } int duration = 0; if (!MediaController.getInstance().isPlayingMessage(currentMessageObject)) { for (int a = 0; a < currentMessageObject.getDocument().attributes.size(); a++) { TLRPC.DocumentAttribute attribute = currentMessageObject.getDocument().attributes.get(a); if (attribute instanceof TLRPC.TL_documentAttributeAudio) { duration = attribute.duration; break; } } } else { duration = currentMessageObject.audioProgressSec; } String timeString = AndroidUtilities.formatLongDuration(duration); if (lastTimeString == null || lastTimeString != null && !lastTimeString.equals(timeString)) { timeWidth = (int)Math.ceil(timePaint.measureText(timeString)); timeLayout = new StaticLayout(timeString, timePaint, timeWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); } invalidate(); }
Example 5
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 6
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 7
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 8
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(); }