[Android] Spare background cover update if not needed
Geoffrey Métais
git at videolan.org
Fri Feb 17 11:57:29 CET 2017
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Feb 17 11:49:51 2017 +0100| [5a956d2d1efb49eb771ab191898380e478498054] | committer: Geoffrey Métais
Spare background cover update if not needed
> https://code.videolan.org/videolan/vlc-android/commit/5a956d2d1efb49eb771ab191898380e478498054
---
vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java | 4 ++++
.../org/videolan/vlc/gui/tv/audioplayer/AudioPlayerActivity.java | 8 +++++++-
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java
index de8f14f..8df06d8 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java
@@ -95,6 +95,7 @@ public class AudioPlayer extends PlaybackServiceFragment implements PlaybackServ
private boolean mProgressBarVisible;
private boolean mHeaderTimeVisible;
private int mPlayerState;
+ private String mCurrentCoverArt;
// Tips
private static final String PREF_PLAYLIST_TIPS_SHOWN = "playlist_tips_shown";
@@ -273,6 +274,9 @@ public class AudioPlayer extends PlaybackServiceFragment implements PlaybackServ
private void updateBackground() {
if (AndroidUtil.isJellyBeanMR1OrLater()) {
final MediaWrapper mw = mService.getCurrentMediaWrapper();
+ if (TextUtils.equals(mCurrentCoverArt, mw.getArtworkMrl()))
+ return;
+ mCurrentCoverArt = mw.getArtworkMrl();
if (mw == null || TextUtils.isEmpty(mw.getArtworkMrl())) {
mBinding.backgroundView.setImageResource(DEFAULT_BACKGROUND_ID);
mBinding.backgroundView.clearColorFilter();
diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/audioplayer/AudioPlayerActivity.java b/vlc-android/src/org/videolan/vlc/gui/tv/audioplayer/AudioPlayerActivity.java
index 35a3ed0..543fe77 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/audioplayer/AudioPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/audioplayer/AudioPlayerActivity.java
@@ -30,6 +30,7 @@ import android.preference.PreferenceManager;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
+import android.text.TextUtils;
import android.view.InputDevice;
import android.view.KeyEvent;
import android.view.MotionEvent;
@@ -73,6 +74,7 @@ public class AudioPlayerActivity extends BaseTvActivity implements PlaybackServi
private long mLastMove;
private int mCurrentlyPlaying, mPositionSaved = 0;
private boolean mShuffling = false;
+ private String mCurrentCoverArt;
private TextView mTitleTv, mArtistTv;
private ImageView mPlayPauseButton, mCover, mNext, mShuffle, mRepeat, mBackground;
@@ -174,10 +176,14 @@ public class AudioPlayerActivity extends BaseTvActivity implements PlaybackServi
mProgressBar.setMax((int) mService.getLength());
mCurrentlyPlaying = mService.getCurrentMediaPosition();
selectItem(mCurrentlyPlaying);
+ final MediaWrapper mw = mService.getCurrentMediaWrapper();
+ if (TextUtils.equals(mCurrentCoverArt, mw.getArtworkMrl()))
+ return;
+ mCurrentCoverArt = mw.getArtworkMrl();
VLCApplication.runBackground(new Runnable() {
@Override
public void run() {
- final Bitmap cover = AudioUtil.readCoverBitmap(Strings.removeFileProtocole(Uri.decode(mService.getCurrentMediaWrapper().getArtworkMrl())), mCover.getWidth());
+ final Bitmap cover = AudioUtil.readCoverBitmap(Strings.removeFileProtocole(Uri.decode(mCurrentCoverArt)), mCover.getWidth());
final Bitmap blurredCover = UiTools.blurBitmap(cover);
VLCApplication.runOnMainThread(new Runnable() {
@Override
More information about the Android
mailing list