Search in sources :

Example 1 with ParallaxImageView

use of us.koller.cameraroll.ui.widget.ParallaxImageView in project Camera-Roll-Android-App by kollerlukas.

the class AlbumHolder method loadImage.

void loadImage(final ImageView image) {
    if (album.getAlbumItems().size() == 0) {
        Glide.with(getContext()).load(R.drawable.error_placeholder).apply(new RequestOptions().skipMemoryCache(true)).into(image);
        return;
    }
    final AlbumItem coverImage = album.getAlbumItems().get(0);
    Glide.with(getContext()).asBitmap().load(coverImage.getPath()).listener(new RequestListener<Bitmap>() {

        @Override
        public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Bitmap> target, boolean isFirstResource) {
            coverImage.error = true;
            if (image instanceof ParallaxImageView) {
                ((ParallaxImageView) image).setParallaxTranslation();
            }
            return false;
        }

        @Override
        public boolean onResourceReady(Bitmap resource, Object model, Target<Bitmap> target, DataSource dataSource, boolean isFirstResource) {
            if (!coverImage.hasFadedIn) {
                coverImage.hasFadedIn = true;
                ColorFade.fadeSaturation(image);
            }
            if (image instanceof ParallaxImageView) {
                ((ParallaxImageView) image).setParallaxTranslation();
            }
            return false;
        }
    }).apply(coverImage.getGlideRequestOptions(getContext())).into(image);
}
Also used : Bitmap(android.graphics.Bitmap) RequestOptions(com.bumptech.glide.request.RequestOptions) ParallaxImageView(us.koller.cameraroll.ui.widget.ParallaxImageView) AlbumItem(us.koller.cameraroll.data.models.AlbumItem) GlideException(com.bumptech.glide.load.engine.GlideException) DataSource(com.bumptech.glide.load.DataSource)

Example 2 with ParallaxImageView

use of us.koller.cameraroll.ui.widget.ParallaxImageView in project Camera-Roll-Android-App by kollerlukas.

the class SimpleAlbumHolder method setAlbum.

@Override
public void setAlbum(Album album) {
    super.setAlbum(album);
    final ImageView image = itemView.findViewById(R.id.image);
    if (image instanceof ParallaxImageView) {
        ((ParallaxImageView) image).setParallaxTranslation();
    }
    loadImage(image);
}
Also used : ParallaxImageView(us.koller.cameraroll.ui.widget.ParallaxImageView) ParallaxImageView(us.koller.cameraroll.ui.widget.ParallaxImageView) ImageView(android.widget.ImageView)

Aggregations

ParallaxImageView (us.koller.cameraroll.ui.widget.ParallaxImageView)2 Bitmap (android.graphics.Bitmap)1 ImageView (android.widget.ImageView)1 DataSource (com.bumptech.glide.load.DataSource)1 GlideException (com.bumptech.glide.load.engine.GlideException)1 RequestOptions (com.bumptech.glide.request.RequestOptions)1 AlbumItem (us.koller.cameraroll.data.models.AlbumItem)1