Java Code Examples for org.telegram.messenger.MessageObject#getArtworkUrl()

The following examples show how to use org.telegram.messenger.MessageObject#getArtworkUrl() . 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-FOSS with GNU General Public License v2.0 6 votes vote down vote up
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-FOSS with GNU General Public License v2.0 6 votes vote down vote up
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: SharedAudioCell.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
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 4
Source File: AudioPlayerCell.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
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 5
Source File: AudioPlayerAlert.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
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 6
Source File: AudioPlayerAlert.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
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);
        }
    }
}