Commit 99e60c93 authored by Sébastien Toque's avatar Sébastien Toque
Browse files

widget: scale down the cover to avoid refresh failure (happens if the cover is too big)

parent 7df6a847
......@@ -528,7 +528,7 @@ public class AudioService extends Service {
if (mCurrentMedia != null) {
views.setTextViewText(R.id.songName, mCurrentMedia.getTitle());
views.setTextViewText(R.id.artist, mCurrentMedia.getArtist());
cover = getCover();
cover = Util.scaleDownBitmap(context, getCover(), 64);
}
else {
views.setTextViewText(R.id.songName, "VLC mini player");
......
......@@ -23,6 +23,8 @@ package org.videolan.vlc.android;
import java.lang.reflect.Field;
import java.text.DecimalFormat;
import android.content.Context;
import android.graphics.Bitmap;
import android.widget.Toast;
public class Util {
......@@ -100,4 +102,14 @@ public class Util {
}
return apiLevel;
}
public static Bitmap scaleDownBitmap(Context context, Bitmap bitmap, int width) {
if (bitmap != null) {
final float densityMultiplier = context.getResources().getDisplayMetrics().density;
int w = (int) (width * densityMultiplier);
int h = (int) (w * bitmap.getHeight() / ((double) bitmap.getWidth()));
bitmap = Bitmap.createScaledBitmap(bitmap, w, h, true);
}
return bitmap;
}
}
Supports Markdown
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