use of android.support.v7.graphics.Palette 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 in project LeafPic by HoraApps.
the class PaletteActivity method setPalette.
public void setPalette() {
Bitmap myBitmap = ((BitmapDrawable) paletteImg.getDrawable()).getBitmap();
((TextView) findViewById(R.id.palette_image_title)).setText(uri.getPath().substring(uri.getPath().lastIndexOf("/") + 1));
((TextView) findViewById(R.id.palette_image_caption)).setText(uri.getPath());
palette = Palette.from(myBitmap).generate();
rvPalette = (RecyclerView) findViewById(R.id.paletteRecycler);
rvPalette.setLayoutManager(new LinearLayoutManager(this));
rvPalette.setNestedScrollingEnabled(false);
paletteAdapter = new PaletteAdapter(palette.getSwatches());
rvPalette.setAdapter(paletteAdapter);
}
use of android.support.v7.graphics.Palette 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)));
}
});
}
}
use of android.support.v7.graphics.Palette in project kickmaterial by byoutline.
the class ProjectDetailsActivity method loadProjectPhoto.
private void loadProjectPhoto() {
Bitmap bitmap = picassoCache.getPlaceholder(project.getBigPhotoUrl());
boolean bigPhotoMustBeFetched = bitmap == null;
if (bigPhotoMustBeFetched) {
bitmap = picassoCache.getPlaceholder(project.getPhotoUrl());
boolean placeholderAlreadyFetched = bitmap != null;
if (placeholderAlreadyFetched) {
binding.projectPhotoIv.setImageBitmap(bitmap);
}
}
// Make sure that transition starts soon even if image is not ready.
binding.projectPhotoIv.postDelayed(this::supportStartPostponedEnterTransition, MAX_TRANSITION_DELAY);
Picasso.with(this).load(project.getBigPhotoUrl()).resize(imageWidth, imageHeight).onlyScaleDown().centerCrop().transform(PaletteAndAplaTransformation.instance()).into(binding.projectPhotoIv, new Callback() {
@Override
public void onSuccess() {
// Ew!
Bitmap bitmap = ((BitmapDrawable) binding.projectPhotoIv.getDrawable()).getBitmap();
Palette palette = PaletteAndAplaTransformation.getPalette(bitmap);
binding.detailsContainer.setBackgroundColor(palette.getDarkVibrantColor(Color.BLACK));
supportStartPostponedEnterTransition();
}
@Override
public void onError() {
supportStartPostponedEnterTransition();
}
});
}
use of android.support.v7.graphics.Palette in project ListenerMusicPlayer by hefuyicoder.
the class PlaylistAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(final ItemHolder itemHolder, final int i) {
final Playlist localItem = arraylist.get(i);
itemHolder.title.setText(localItem.name);
itemHolder.songcount.setText(ListenerUtil.makeLabel(mContext, R.plurals.Nsongs, localItem.songCount));
itemHolder.subtitle1.setVisibility(View.GONE);
itemHolder.divider.setVisibility(View.GONE);
PlaylistSongLoader.getSongsInPlaylist(mContext, localItem.id).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<List<Song>>() {
@Override
public void call(List<Song> playlistsongs) {
String uri = "";
long firstAlbumID = -1;
if (playlistsongs.size() != 0) {
firstAlbumID = playlistsongs.get(0).albumId;
uri = ListenerUtil.getAlbumArtUri(firstAlbumID).toString();
}
itemHolder.playlistArt.setTag(R.string.playlistArt, firstAlbumID);
Glide.with(itemHolder.itemView.getContext()).load(uri).asBitmap().placeholder(ATEUtil.getDefaultAlbumDrawable(mContext)).into(new SimpleTarget<Bitmap>() {
@Override
public void onLoadFailed(Exception e, Drawable errorDrawable) {
if (isGrid) {
itemHolder.footer.setBackgroundColor(ATEUtil.getThemeAlbumDefaultPaletteColor(mContext));
}
itemHolder.playlistArt.setImageDrawable(ATEUtil.getDefaultAlbumDrawable(mContext));
itemHolder.title.setTextColor(ATEUtil.getThemeTextColorPrimary(mContext));
itemHolder.songcount.setTextColor(ATEUtil.getThemeTextColorSecondly(mContext));
itemHolder.popupMenu.setColorFilter(mContext.getResources().getColor(R.color.background_floating_material_dark));
}
@Override
public void onResourceReady(final Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
if (isGrid) {
new Palette.Builder(resource).generate(new Palette.PaletteAsyncListener() {
@Override
public void onGenerated(Palette palette) {
Palette.Swatch swatch = ColorUtil.getMostPopulousSwatch(palette);
if (swatch != null) {
int color = swatch.getRgb();
itemHolder.footer.setBackgroundColor(color);
int detailColor = swatch.getTitleTextColor();
itemHolder.playlistArt.setImageBitmap(resource);
itemHolder.title.setTextColor(ColorUtil.getOpaqueColor(detailColor));
itemHolder.songcount.setTextColor(detailColor);
itemHolder.popupMenu.setColorFilter(detailColor);
}
}
});
} else {
itemHolder.playlistArt.setImageBitmap(resource);
}
}
});
}
});
if (ListenerUtil.isLollipop())
itemHolder.playlistArt.setTransitionName("transition_album_art" + i);
setOnPopupMenuListener(itemHolder, i);
}
Aggregations