Added an option to turn off the color
This commit is contained in:
parent
3fd86db39d
commit
2fa79c6d09
5 changed files with 66 additions and 3 deletions
|
|
@ -1,5 +1,6 @@
|
|||
package com.kabouzeid.gramophone.adapter.album;
|
||||
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
|
|
@ -7,8 +8,11 @@ import android.support.v7.widget.CardView;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.kabouzeid.appthemehelper.util.ColorUtil;
|
||||
import com.kabouzeid.appthemehelper.util.MaterialValueHelper;
|
||||
import com.kabouzeid.gramophone.glide.PhonographColoredTarget;
|
||||
import com.kabouzeid.gramophone.glide.SongGlideRequest;
|
||||
import com.kabouzeid.gramophone.helper.HorizontalAdapterHelper;
|
||||
import com.kabouzeid.gramophone.interfaces.CabHolder;
|
||||
import com.kabouzeid.gramophone.model.Album;
|
||||
|
|
@ -21,8 +25,8 @@ import java.util.ArrayList;
|
|||
public class HorizontalAlbumAdapter extends AlbumAdapter {
|
||||
public static final String TAG = AlbumAdapter.class.getSimpleName();
|
||||
|
||||
public HorizontalAlbumAdapter(@NonNull AppCompatActivity activity, ArrayList<Album> dataSet, @Nullable CabHolder cabHolder) {
|
||||
super(activity, dataSet, HorizontalAdapterHelper.LAYOUT_RES, true, cabHolder);
|
||||
public HorizontalAlbumAdapter(@NonNull AppCompatActivity activity, ArrayList<Album> dataSet,boolean usePalette, @Nullable CabHolder cabHolder) {
|
||||
super(activity, dataSet, HorizontalAdapterHelper.LAYOUT_RES, usePalette, cabHolder);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -46,6 +50,30 @@ public class HorizontalAlbumAdapter extends AlbumAdapter {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadAlbumCover(Album album, final ViewHolder holder) {
|
||||
if (holder.image == null) return;
|
||||
|
||||
SongGlideRequest.Builder.from(Glide.with(activity), album.safeGetFirstSong())
|
||||
.checkIgnoreMediaStore(activity)
|
||||
.generatePalette(activity).build()
|
||||
.into(new PhonographColoredTarget(holder.image) {
|
||||
@Override
|
||||
public void onLoadCleared(Drawable placeholder) {
|
||||
super.onLoadCleared(placeholder);
|
||||
setColors(getAlbumArtistFooterColor(), holder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onColorReady(int color) {
|
||||
if (usePalette)
|
||||
setColors(color, holder);
|
||||
else
|
||||
setColors(getAlbumArtistFooterColor(), holder);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getAlbumText(Album album) {
|
||||
return String.valueOf(album.getYear());
|
||||
|
|
|
|||
|
|
@ -31,5 +31,9 @@ public abstract class PhonographColoredTarget extends BitmapPaletteTarget {
|
|||
return ATHUtil.resolveColor(getView().getContext(), R.attr.defaultFooterColor);
|
||||
}
|
||||
|
||||
protected int getAlbumArtistFooterColor() {
|
||||
return ATHUtil.resolveColor(getView().getContext(), R.attr.cardBackgroundColor);
|
||||
}
|
||||
|
||||
public abstract void onColorReady(int color);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ import com.kabouzeid.gramophone.ui.activities.base.AbsSlidingMusicPanelActivity;
|
|||
import com.kabouzeid.gramophone.util.ArtistSignatureUtil;
|
||||
import com.kabouzeid.gramophone.util.NavigationUtil;
|
||||
import com.kabouzeid.gramophone.util.PhonographColorUtil;
|
||||
import com.kabouzeid.gramophone.util.PreferenceUtil;
|
||||
import com.kabouzeid.gramophone.util.Util;
|
||||
|
||||
import butterknife.BindView;
|
||||
|
|
@ -91,6 +92,7 @@ public class ArtistDetailActivity extends AbsSlidingMusicPanelActivity implement
|
|||
private int artistImageViewHeight;
|
||||
private int toolbarColor;
|
||||
private float toolbarAlpha;
|
||||
private boolean usePalette;
|
||||
|
||||
private Artist artist;
|
||||
@Nullable
|
||||
|
|
@ -109,6 +111,7 @@ public class ArtistDetailActivity extends AbsSlidingMusicPanelActivity implement
|
|||
supportPostponeEnterTransition();
|
||||
|
||||
lastFMRestClient = new LastFMRestClient(this);
|
||||
usePalette=PreferenceUtil.getInstance(this).albumArtistColoredFooters();
|
||||
|
||||
initViews();
|
||||
setUpObservableListViewParams();
|
||||
|
|
@ -194,7 +197,7 @@ public class ArtistDetailActivity extends AbsSlidingMusicPanelActivity implement
|
|||
|
||||
private void setUpAlbumRecyclerView() {
|
||||
albumRecyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false));
|
||||
albumAdapter = new HorizontalAlbumAdapter(this, getArtist().albums, this);
|
||||
albumAdapter = new HorizontalAlbumAdapter(this, getArtist().albums, usePalette, this);
|
||||
albumRecyclerView.setAdapter(albumAdapter);
|
||||
albumAdapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() {
|
||||
@Override
|
||||
|
|
@ -205,6 +208,12 @@ public class ArtistDetailActivity extends AbsSlidingMusicPanelActivity implement
|
|||
});
|
||||
}
|
||||
|
||||
protected void setUsePalette(boolean usePalette) {
|
||||
albumAdapter.usePalette(usePalette);
|
||||
PreferenceUtil.getInstance(this).setAlbumArtistColoredFooters(usePalette);
|
||||
this.usePalette = usePalette;
|
||||
}
|
||||
|
||||
private void reload() {
|
||||
getSupportLoaderManager().restartLoader(LOADER_ID, getIntent().getExtras(), this);
|
||||
}
|
||||
|
|
@ -309,6 +318,7 @@ public class ArtistDetailActivity extends AbsSlidingMusicPanelActivity implement
|
|||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.menu_artist_detail, menu);
|
||||
menu.findItem(R.id.action_colored_footers).setChecked(usePalette);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -339,6 +349,10 @@ public class ArtistDetailActivity extends AbsSlidingMusicPanelActivity implement
|
|||
Toast.makeText(ArtistDetailActivity.this, getResources().getString(R.string.updating), Toast.LENGTH_SHORT).show();
|
||||
loadArtistImage(true);
|
||||
return true;
|
||||
case R.id.action_colored_footers:
|
||||
item.setChecked(!item.isChecked());
|
||||
setUsePalette(item.isChecked());
|
||||
return true;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ public final class PreferenceUtil {
|
|||
public static final String ALBUM_COLORED_FOOTERS = "album_colored_footers";
|
||||
public static final String SONG_COLORED_FOOTERS = "song_colored_footers";
|
||||
public static final String ARTIST_COLORED_FOOTERS = "artist_colored_footers";
|
||||
public static final String ALBUM_ARTIST_COLORED_FOOTERS = "album_artist_colored_footers";
|
||||
|
||||
public static final String FORCE_SQUARE_ALBUM_COVER = "force_square_album_art";
|
||||
|
||||
|
|
@ -319,6 +320,16 @@ public final class PreferenceUtil {
|
|||
return mPreferences.getBoolean(ALBUM_COLORED_FOOTERS, true);
|
||||
}
|
||||
|
||||
public void setAlbumArtistColoredFooters(final boolean value) {
|
||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
||||
editor.putBoolean(ALBUM_ARTIST_COLORED_FOOTERS, value);
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public final boolean albumArtistColoredFooters() {
|
||||
return mPreferences.getBoolean(ALBUM_ARTIST_COLORED_FOOTERS, true);
|
||||
}
|
||||
|
||||
public void setSongColoredFooters(final boolean value) {
|
||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
||||
editor.putBoolean(SONG_COLORED_FOOTERS, value);
|
||||
|
|
|
|||
|
|
@ -19,6 +19,12 @@
|
|||
android:title="@string/action_re_download_artist_image"
|
||||
app:showAsAction="never" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_colored_footers"
|
||||
android:checkable="true"
|
||||
android:title="@string/colored_footers"
|
||||
app:showAsAction="never"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_sleep_timer"
|
||||
android:title="@string/action_sleep_timer"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue