Search in sources :

Example 1 with GlideAnimation

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)));
                }
            });
        }
    });
}
Also used : Palette(android.support.v7.graphics.Palette) Bitmap(android.graphics.Bitmap) BitmapImageViewTarget(com.bumptech.glide.request.target.BitmapImageViewTarget) GlideAnimation(com.bumptech.glide.request.animation.GlideAnimation)

Example 2 with GlideAnimation

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);
}
Also used : Palette(android.support.v7.graphics.Palette) Drawable(android.graphics.drawable.Drawable) GlideAnimation(com.bumptech.glide.request.animation.GlideAnimation) SimpleTarget(com.bumptech.glide.request.target.SimpleTarget) Playlist(io.hefuyi.listener.mvp.model.Playlist) Song(io.hefuyi.listener.mvp.model.Song) Bitmap(android.graphics.Bitmap) ArrayList(java.util.ArrayList) List(java.util.List)

Example 3 with GlideAnimation

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();
        }
    });
}
Also used : Drawable(android.graphics.drawable.Drawable) GlideAnimation(com.bumptech.glide.request.animation.GlideAnimation) Uri(android.net.Uri) SmackException(org.jivesoftware.smack.SmackException) ParseException(java.text.ParseException) XmlPullParserException(org.xmlpull.v1.XmlPullParserException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException)

Example 4 with GlideAnimation

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;
}
Also used : Drawable(android.graphics.drawable.Drawable) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) GlideAnimation(com.bumptech.glide.request.animation.GlideAnimation) Notification(android.app.Notification) SuppressLint(android.annotation.SuppressLint) SQLiteException(android.database.sqlite.SQLiteException) NoConnectionException(com.google.android.libraries.cast.companionlibrary.cast.exceptions.NoConnectionException) TransientNetworkDisconnectionException(com.google.android.libraries.cast.companionlibrary.cast.exceptions.TransientNetworkDisconnectionException) CastException(com.google.android.libraries.cast.companionlibrary.cast.exceptions.CastException) SimpleTarget(com.bumptech.glide.request.target.SimpleTarget) RemoteViews(android.widget.RemoteViews) Bitmap(android.graphics.Bitmap) PendingIntent(android.app.PendingIntent)

Example 5 with GlideAnimation

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;
}
Also used : GlideAnimation(com.bumptech.glide.request.animation.GlideAnimation) ImageView(android.widget.ImageView) View(android.view.View) SimpleTarget(com.bumptech.glide.request.target.SimpleTarget) ColorDrawable(android.graphics.drawable.ColorDrawable) ImageView(android.widget.ImageView) GlideDrawable(com.bumptech.glide.load.resource.drawable.GlideDrawable) Nullable(android.support.annotation.Nullable)

Aggregations

GlideAnimation (com.bumptech.glide.request.animation.GlideAnimation)5 Bitmap (android.graphics.Bitmap)3 Drawable (android.graphics.drawable.Drawable)3 SimpleTarget (com.bumptech.glide.request.target.SimpleTarget)3 Palette (android.support.v7.graphics.Palette)2 SuppressLint (android.annotation.SuppressLint)1 Notification (android.app.Notification)1 PendingIntent (android.app.PendingIntent)1 Intent (android.content.Intent)1 SQLiteException (android.database.sqlite.SQLiteException)1 ColorDrawable (android.graphics.drawable.ColorDrawable)1 Uri (android.net.Uri)1 Nullable (android.support.annotation.Nullable)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 RemoteViews (android.widget.RemoteViews)1 GlideDrawable (com.bumptech.glide.load.resource.drawable.GlideDrawable)1 BitmapImageViewTarget (com.bumptech.glide.request.target.BitmapImageViewTarget)1 CastException (com.google.android.libraries.cast.companionlibrary.cast.exceptions.CastException)1 NoConnectionException (com.google.android.libraries.cast.companionlibrary.cast.exceptions.NoConnectionException)1