Java Code Examples for org.telegram.messenger.MessageObject#isMusic()
The following examples show how to use
org.telegram.messenger.MessageObject#isMusic() .
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: 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 2
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 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: AudioPlayerAlert.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
private void updateTitle(boolean shutdown) { MessageObject messageObject = MediaController.getInstance().getPlayingMessageObject(); if (messageObject == null && shutdown || messageObject != null && !messageObject.isMusic()) { dismiss(); } else { if (messageObject == null) { return; } if (messageObject.eventId != 0 || messageObject.getId() <= -2000000000) { hasOptions = false; menuItem.setVisibility(View.INVISIBLE); optionsButton.setVisibility(View.INVISIBLE); } else { hasOptions = true; if (!actionBar.isSearchFieldVisible()) { menuItem.setVisibility(View.VISIBLE); } optionsButton.setVisibility(View.VISIBLE); } checkIfMusicDownloaded(messageObject); updateProgress(messageObject); if (MediaController.getInstance().isMessagePaused()) { playButton.setImageDrawable(Theme.createSimpleSelectorDrawable(playButton.getContext(), R.drawable.pl_play, Theme.getColor(Theme.key_player_button), Theme.getColor(Theme.key_player_buttonActive))); } else { playButton.setImageDrawable(Theme.createSimpleSelectorDrawable(playButton.getContext(), R.drawable.pl_pause, Theme.getColor(Theme.key_player_button), Theme.getColor(Theme.key_player_buttonActive))); } String title = messageObject.getMusicTitle(); String author = messageObject.getMusicAuthor(); titleTextView.setText(title); authorTextView.setText(author); actionBar.setTitle(title); actionBar.setSubtitle(author); AudioInfo audioInfo = MediaController.getInstance().getAudioInfo(); if (audioInfo != null && audioInfo.getCover() != null) { hasNoCover = false; placeholderImageView.setImageBitmap(audioInfo.getCover()); } else { hasNoCover = true; placeholderImageView.invalidate(); placeholderImageView.setImageDrawable(null); } if (durationTextView != null) { int duration = messageObject.getDuration(); durationTextView.setText(duration != 0 ? String.format("%d:%02d", duration / 60, duration % 60) : "-:--"); } } }
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: AudioPlayerAlert.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
private void updateTitle(boolean shutdown) { MessageObject messageObject = MediaController.getInstance().getPlayingMessageObject(); if (messageObject == null && shutdown || messageObject != null && !messageObject.isMusic()) { dismiss(); } else { if (messageObject == null) { return; } if (messageObject.eventId != 0 || messageObject.getId() <= -2000000000) { hasOptions = false; menuItem.setVisibility(View.INVISIBLE); optionsButton.setVisibility(View.INVISIBLE); } else { hasOptions = true; if (!actionBar.isSearchFieldVisible()) { menuItem.setVisibility(View.VISIBLE); } optionsButton.setVisibility(View.VISIBLE); } checkIfMusicDownloaded(messageObject); updateProgress(messageObject); if (MediaController.getInstance().isMessagePaused()) { playButton.setImageDrawable(Theme.createSimpleSelectorDrawable(playButton.getContext(), R.drawable.pl_play, Theme.getColor(Theme.key_player_button), Theme.getColor(Theme.key_player_buttonActive))); } else { playButton.setImageDrawable(Theme.createSimpleSelectorDrawable(playButton.getContext(), R.drawable.pl_pause, Theme.getColor(Theme.key_player_button), Theme.getColor(Theme.key_player_buttonActive))); } String title = messageObject.getMusicTitle(); String author = messageObject.getMusicAuthor(); titleTextView.setText(title); authorTextView.setText(author); actionBar.setTitle(title); actionBar.setSubtitle(author); AudioInfo audioInfo = MediaController.getInstance().getAudioInfo(); if (audioInfo != null && audioInfo.getCover() != null) { hasNoCover = false; placeholderImageView.setImageBitmap(audioInfo.getCover()); } else { hasNoCover = true; placeholderImageView.invalidate(); placeholderImageView.setImageDrawable(null); } if (durationTextView != null) { int duration = messageObject.getDuration(); durationTextView.setText(duration != 0 ? String.format("%d:%02d", duration / 60, duration % 60) : "-:--"); } } }
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: AudioPlayerAlert.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
private void updateTitle(boolean shutdown) { MessageObject messageObject = MediaController.getInstance().getPlayingMessageObject(); if (messageObject == null && shutdown || messageObject != null && !messageObject.isMusic()) { dismiss(); } else { if (messageObject == null) { return; } if (messageObject.eventId != 0 || messageObject.getId() <= -2000000000) { hasOptions = false; menuItem.setVisibility(View.INVISIBLE); optionsButton.setVisibility(View.INVISIBLE); } else { hasOptions = true; if (!actionBar.isSearchFieldVisible()) { menuItem.setVisibility(View.VISIBLE); } optionsButton.setVisibility(View.VISIBLE); } checkIfMusicDownloaded(messageObject); updateProgress(messageObject); if (MediaController.getInstance().isMessagePaused()) { playButton.setImageDrawable(Theme.createSimpleSelectorDrawable(playButton.getContext(), R.drawable.pl_play, Theme.getColor(Theme.key_player_button), Theme.getColor(Theme.key_player_buttonActive))); playButton.setContentDescription(LocaleController.getString("AccActionPlay", R.string.AccActionPlay)); } else { playButton.setImageDrawable(Theme.createSimpleSelectorDrawable(playButton.getContext(), R.drawable.pl_pause, Theme.getColor(Theme.key_player_button), Theme.getColor(Theme.key_player_buttonActive))); playButton.setContentDescription(LocaleController.getString("AccActionPause", R.string.AccActionPause)); } String title = messageObject.getMusicTitle(); String author = messageObject.getMusicAuthor(); titleTextView.setText(title); authorTextView.setText(author); actionBar.setTitle(title); actionBar.setSubtitle(author); String loadTitle = author + " " + title; AudioInfo audioInfo = MediaController.getInstance().getAudioInfo(); if (audioInfo != null && audioInfo.getCover() != null) { hasNoCover = 0; placeholderImageView.setImageBitmap(audioInfo.getCover()); } else { String artworkUrl = messageObject.getArtworkUrl(false); if (!TextUtils.isEmpty(artworkUrl)) { placeholderImageView.setImage(artworkUrl, null, null); hasNoCover = 2; } else { placeholderImageView.setImageDrawable(null); hasNoCover = 1; } placeholderImageView.invalidate(); } int duration = messageObject.getDuration(); if (durationTextView != null) { durationTextView.setText(duration != 0 ? AndroidUtilities.formatShortDuration(duration) : "-:--"); } if (duration > 60 * 20) { playbackSpeedButton.setVisibility(View.VISIBLE); } else { playbackSpeedButton.setVisibility(View.GONE); } } }
Example 9
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 10
Source File: AudioPlayerAlert.java From Telegram with GNU General Public License v2.0 | 4 votes |
private void updateTitle(boolean shutdown) { MessageObject messageObject = MediaController.getInstance().getPlayingMessageObject(); if (messageObject == null && shutdown || messageObject != null && !messageObject.isMusic()) { dismiss(); } else { if (messageObject == null) { return; } if (messageObject.eventId != 0 || messageObject.getId() <= -2000000000) { hasOptions = false; menuItem.setVisibility(View.INVISIBLE); optionsButton.setVisibility(View.INVISIBLE); } else { hasOptions = true; if (!actionBar.isSearchFieldVisible()) { menuItem.setVisibility(View.VISIBLE); } optionsButton.setVisibility(View.VISIBLE); } checkIfMusicDownloaded(messageObject); updateProgress(messageObject); if (MediaController.getInstance().isMessagePaused()) { playButton.setImageDrawable(Theme.createSimpleSelectorDrawable(playButton.getContext(), R.drawable.pl_play, Theme.getColor(Theme.key_player_button), Theme.getColor(Theme.key_player_buttonActive))); playButton.setContentDescription(LocaleController.getString("AccActionPlay", R.string.AccActionPlay)); } else { playButton.setImageDrawable(Theme.createSimpleSelectorDrawable(playButton.getContext(), R.drawable.pl_pause, Theme.getColor(Theme.key_player_button), Theme.getColor(Theme.key_player_buttonActive))); playButton.setContentDescription(LocaleController.getString("AccActionPause", R.string.AccActionPause)); } String title = messageObject.getMusicTitle(); String author = messageObject.getMusicAuthor(); titleTextView.setText(title); authorTextView.setText(author); actionBar.setTitle(title); actionBar.setSubtitle(author); String loadTitle = author + " " + title; AudioInfo audioInfo = MediaController.getInstance().getAudioInfo(); if (audioInfo != null && audioInfo.getCover() != null) { hasNoCover = 0; placeholderImageView.setImageBitmap(audioInfo.getCover()); } else { String artworkUrl = messageObject.getArtworkUrl(false); if (!TextUtils.isEmpty(artworkUrl)) { placeholderImageView.setImage(artworkUrl, null, null); hasNoCover = 2; } else { placeholderImageView.setImageDrawable(null); hasNoCover = 1; } placeholderImageView.invalidate(); } int duration = messageObject.getDuration(); if (durationTextView != null) { durationTextView.setText(duration != 0 ? AndroidUtilities.formatShortDuration(duration) : "-:--"); } if (duration > 60 * 20) { playbackSpeedButton.setVisibility(View.VISIBLE); } else { playbackSpeedButton.setVisibility(View.GONE); } } }