Commit e6c24b23 authored by Geoffrey Métais's avatar Geoffrey Métais

Filter widget cover update from playback service

parent 21e12427
......@@ -1515,9 +1515,14 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
sendBroadcast(widgetIntent);
}
private String mCurrentWidgetCover = null;
private void updateWidgetCover() {
sendBroadcast(new Intent(VLCAppWidgetProvider.ACTION_WIDGET_UPDATE_COVER)
.putExtra("artworkMrl", hasCurrentMedia() ? getCurrentMedia().getArtworkMrl() : null));
String newWidgetCover = hasCurrentMedia() ? getCurrentMedia().getArtworkMrl() : null;
if (!TextUtils.equals(mCurrentWidgetCover, newWidgetCover)) {
mCurrentWidgetCover = newWidgetCover;
sendBroadcast(new Intent(VLCAppWidgetProvider.ACTION_WIDGET_UPDATE_COVER)
.putExtra("artworkMrl", newWidgetCover));
}
}
private void updateWidgetPosition(final float pos) {
......
......@@ -57,7 +57,6 @@ abstract public class VLCAppWidgetProvider extends AppWidgetProvider {
public static final String ACTION_WIDGET_UPDATE_POSITION = ACTION_WIDGET_PREFIX+"UPDATE_POSITION";
public static final String ACTION_WIDGET_ENABLED = ACTION_WIDGET_PREFIX+"ENABLED";
public static final String ACTION_WIDGET_DISABLED = ACTION_WIDGET_PREFIX+"DISABLED";
private static String sCurrentArtworkMrl;
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
......@@ -118,30 +117,27 @@ abstract public class VLCAppWidgetProvider extends AppWidgetProvider {
views.setImageViewResource(R.id.play_pause, getPlayPauseImage(isplaying));
} else if (ACTION_WIDGET_UPDATE_COVER.equals(action)) {
final String artworkMrl = intent.getStringExtra("artworkMrl");
if (!TextUtils.equals(sCurrentArtworkMrl, artworkMrl)) {
sCurrentArtworkMrl = ""+artworkMrl;
if (!TextUtils.isEmpty(artworkMrl)) {
VLCApplication.runBackground(new Runnable() {
@Override
public void run() {
final Bitmap cover = AudioUtil.readCoverBitmap(Uri.decode(artworkMrl), 320);
VLCApplication.runOnMainThread(new Runnable() {
@Override
public void run() {
if (cover != null)
views.setImageViewBitmap(R.id.cover, cover);
else
views.setImageViewResource(R.id.cover, R.drawable.icon);
views.setProgressBar(R.id.timeline, 100, 0, false);
applyUpdate(context, views, partial);
}
});
}
});
} else
views.setImageViewResource(R.id.cover, R.drawable.icon);
views.setProgressBar(R.id.timeline, 100, 0, false);
}
if (!TextUtils.isEmpty(artworkMrl)) {
VLCApplication.runBackground(new Runnable() {
@Override
public void run() {
final Bitmap cover = AudioUtil.readCoverBitmap(Uri.decode(artworkMrl), 320);
VLCApplication.runOnMainThread(new Runnable() {
@Override
public void run() {
if (cover != null)
views.setImageViewBitmap(R.id.cover, cover);
else
views.setImageViewResource(R.id.cover, R.drawable.icon);
views.setProgressBar(R.id.timeline, 100, 0, false);
applyUpdate(context, views, partial);
}
});
}
});
} else
views.setImageViewResource(R.id.cover, R.drawable.icon);
views.setProgressBar(R.id.timeline, 100, 0, false);
} else if (ACTION_WIDGET_UPDATE_POSITION.equals(action)) {
final float pos = intent.getFloatExtra("position", 0f);
views.setProgressBar(R.id.timeline, 100, (int) (100 * pos), false);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment