use of com.bumptech.glide.request.animation.GlideAnimation in project MovieGuide by esoxjem.
the class MoviesListingAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(final ViewHolder holder, int position) {
holder.itemView.setOnClickListener(holder);
holder.movie = movies.get(position);
holder.name.setText(holder.movie.getTitle());
Glide.with(context).load(holder.movie.getPosterPath()).asBitmap().diskCacheStrategy(DiskCacheStrategy.RESULT).into(new BitmapImageViewTarget(holder.poster) {
@Override
public void onResourceReady(Bitmap bitmap, GlideAnimation anim) {
super.onResourceReady(bitmap, anim);
Palette.from(bitmap).generate(new Palette.PaletteAsyncListener() {
@Override
public void onGenerated(Palette palette) {
holder.titleBackground.setBackgroundColor(palette.getVibrantColor(context.getResources().getColor(R.color.black_translucent_60)));
}
});
}
});
}
use of com.bumptech.glide.request.animation.GlideAnimation 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);
}
use of com.bumptech.glide.request.animation.GlideAnimation in project xabber-android by redsolution.
the class AccountInfoEditorFragment method preprocessAndStartCrop.
private void preprocessAndStartCrop(Uri source) {
enableProgressMode(getString(R.string.processing_image));
Glide.with(this).load(source).asBitmap().toBytes().override(MAX_IMAGE_SIZE, MAX_IMAGE_SIZE).into(new SimpleTarget<byte[]>() {
@Override
public void onResourceReady(final byte[] data, GlideAnimation anim) {
Application.getInstance().runInBackground(new Runnable() {
@Override
public void run() {
final Uri rotatedImage = FileManager.saveImage(data, ROTATE_FILE_NAME);
if (rotatedImage == null)
return;
Application.getInstance().runOnUiThread(new Runnable() {
@Override
public void run() {
startImageCropActivity(rotatedImage);
disableProgressMode();
}
});
}
});
}
@Override
public void onLoadFailed(Exception e, Drawable errorDrawable) {
super.onLoadFailed(e, errorDrawable);
disableProgressMode();
Toast.makeText(getActivity(), R.string.error_during_image_processing, Toast.LENGTH_SHORT).show();
}
});
}
use of com.bumptech.glide.request.animation.GlideAnimation in project Shuttle by timusus.
the class MusicService method buildNotification.
private Notification buildNotification() {
final boolean isPlaying = isPlaying();
if (mNotification == null) {
Intent intent = new Intent(BuildConfig.APPLICATION_ID + (ShuttleUtils.isTablet() ? ".TABLET_PLAYBACK_VIEWER" : ".PLAYBACK_VIEWER"));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent contentIntent = PendingIntent.getActivity(MusicService.this, 0, intent, 0);
Notification.Builder builder = new Notification.Builder(this);
builder.setSmallIcon(R.drawable.ic_stat_notification).setContentIntent(contentIntent).setPriority(Notification.PRIORITY_MAX);
if (ShuttleUtils.hasJellyBeanMR1()) {
builder.setShowWhen(false);
}
if (ShuttleUtils.hasLollipop()) {
builder.setVisibility(Notification.VISIBILITY_PUBLIC);
}
if (ShuttleUtils.hasNougat()) {
builder.setStyle(new Notification.DecoratedCustomViewStyle());
}
mNotification = builder.build();
}
boolean invertIconsAndText = SettingsManager.getInstance().invertNotificationIcons() && ShuttleUtils.hasLollipop();
int baseLayoutResId = invertIconsAndText ? R.layout.notification_template_base_inverse : R.layout.notification_template_base;
int baseBigLayoutResId = invertIconsAndText ? R.layout.notification_template_big_base_inverse : R.layout.notification_template_big_base;
if (ShuttleUtils.hasNougat()) {
baseLayoutResId = invertIconsAndText ? R.layout.notification_template_base_v24_inverse : R.layout.notification_template_base_v24;
baseBigLayoutResId = invertIconsAndText ? R.layout.notification_template_big_base_v24_inverse : R.layout.notification_template_big_base_v24;
}
RemoteViews contentView = new RemoteViews(getPackageName(), baseLayoutResId);
RemoteViews bigContentView = new RemoteViews(getPackageName(), baseBigLayoutResId);
String artistName = getArtistName();
String albumName = getAlbumName();
String trackName = getSongName();
if (artistName != null && albumName != null) {
contentView.setTextViewText(R.id.text, String.format("%s | %s", artistName, albumName));
bigContentView.setTextViewText(R.id.text, String.format("%s | %s", artistName, albumName));
}
if (trackName != null) {
contentView.setTextViewText(R.id.title, trackName);
bigContentView.setTextViewText(R.id.title, trackName);
}
contentView.setImageViewBitmap(R.id.pause, DrawableUtils.getTintedNotificationDrawable(this, R.drawable.ic_pause_white));
contentView.setImageViewBitmap(R.id.next, DrawableUtils.getTintedNotificationDrawable(this, R.drawable.ic_skip_white));
contentView.setImageViewBitmap(R.id.prev, DrawableUtils.getTintedNotificationDrawable(this, R.drawable.ic_prev_white));
bigContentView.setImageViewBitmap(R.id.pause, DrawableUtils.getTintedNotificationDrawable(this, R.drawable.ic_pause_white));
bigContentView.setImageViewBitmap(R.id.next, DrawableUtils.getTintedNotificationDrawable(this, R.drawable.ic_skip_white));
bigContentView.setImageViewBitmap(R.id.prev, DrawableUtils.getTintedNotificationDrawable(this, R.drawable.ic_prev_white));
PendingIntent pendingIntent = retrievePlaybackAction(ServiceCommand.PREV_ACTION);
bigContentView.setOnClickPendingIntent(R.id.prev, pendingIntent);
pendingIntent = retrievePlaybackAction(ServiceCommand.TOGGLE_PAUSE_ACTION);
contentView.setOnClickPendingIntent(R.id.pause, pendingIntent);
bigContentView.setOnClickPendingIntent(R.id.pause, pendingIntent);
pendingIntent = retrievePlaybackAction(ServiceCommand.NEXT_ACTION);
contentView.setOnClickPendingIntent(R.id.next, pendingIntent);
bigContentView.setOnClickPendingIntent(R.id.next, pendingIntent);
pendingIntent = retrievePlaybackAction(ServiceCommand.PREV_ACTION);
contentView.setOnClickPendingIntent(R.id.prev, pendingIntent);
bigContentView.setOnClickPendingIntent(R.id.prev, pendingIntent);
pendingIntent = retrievePlaybackAction(ServiceCommand.STOP_ACTION);
contentView.setOnClickPendingIntent(R.id.close, pendingIntent);
bigContentView.setOnClickPendingIntent(R.id.close, pendingIntent);
doOnMainThread(() -> Glide.with(MusicService.this).load(getAlbum()).asBitmap().diskCacheStrategy(DiskCacheStrategy.ALL).override(600, 600).placeholder(GlideUtils.getPlaceHolderDrawable(albumName, false)).into(new SimpleTarget<Bitmap>() {
@Override
public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
if (resource != null) {
contentView.setImageViewBitmap(R.id.icon, resource);
bigContentView.setImageViewBitmap(R.id.icon, resource);
}
mNotificationManager.notify(NOTIFICATION_ID, mNotification);
}
@Override
public void onLoadFailed(Exception e, Drawable errorDrawable) {
super.onLoadFailed(e, errorDrawable);
contentView.setImageViewBitmap(R.id.icon, GlideUtils.drawableToBitmap(errorDrawable));
bigContentView.setImageViewBitmap(R.id.icon, GlideUtils.drawableToBitmap(errorDrawable));
mNotificationManager.notify(NOTIFICATION_ID, mNotification);
}
}));
mNotification.contentView = contentView;
try {
mNotification.bigContentView = bigContentView;
} catch (NoSuchFieldError ignored) {
}
if (ShuttleUtils.hasAndroidLPreview()) {
mNotification.contentView.setImageViewBitmap(R.id.pause, !isPlaying ? DrawableUtils.getTintedNotificationDrawable(this, R.drawable.ic_play_white) : DrawableUtils.getTintedNotificationDrawable(this, R.drawable.ic_pause_white));
} else {
mNotification.contentView.setImageViewResource(R.id.pause, !isPlaying ? R.drawable.ic_play_white : R.drawable.ic_pause_white);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
try {
if (mNotification.bigContentView != null) {
if (ShuttleUtils.hasAndroidLPreview()) {
mNotification.bigContentView.setImageViewBitmap(R.id.pause, !isPlaying ? DrawableUtils.getTintedNotificationDrawable(this, R.drawable.ic_play_white) : DrawableUtils.getTintedNotificationDrawable(this, R.drawable.ic_pause_white));
} else {
mNotification.bigContentView.setImageViewResource(R.id.pause, !isPlaying ? R.drawable.ic_play_white : R.drawable.ic_pause_white);
}
}
} catch (NoSuchFieldError ignored) {
}
}
return mNotification;
}
use of com.bumptech.glide.request.animation.GlideAnimation in project Notes by Elder-Wu.
the class GlideFragment method onCreateView.
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_glide, container, false);
ImageView imageView = (ImageView) rootView.findViewById(R.id.image);
Glide.with(getContext()).load("http://pic.qiantucdn.com/58pic/18/31/50/70T58PIC4Xi_1024.jpg").diskCacheStrategy(DiskCacheStrategy.NONE).skipMemoryCache(true).crossFade().into(imageView);
final ImageView imageView2 = (ImageView) rootView.findViewById(R.id.image2);
imageView2.postDelayed(new Runnable() {
@Override
public void run() {
Glide.with(getContext()).load((String) null).transform(new RoundTransform(getContext(), imageView2.getMeasuredWidth(), 10)).diskCacheStrategy(DiskCacheStrategy.NONE).skipMemoryCache(true).fallback(new ColorDrawable(Color.GREEN)).listener(new RequestListener<String, GlideDrawable>() {
@Override
public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
return false;
}
@Override
public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
Logger.d(model);
return false;
}
}).into(new SimpleTarget<GlideDrawable>() {
@Override
public void onResourceReady(final GlideDrawable resource, GlideAnimation<? super GlideDrawable> glideAnimation) {
Observable.timer(5, TimeUnit.SECONDS).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<Long>() {
@Override
public void call(Long aLong) {
imageView2.setImageDrawable(new ColorDrawable(Color.DKGRAY));
}
});
}
});
}
}, 2000);
return rootView;
}
Aggregations