use of android.support.v7.graphics.Palette.Swatch in project Timber by naman14.
the class AlbumAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(final ItemHolder itemHolder, int i) {
Album localItem = arraylist.get(i);
itemHolder.title.setText(localItem.title);
itemHolder.artist.setText(localItem.artistName);
ImageLoader.getInstance().displayImage(TimberUtils.getAlbumArtUri(localItem.id).toString(), itemHolder.albumArt, new DisplayImageOptions.Builder().cacheInMemory(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) {
new Palette.Builder(loadedImage).generate(new Palette.PaletteAsyncListener() {
@Override
public void onGenerated(Palette palette) {
Palette.Swatch swatch = palette.getVibrantSwatch();
if (swatch != null) {
int color = swatch.getRgb();
itemHolder.footer.setBackgroundColor(color);
int textColor = TimberUtils.getBlackWhiteColor(swatch.getTitleTextColor());
itemHolder.title.setTextColor(textColor);
itemHolder.artist.setTextColor(textColor);
} else {
Palette.Swatch mutedSwatch = palette.getMutedSwatch();
if (mutedSwatch != null) {
int color = mutedSwatch.getRgb();
itemHolder.footer.setBackgroundColor(color);
int textColor = TimberUtils.getBlackWhiteColor(mutedSwatch.getTitleTextColor());
itemHolder.title.setTextColor(textColor);
itemHolder.artist.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.title.setTextColor(textColorPrimary);
itemHolder.artist.setTextColor(textColorPrimary);
}
}
}
});
if (TimberUtils.isLollipop())
itemHolder.albumArt.setTransitionName("transition_album_art" + i);
}
use of android.support.v7.graphics.Palette.Swatch in project Timber by naman14.
the class PlaylistAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(final ItemHolder itemHolder, int i) {
final Playlist localItem = arraylist.get(i);
itemHolder.title.setText(localItem.name);
String s = getAlbumArtUri(i, localItem.id);
itemHolder.albumArt.setTag(firstAlbumID);
ImageLoader.getInstance().displayImage(s, itemHolder.albumArt, new DisplayImageOptions.Builder().cacheInMemory(true).showImageOnFail(R.drawable.ic_empty_music2).resetViewBeforeLoading(true).build(), new SimpleImageLoadingListener() {
@Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
if (isGrid) {
new Palette.Builder(loadedImage).generate(new Palette.PaletteAsyncListener() {
@Override
public void onGenerated(Palette palette) {
Palette.Swatch swatch = palette.getVibrantSwatch();
if (swatch != null) {
int color = swatch.getRgb();
itemHolder.footer.setBackgroundColor(color);
int textColor = TimberUtils.getBlackWhiteColor(swatch.getTitleTextColor());
itemHolder.title.setTextColor(textColor);
itemHolder.artist.setTextColor(textColor);
} else {
Palette.Swatch mutedSwatch = palette.getMutedSwatch();
if (mutedSwatch != null) {
int color = mutedSwatch.getRgb();
itemHolder.footer.setBackgroundColor(color);
int textColor = TimberUtils.getBlackWhiteColor(mutedSwatch.getTitleTextColor());
itemHolder.title.setTextColor(textColor);
itemHolder.artist.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.title.setTextColor(textColorPrimary);
itemHolder.artist.setTextColor(textColorPrimary);
}
}
}
});
itemHolder.artist.setText(" " + String.valueOf(songCountInt) + " " + mContext.getString(R.string.songs));
if (TimberUtils.isLollipop())
itemHolder.albumArt.setTransitionName("transition_album_art" + i);
}
use of android.support.v7.graphics.Palette.Swatch in project Timber by naman14.
the class ArtistDetailFragment method setUpArtistDetails.
private void setUpArtistDetails() {
final Artist artist = ArtistLoader.getArtist(getActivity(), artistID);
collapsingToolbarLayout.setTitle(artist.name);
LastFmClient.getInstance(getActivity()).getArtistInfo(new ArtistQuery(artist.name), new ArtistInfoListener() {
@Override
public void artistInfoSucess(final LastfmArtist artist) {
if (artist != null) {
ImageLoader.getInstance().displayImage(artist.mArtwork.get(4).mUrl, artistArt, new DisplayImageOptions.Builder().cacheInMemory(true).cacheOnDisk(true).showImageOnFail(R.drawable.ic_empty_music2).build(), new SimpleImageLoadingListener() {
@Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
largeImageLoaded = true;
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);
}
}
}
});
} catch (Exception ignored) {
}
}
});
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
setBlurredPlaceholder(artist);
}
}, 100);
}
}
@Override
public void artistInfoFailed() {
}
});
}
use of android.support.v7.graphics.Palette.Swatch in project Material-Movies by saulmm.
the class MovieDetailActivity method onGenerated.
@Override
public void onGenerated(Palette palette) {
if (palette != null) {
final Swatch darkVibrantSwatch = palette.getDarkVibrantSwatch();
final Swatch darkMutedSwatch = palette.getDarkMutedSwatch();
final Swatch lightVibrantSwatch = palette.getLightVibrantSwatch();
final Swatch lightMutedSwatch = palette.getLightMutedSwatch();
final Swatch vibrantSwatch = palette.getVibrantSwatch();
final Swatch backgroundAndContentColors = (darkVibrantSwatch != null) ? darkVibrantSwatch : darkMutedSwatch;
final Swatch titleAndFabColors = (darkVibrantSwatch != null) ? lightVibrantSwatch : lightMutedSwatch;
setBackgroundAndFabContentColors(backgroundAndContentColors);
setHeadersTitlColors(titleAndFabColors);
setVibrantElements(vibrantSwatch);
}
}
use of android.support.v7.graphics.Palette.Swatch in project Shuttle by timusus.
the class PlayerFragment method trackInfoChanged.
@Override
public void trackInfoChanged(@Nullable Song song) {
if (song == null)
return;
if (isExpanded && !snowfallView.isSnowing()) {
snowfallView.letItSnow();
} else {
snowfallView.removeSnow();
}
String totalTimeString = StringUtils.makeTimeString(this.getActivity(), song.duration / 1000);
if (!TextUtils.isEmpty(totalTimeString)) {
if (totalTime != null) {
totalTime.setText(totalTimeString);
}
}
if (track != null) {
track.setText(song.name);
track.setSelected(true);
}
if (album != null) {
album.setText(String.format("%s | %s", song.artistName, song.albumName));
}
if (isLandscape) {
toolbar.setTitle(song.name);
toolbar.setSubtitle(String.format("%s | %s", song.artistName, song.albumName));
target = Glide.with(this).load(song).diskCacheStrategy(DiskCacheStrategy.SOURCE).bitmapTransform(new BlurTransformation(getContext(), 15, 4)).error(PlaceholderProvider.getInstance().getPlaceHolderDrawable(song.name, true)).thumbnail(Glide.with(this).load(this.song).bitmapTransform(new BlurTransformation(getContext(), 15, 4))).crossFade(600).into(backgroundView);
this.song = song;
} else {
backgroundView.setImageDrawable(null);
toolbar.setTitle(null);
toolbar.setSubtitle(null);
}
if (SettingsManager.getInstance().getUsePalette()) {
// noinspection unchecked
Glide.with(this).load(song).asBitmap().transcode(new PaletteBitmapTranscoder(getContext()), PaletteBitmap.class).override(250, 250).diskCacheStrategy(DiskCacheStrategy.ALL).into(new SimpleTarget<PaletteBitmap>() {
@Override
public void onResourceReady(PaletteBitmap resource, GlideAnimation<? super PaletteBitmap> glideAnimation) {
if (!isAdded() || getContext() == null) {
return;
}
Palette.Swatch swatch = resource.palette.getDarkMutedSwatch();
if (swatch != null) {
if (SettingsManager.getInstance().getUsePalette()) {
if (SettingsManager.getInstance().getUsePaletteNowPlayingOnly()) {
animateColors(currentColor, swatch.getRgb(), color -> invalidateColors(color));
} else {
// Set Aesthetic colors globally, based on the current Palette swatch
disposables.add(Aesthetic.get(getContext()).colorPrimary().take(1).subscribe(integer -> animateColors(integer, swatch.getRgb(), color -> {
if (getContext() != null && isAdded()) {
Aesthetic aesthetic = Aesthetic.get(getContext()).colorPrimary(color).colorStatusBarAuto();
if (SettingsManager.getInstance().getTintNavBar()) {
aesthetic = aesthetic.colorNavigationBar(color);
}
aesthetic.apply();
}
})));
}
}
} else {
// Failed to generate the dark muted swatch, fall back to the primary theme colour.
Aesthetic.get(getContext()).colorPrimary().take(1).subscribe(primaryColor -> animateColors(currentColor, primaryColor, color -> invalidateColors(color)));
}
}
@Override
public void onLoadFailed(Exception e, Drawable errorDrawable) {
super.onLoadFailed(e, errorDrawable);
Aesthetic.get(getContext()).colorPrimary().take(1).subscribe(primaryColor -> animateColors(currentColor, primaryColor, color -> invalidateColors(color)));
}
});
}
}
Aggregations