Load bitmaps in the size we need them
This commit is contained in:
parent
a8ba29fe0b
commit
bca8b83140
|
@ -30,7 +30,6 @@ import android.widget.Toast;
|
||||||
import com.bumptech.glide.Glide;
|
import com.bumptech.glide.Glide;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
|
|
||||||
import de.danoeh.antennapod.core.ClientConfig;
|
import de.danoeh.antennapod.core.ClientConfig;
|
||||||
import de.danoeh.antennapod.core.R;
|
import de.danoeh.antennapod.core.R;
|
||||||
|
@ -808,14 +807,11 @@ public class PlaybackService extends Service {
|
||||||
.load(info.playable.getImageUri())
|
.load(info.playable.getImageUri())
|
||||||
.asBitmap()
|
.asBitmap()
|
||||||
.diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY)
|
.diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY)
|
||||||
.into(-1, -1) // this resizing would not be exact, so we have
|
.centerCrop()
|
||||||
// scale the bitmap ourselves
|
.into(iconSize, iconSize)
|
||||||
.get();
|
.get();
|
||||||
icon = Bitmap.createScaledBitmap(icon, iconSize, iconSize, true);
|
} catch(Exception e) {
|
||||||
} catch (InterruptedException e) {
|
Log.e(TAG, Log.getStackTraceString(e));
|
||||||
e.printStackTrace();
|
|
||||||
} catch (ExecutionException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -835,7 +831,7 @@ public class PlaybackService extends Service {
|
||||||
String contentTitle = info.playable.getFeedTitle();
|
String contentTitle = info.playable.getFeedTitle();
|
||||||
Notification notification = null;
|
Notification notification = null;
|
||||||
|
|
||||||
NotificationCompat.Builder notificationBuilder = new android.support.v7.app.NotificationCompat.Builder(
|
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(
|
||||||
PlaybackService.this)
|
PlaybackService.this)
|
||||||
.setContentTitle(contentTitle)
|
.setContentTitle(contentTitle)
|
||||||
.setContentText(contentText)
|
.setContentText(contentText)
|
||||||
|
|
|
@ -17,12 +17,13 @@ import android.support.v4.media.session.PlaybackStateCompat;
|
||||||
import android.telephony.TelephonyManager;
|
import android.telephony.TelephonyManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.Pair;
|
import android.util.Pair;
|
||||||
|
import android.view.Display;
|
||||||
import android.view.InputDevice;
|
import android.view.InputDevice;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.SurfaceHolder;
|
import android.view.SurfaceHolder;
|
||||||
|
import android.view.WindowManager;
|
||||||
|
|
||||||
import com.bumptech.glide.Glide;
|
import com.bumptech.glide.Glide;
|
||||||
import com.bumptech.glide.request.target.Target;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.concurrent.CountDownLatch;
|
import java.util.concurrent.CountDownLatch;
|
||||||
|
@ -292,22 +293,23 @@ public class PlaybackServiceMediaPlayer implements SharedPreferences.OnSharedPre
|
||||||
builder.putLong(MediaMetadataCompat.METADATA_KEY_DURATION, p.getDuration());
|
builder.putLong(MediaMetadataCompat.METADATA_KEY_DURATION, p.getDuration());
|
||||||
builder.putString(MediaMetadataCompat.METADATA_KEY_DISPLAY_TITLE, p.getEpisodeTitle());
|
builder.putString(MediaMetadataCompat.METADATA_KEY_DISPLAY_TITLE, p.getEpisodeTitle());
|
||||||
builder.putString(MediaMetadataCompat.METADATA_KEY_ALBUM, p.getFeedTitle());
|
builder.putString(MediaMetadataCompat.METADATA_KEY_ALBUM, p.getFeedTitle());
|
||||||
if (p.getImageUri() != null) {
|
if (p.getImageUri() != null && UserPreferences.setLockscreenBackground()) {
|
||||||
if (UserPreferences.setLockscreenBackground()) {
|
|
||||||
builder.putString(MediaMetadataCompat.METADATA_KEY_ART_URI, p.getImageUri().toString());
|
builder.putString(MediaMetadataCompat.METADATA_KEY_ART_URI, p.getImageUri().toString());
|
||||||
try {
|
try {
|
||||||
|
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
|
||||||
|
Display display = wm.getDefaultDisplay();
|
||||||
Bitmap art = Glide.with(context)
|
Bitmap art = Glide.with(context)
|
||||||
.load(p.getImageUri())
|
.load(p.getImageUri())
|
||||||
.asBitmap()
|
.asBitmap()
|
||||||
.diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY)
|
.diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY)
|
||||||
.into(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL)
|
.centerCrop()
|
||||||
|
.into(display.getWidth(), display.getHeight())
|
||||||
.get();
|
.get();
|
||||||
builder.putBitmap(MediaMetadataCompat.METADATA_KEY_ART, art);
|
builder.putBitmap(MediaMetadataCompat.METADATA_KEY_ART, art);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e(TAG, Log.getStackTraceString(e));
|
Log.e(TAG, Log.getStackTraceString(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
mediaSession.setMetadata(builder.build());
|
mediaSession.setMetadata(builder.build());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue