Commit 5a956d2d authored by Geoffrey Métais's avatar Geoffrey Métais

Spare background cover update if not needed

parent 23ef5c49
......@@ -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();
......
......@@ -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
......
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