Improved the Palette APIs speed and readded colored footers to artist and song adapters.

This commit is contained in:
Karim Abou Zeid 2016-01-28 17:49:37 +01:00
commit 2ce9b38747
6 changed files with 30 additions and 62 deletions

View file

@ -139,6 +139,4 @@ dependencies {
compile 'com.github.bumptech.glide:glide:3.6.1'
compile 'com.github.kabouzeid:RecyclerView-FastScroll:v1.2-kmod'
compile 'com.github.kabouzeid:app-theme-helper:0.7.8kmod'
compile 'com.github.kabouzeid:GlidePalette:e34717bced@aar'
}

View file

@ -12,6 +12,8 @@ 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.R;
import com.kabouzeid.gramophone.adapter.base.AbsMultiSelectAdapter;
import com.kabouzeid.gramophone.adapter.base.MediaEntryViewHolder;
@ -104,16 +106,15 @@ public class AlbumAdapter extends AbsMultiSelectAdapter<AlbumAdapter.ViewHolder,
}
private void setColors(int color, ViewHolder holder) {
// TODO
// if (holder.paletteColorContainer != null) {
// holder.paletteColorContainer.setBackgroundColor(color);
// if (holder.title != null) {
// holder.title.setTextColor(PhonographColorUtil.getPrimaryTextColorForBackground(activity, color));
// }
// if (holder.text != null) {
// holder.text.setTextColor(PhonographColorUtil.getSecondaryTextColorForBackground(activity, color));
// }
// }
if (holder.paletteColorContainer != null) {
holder.paletteColorContainer.setBackgroundColor(color);
if (holder.title != null) {
holder.title.setTextColor(MaterialValueHelper.getPrimaryTextColor(activity, ColorUtil.isColorLight(color)));
}
if (holder.text != null) {
holder.text.setTextColor(MaterialValueHelper.getSecondaryTextColor(activity, ColorUtil.isColorLight(color)));
}
}
}
protected void loadAlbumCover(Album album, final ViewHolder holder) {

View file

@ -15,6 +15,8 @@ import com.bumptech.glide.Glide;
import com.bumptech.glide.Priority;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.request.target.Target;
import com.kabouzeid.appthemehelper.util.ColorUtil;
import com.kabouzeid.appthemehelper.util.MaterialValueHelper;
import com.kabouzeid.gramophone.R;
import com.kabouzeid.gramophone.adapter.base.AbsMultiSelectAdapter;
import com.kabouzeid.gramophone.adapter.base.MediaEntryViewHolder;
@ -109,14 +111,13 @@ public class ArtistAdapter extends AbsMultiSelectAdapter<ArtistAdapter.ViewHolde
private void setColors(int color, ViewHolder holder) {
if (holder.paletteColorContainer != null) {
// TODO
// holder.paletteColorContainer.setBackgroundColor(color);
// if (holder.title != null) {
// holder.title.setTextColor(PhonographColorUtil.getPrimaryTextColorForBackground(activity, color));
// }
// if (holder.text != null) {
// holder.text.setTextColor(PhonographColorUtil.getSecondaryTextColorForBackground(activity, color));
// }
holder.paletteColorContainer.setBackgroundColor(color);
if (holder.title != null) {
holder.title.setTextColor(MaterialValueHelper.getPrimaryTextColor(activity, ColorUtil.isColorLight(color)));
}
if (holder.text != null) {
holder.text.setTextColor(MaterialValueHelper.getSecondaryTextColor(activity, ColorUtil.isColorLight(color)));
}
}
}

View file

@ -13,6 +13,8 @@ import android.view.ViewGroup;
import com.afollestad.materialcab.MaterialCab;
import com.bumptech.glide.Glide;
import com.kabouzeid.appthemehelper.util.ColorUtil;
import com.kabouzeid.appthemehelper.util.MaterialValueHelper;
import com.kabouzeid.gramophone.R;
import com.kabouzeid.gramophone.adapter.base.AbsMultiSelectAdapter;
import com.kabouzeid.gramophone.adapter.base.MediaEntryViewHolder;
@ -106,14 +108,13 @@ public class SongAdapter extends AbsMultiSelectAdapter<SongAdapter.ViewHolder, S
private void setColors(int color, ViewHolder holder) {
if (holder.paletteColorContainer != null) {
// TODO
// holder.paletteColorContainer.setBackgroundColor(color);
// if (holder.title != null) {
// holder.title.setTextColor(PhonographColorUtil.getPrimaryTextColorForBackground(activity, color));
// }
// if (holder.text != null) {
// holder.text.setTextColor(PhonographColorUtil.getSecondaryTextColorForBackground(activity, color));
// }
holder.paletteColorContainer.setBackgroundColor(color);
if (holder.title != null) {
holder.title.setTextColor(MaterialValueHelper.getPrimaryTextColor(activity, ColorUtil.isColorLight(color)));
}
if (holder.text != null) {
holder.text.setTextColor(MaterialValueHelper.getSecondaryTextColor(activity, ColorUtil.isColorLight(color)));
}
}
}

View file

@ -1,33 +0,0 @@
package com.kabouzeid.gramophone.glide.palette;
import android.support.annotation.ColorInt;
import android.support.v7.graphics.Palette;
import com.github.florent37.glidepalette.common.BaseColorGenerator;
/**
* @author Karim Abou Zeid (kabouzeid)
*/
public class CustomTextColorGenerator extends BaseColorGenerator {
private final int titleDark;
private final int titleLight;
private final int bodyDark;
private final int bodyLight;
public CustomTextColorGenerator(@ColorInt int titleDark, @ColorInt int titleLight, @ColorInt int bodyDark, @ColorInt int bodyLight) {
this.titleDark = titleDark;
this.titleLight = titleLight;
this.bodyDark = bodyDark;
this.bodyLight = bodyLight;
}
@Override
public int getTitleTextColor(Palette.Swatch swatch) {
return super.getTitleTextColor(swatch);
}
@Override
public int getBodyTextColor(Palette.Swatch swatch) {
return super.getBodyTextColor(swatch);
}
}

View file

@ -14,7 +14,7 @@ import java.util.Comparator;
* @author Karim Abou Zeid (kabouzeid)
*/
public class PhonographColorUtil {
public static final int PALETTE_BITMAP_SIZE = 100;
public static final int PALETTE_BITMAP_SIZE = 10;
@Nullable
public static Palette generatePalette(Bitmap bitmap) {