diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java b/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java index 1313d9607..2214e992f 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java @@ -30,7 +30,6 @@ import android.widget.Toast; import com.bumptech.glide.Glide; import java.util.List; -import java.util.concurrent.ExecutionException; import de.danoeh.antennapod.core.ClientConfig; import de.danoeh.antennapod.core.R; @@ -808,14 +807,11 @@ public class PlaybackService extends Service { .load(info.playable.getImageUri()) .asBitmap() .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) - .into(-1, -1) // this resizing would not be exact, so we have - // scale the bitmap ourselves + .centerCrop() + .into(iconSize, iconSize) .get(); - icon = Bitmap.createScaledBitmap(icon, iconSize, iconSize, true); - } catch (InterruptedException e) { - e.printStackTrace(); - } catch (ExecutionException e) { - e.printStackTrace(); + } catch(Exception e) { + Log.e(TAG, Log.getStackTraceString(e)); } } } @@ -835,7 +831,7 @@ public class PlaybackService extends Service { String contentTitle = info.playable.getFeedTitle(); Notification notification = null; - NotificationCompat.Builder notificationBuilder = new android.support.v7.app.NotificationCompat.Builder( + NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder( PlaybackService.this) .setContentTitle(contentTitle) .setContentText(contentText) diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackServiceMediaPlayer.java b/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackServiceMediaPlayer.java index 6ad376bf0..56b81ec4a 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackServiceMediaPlayer.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackServiceMediaPlayer.java @@ -17,12 +17,13 @@ import android.support.v4.media.session.PlaybackStateCompat; import android.telephony.TelephonyManager; import android.util.Log; import android.util.Pair; +import android.view.Display; import android.view.InputDevice; import android.view.KeyEvent; import android.view.SurfaceHolder; +import android.view.WindowManager; import com.bumptech.glide.Glide; -import com.bumptech.glide.request.target.Target; import java.io.IOException; import java.util.concurrent.CountDownLatch; @@ -292,20 +293,21 @@ public class PlaybackServiceMediaPlayer implements SharedPreferences.OnSharedPre builder.putLong(MediaMetadataCompat.METADATA_KEY_DURATION, p.getDuration()); builder.putString(MediaMetadataCompat.METADATA_KEY_DISPLAY_TITLE, p.getEpisodeTitle()); builder.putString(MediaMetadataCompat.METADATA_KEY_ALBUM, p.getFeedTitle()); - if (p.getImageUri() != null) { - if (UserPreferences.setLockscreenBackground()) { - builder.putString(MediaMetadataCompat.METADATA_KEY_ART_URI, p.getImageUri().toString()); - try { - Bitmap art = Glide.with(context) + if (p.getImageUri() != null && UserPreferences.setLockscreenBackground()) { + builder.putString(MediaMetadataCompat.METADATA_KEY_ART_URI, p.getImageUri().toString()); + try { + WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); + Display display = wm.getDefaultDisplay(); + Bitmap art = Glide.with(context) .load(p.getImageUri()) .asBitmap() .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) - .into(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL) + .centerCrop() + .into(display.getWidth(), display.getHeight()) .get(); - builder.putBitmap(MediaMetadataCompat.METADATA_KEY_ART, art); - } catch (Exception e) { - Log.e(TAG, Log.getStackTraceString(e)); - } + builder.putBitmap(MediaMetadataCompat.METADATA_KEY_ART, art); + } catch (Exception e) { + Log.e(TAG, Log.getStackTraceString(e)); } } mediaSession.setMetadata(builder.build());