use of com.doctoror.fuckoffmusicplayer.domain.queue.Media in project PainlessMusicPlayer by Doctoror.
the class SingleRowAppWidgetProvider method bindViews.
private void bindViews(@NonNull final Context context, @NonNull final AppWidgetManager appWidgetManager, @NonNull final int[] appWidgetIds, @PlaybackState final int state) {
final RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.appwidget_single_row);
final Media media = currentMediaProvider.getCurrentMedia();
final boolean hasMedia = media != null;
views.setImageViewResource(R.id.appwidget_btn_play_pause, state == PlaybackState.STATE_PLAYING ? R.drawable.ic_pause_white_24dp : R.drawable.ic_play_arrow_white_24dp);
if (hasMedia) {
setPlayPauseButtonAction(context, views);
setPrevButtonAction(context, views);
setNextButtonAction(context, views);
} else {
final PendingIntent playAnything = generatePlayAnythingIntent(context);
setButtonAction(views, R.id.appwidget_btn_play_pause, playAnything);
setButtonAction(views, R.id.appwidget_btn_prev, playAnything);
setButtonAction(views, R.id.appwidget_btn_next, playAnything);
}
setCoverClickAction(context, views, hasMedia);
CharSequence artist = media != null ? media.getArtist() : null;
CharSequence title = media != null ? media.getTitle() : null;
if (TextUtils.isEmpty(artist)) {
artist = context.getText(R.string.Unknown_artist);
}
if (TextUtils.isEmpty(title)) {
title = context.getText(R.string.Untitled);
}
views.setTextViewText(R.id.appwidget_text_artist, artist);
views.setTextViewText(R.id.appwidget_text_title, title);
final Bitmap thumb = albumThumbHolder.getAlbumThumb();
if (thumb != null) {
views.setImageViewBitmap(R.id.appwidget_img_albumart, thumb);
} else {
views.setImageViewResource(R.id.appwidget_img_albumart, R.drawable.album_art_placeholder);
}
appWidgetManager.updateAppWidget(appWidgetIds, views);
}
use of com.doctoror.fuckoffmusicplayer.domain.queue.Media in project PainlessMusicPlayer by Doctoror.
the class PlaybackAndroidService method onActionSeek.
private void onActionSeek(final float positionPercent) {
final Media media = currentMediaProvider.getCurrentMedia();
if (media != null) {
final long duration = media.getDuration();
if (duration > 0) {
final int position = (int) ((float) duration * positionPercent);
playbackData.setMediaPosition(position);
service.seek(position);
}
}
}
use of com.doctoror.fuckoffmusicplayer.domain.queue.Media in project PainlessMusicPlayer by Doctoror.
the class QueueActivity method onPlayClick.
private void onPlayClick(@NonNull final View clickedView, final int queuePosition) {
mPlaybackInitializer.setQueueAndPlay(queue, queuePosition);
final Media media = CollectionUtils.getItemSafe(queue, queuePosition);
final boolean shouldPassCoverView = mAppbarOffset == 0 && TextUtils.equals(mCoverUri, media != null ? media.getAlbumArt() : null);
if (shouldPassCoverView) {
prepareViewsAndExit(() -> startNowPlayingActivity(albumArt, null));
} else {
mFabAnchorParams = CoordinatorLayoutUtil.getAnchorParams(fab);
CoordinatorLayoutUtil.clearAnchorGravityAndApplyMargins(fab);
startNowPlayingActivity(null, clickedView);
}
}
use of com.doctoror.fuckoffmusicplayer.domain.queue.Media in project PainlessMusicPlayer by Doctoror.
the class QueueActivity method onPlaybackStateChanged.
@WorkerThread
private void onPlaybackStateChanged(@PlaybackState final int state) {
final Media media = state == PlaybackState.STATE_PLAYING ? currentMediaProvider.getCurrentMedia() : null;
// noinspection WrongThread
runOnUiThread(() -> onNowPlayingMediaChanged(media));
}
Aggregations