use of android.support.v7.graphics.Palette in project Timber by naman14.
the class AlbumDetailFragment method setAlbumart.
private void setAlbumart() {
ImageLoader.getInstance().displayImage(TimberUtils.getAlbumArtUri(albumID).toString(), albumArt, new DisplayImageOptions.Builder().cacheInMemory(true).showImageOnFail(R.drawable.ic_empty_music2).resetViewBeforeLoading(true).build(), new ImageLoadingListener() {
@Override
public void onLoadingStarted(String imageUri, View view) {
}
@Override
public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
loadFailed = true;
MaterialDrawableBuilder builder = MaterialDrawableBuilder.with(context).setIcon(MaterialDrawableBuilder.IconValue.SHUFFLE).setColor(TimberUtils.getBlackWhiteColor(Config.accentColor(context, Helpers.getATEKey(context))));
ATEUtils.setFabBackgroundTint(fab, Config.accentColor(context, Helpers.getATEKey(context)));
fab.setImageDrawable(builder.build());
}
@Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
try {
new Palette.Builder(loadedImage).generate(new Palette.PaletteAsyncListener() {
@Override
public void onGenerated(Palette palette) {
Palette.Swatch swatch = palette.getVibrantSwatch();
if (swatch != null) {
primaryColor = swatch.getRgb();
collapsingToolbarLayout.setContentScrimColor(primaryColor);
if (getActivity() != null)
ATEUtils.setStatusBarColor(getActivity(), Helpers.getATEKey(getActivity()), primaryColor);
} else {
Palette.Swatch swatchMuted = palette.getMutedSwatch();
if (swatchMuted != null) {
primaryColor = swatchMuted.getRgb();
collapsingToolbarLayout.setContentScrimColor(primaryColor);
if (getActivity() != null)
ATEUtils.setStatusBarColor(getActivity(), Helpers.getATEKey(getActivity()), primaryColor);
}
}
MaterialDrawableBuilder builder = MaterialDrawableBuilder.with(getActivity()).setIcon(MaterialDrawableBuilder.IconValue.SHUFFLE).setSizeDp(30);
if (primaryColor != -1) {
builder.setColor(TimberUtils.getBlackWhiteColor(primaryColor));
ATEUtils.setFabBackgroundTint(fab, primaryColor);
fab.setImageDrawable(builder.build());
} else {
if (context != null) {
ATEUtils.setFabBackgroundTint(fab, Config.accentColor(context, Helpers.getATEKey(context)));
builder.setColor(TimberUtils.getBlackWhiteColor(Config.accentColor(context, Helpers.getATEKey(context))));
fab.setImageDrawable(builder.build());
}
}
}
});
} catch (Exception ignored) {
}
}
@Override
public void onLoadingCancelled(String imageUri, View view) {
}
});
}
use of android.support.v7.graphics.Palette in project Timber by naman14.
the class ArtistAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(final ItemHolder itemHolder, int i) {
final Artist localItem = arraylist.get(i);
itemHolder.name.setText(localItem.name);
String albumNmber = TimberUtils.makeLabel(mContext, R.plurals.Nalbums, localItem.albumCount);
String songCount = TimberUtils.makeLabel(mContext, R.plurals.Nsongs, localItem.songCount);
itemHolder.albums.setText(TimberUtils.makeCombinedString(mContext, albumNmber, songCount));
LastFmClient.getInstance(mContext).getArtistInfo(new ArtistQuery(localItem.name), new ArtistInfoListener() {
@Override
public void artistInfoSucess(LastfmArtist artist) {
if (artist != null && artist.mArtwork != null) {
if (isGrid) {
ImageLoader.getInstance().displayImage(artist.mArtwork.get(2).mUrl, itemHolder.artistImage, new DisplayImageOptions.Builder().cacheInMemory(true).cacheOnDisk(true).showImageOnFail(R.drawable.ic_empty_music2).resetViewBeforeLoading(true).displayer(new FadeInBitmapDisplayer(400)).build(), new SimpleImageLoadingListener() {
@Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
if (isGrid && loadedImage != null) {
new Palette.Builder(loadedImage).generate(new Palette.PaletteAsyncListener() {
@Override
public void onGenerated(Palette palette) {
int color = palette.getVibrantColor(Color.parseColor("#66000000"));
itemHolder.footer.setBackgroundColor(color);
Palette.Swatch swatch = palette.getVibrantSwatch();
int textColor;
if (swatch != null) {
textColor = getOpaqueColor(swatch.getTitleTextColor());
} else
textColor = Color.parseColor("#ffffff");
itemHolder.name.setTextColor(textColor);
itemHolder.albums.setTextColor(textColor);
}
});
}
}
@Override
public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
if (isGrid) {
itemHolder.footer.setBackgroundColor(0);
if (mContext != null) {
int textColorPrimary = Config.textColorPrimary(mContext, Helpers.getATEKey(mContext));
itemHolder.name.setTextColor(textColorPrimary);
itemHolder.albums.setTextColor(textColorPrimary);
}
}
}
});
} else {
ImageLoader.getInstance().displayImage(artist.mArtwork.get(1).mUrl, itemHolder.artistImage, new DisplayImageOptions.Builder().cacheInMemory(true).cacheOnDisk(true).showImageOnFail(R.drawable.ic_empty_music2).resetViewBeforeLoading(true).displayer(new FadeInBitmapDisplayer(400)).build());
}
}
}
@Override
public void artistInfoFailed() {
}
});
if (TimberUtils.isLollipop())
itemHolder.artistImage.setTransitionName("transition_artist_art" + i);
}
use of android.support.v7.graphics.Palette in project LookLook by xinghongfei.
the class MainActivity method setStatusColor.
private void setStatusColor() {
Bitmap bm = BitmapFactory.decodeResource(getResources(), R.drawable.nav_icon);
Palette palette = Palette.generate(bm);
if (palette.getLightVibrantSwatch() != null) {
mainColor = palette.getLightVibrantSwatch().getRgb();
getWindow().setStatusBarColor(palette.getLightVibrantSwatch().getRgb());
toolbar.setBackgroundColor(palette.getLightVibrantSwatch().getRgb());
}
}
use of android.support.v7.graphics.Palette in project PhotoNoter by yydcdut.
the class Utils method getPaletteColor.
public static int getPaletteColor(Bitmap bitmap) {
Palette.Builder builder = Palette.from(bitmap);
Palette palette = builder.generate();
Palette.Swatch vibrantSwatch = palette.getVibrantSwatch();
if (vibrantSwatch == null) {
Palette.Swatch lightVibrant = palette.getLightVibrantSwatch();
if (lightVibrant == null) {
Palette.Swatch darkVibrant = palette.getDarkVibrantSwatch();
if (darkVibrant == null) {
Palette.Swatch mutedSwatch = palette.getMutedSwatch();
if (mutedSwatch == null) {
Palette.Swatch lightMuted = palette.getMutedSwatch();
if (lightMuted == null) {
Palette.Swatch darkMuted = palette.getDarkMutedSwatch();
if (darkMuted == null) {
return Color.WHITE;
} else {
return darkMuted.getRgb();
}
} else {
return lightMuted.getRgb();
}
} else {
return mutedSwatch.getRgb();
}
} else {
return darkVibrant.getRgb();
}
} else {
return lightVibrant.getRgb();
}
} else {
return vibrantSwatch.getRgb();
}
}
use of android.support.v7.graphics.Palette in project Shuttle by timusus.
the class PaletteBitmapTranscoder method transcode.
@Override
public Resource<PaletteBitmap> transcode(Resource<Bitmap> toTranscode) {
Bitmap bitmap = toTranscode.get();
Palette palette = new Palette.Builder(bitmap).generate();
PaletteBitmap result = new PaletteBitmap(bitmap, palette);
return new PaletteBitmapResource(result, bitmapPool);
}
Aggregations