diff --git a/README.md b/README.md index 9c68b69..81c526e 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ Then, add the library in your app module `build.gradle` ```groovy dependencies{ - compile 'com.github.andremion:louvre:1.2.0' + compile 'com.github.andremion:louvre:[LATEST VERSION]' } ``` diff --git a/build.gradle b/build.gradle index 58ca04f..dd0ce1f 100644 --- a/build.gradle +++ b/build.gradle @@ -7,7 +7,7 @@ buildscript { } dependencies { classpath 'com.android.tools.build:gradle:3.0.0' - classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1' + classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0' } } @@ -28,12 +28,12 @@ allprojects { minSdkVersion = 16 targetSdkVersion = 26 - versionCode = 8 - versionName = "1.2.1" + versionCode = 9 + versionName = "1.2.3" supportLibraryVersion = '26.1.0' counterFabVersion = '1.0.2' - glideVersion = '3.8.0' + glideVersion = '4.3.1' photoViewVersion = '2.0.0' junitVersion = '4.12' diff --git a/louvre/src/main/java/com/andremion/louvre/home/GalleryAdapter.java b/louvre/src/main/java/com/andremion/louvre/home/GalleryAdapter.java index 5022160..46867f9 100644 --- a/louvre/src/main/java/com/andremion/louvre/home/GalleryAdapter.java +++ b/louvre/src/main/java/com/andremion/louvre/home/GalleryAdapter.java @@ -36,6 +36,7 @@ import com.andremion.louvre.R; import com.andremion.louvre.util.AnimationHelper; import com.bumptech.glide.Glide; +import com.bumptech.glide.request.RequestOptions; import java.io.File; import java.lang.annotation.Retention; @@ -158,9 +159,9 @@ public void onBindViewHolder(@NonNull GalleryAdapter.ViewHolder holder, int posi ViewCompat.setTransitionName(holder.mImageView, imageTransitionName); Glide.with(holder.mImageView.getContext()) .load(data) - .skipMemoryCache(true) - .centerCrop() - .placeholder(R.color.gallery_item_background) + .apply(RequestOptions.skipMemoryCacheOf(true) + .centerCrop() + .placeholder(R.color.gallery_item_background)) .into(holder.mImageView); boolean selected = isSelected(position); @@ -295,7 +296,7 @@ abstract class ViewHolder extends RecyclerView.ViewHolder { private ViewHolder(View itemView) { super(itemView); - mImageView = (ImageView) itemView.findViewById(R.id.image); + mImageView = itemView.findViewById(R.id.image); } } @@ -305,7 +306,7 @@ private class BucketViewHolder extends ViewHolder implements View.OnClickListene private BucketViewHolder(View itemView) { super(itemView); - mTextView = (TextView) itemView.findViewById(R.id.text); + mTextView = itemView.findViewById(R.id.text); itemView.setOnClickListener(this); } @@ -332,7 +333,7 @@ class MediaViewHolder extends ViewHolder implements View.OnClickListener { private MediaViewHolder(View itemView) { super(itemView); - mCheckView = (CheckedTextView) itemView.findViewById(R.id.check); + mCheckView = itemView.findViewById(R.id.check); mCheckView.setOnClickListener(this); itemView.setOnClickListener(this); } diff --git a/louvre/src/main/java/com/andremion/louvre/preview/PreviewAdapter.java b/louvre/src/main/java/com/andremion/louvre/preview/PreviewAdapter.java index 9d07bc0..57458c5 100644 --- a/louvre/src/main/java/com/andremion/louvre/preview/PreviewAdapter.java +++ b/louvre/src/main/java/com/andremion/louvre/preview/PreviewAdapter.java @@ -17,6 +17,7 @@ package com.andremion.louvre.preview; import android.database.Cursor; +import android.graphics.drawable.Drawable; import android.net.Uri; import android.provider.MediaStore; import android.support.annotation.IntRange; @@ -34,10 +35,11 @@ import com.andremion.louvre.R; import com.andremion.louvre.util.transition.MediaSharedElementCallback; -import com.bumptech.glide.DrawableRequestBuilder; import com.bumptech.glide.Glide; -import com.bumptech.glide.load.resource.drawable.GlideDrawable; +import com.bumptech.glide.load.DataSource; +import com.bumptech.glide.load.engine.GlideException; import com.bumptech.glide.request.RequestListener; +import com.bumptech.glide.request.RequestOptions; import com.bumptech.glide.request.target.Target; import java.io.File; @@ -139,15 +141,18 @@ private long getItemId(int position) { private void onViewBound(ViewHolder holder, int position, Uri data) { String imageTransitionName = holder.imageView.getContext().getString(R.string.activity_gallery_image_transition, data.toString()); ViewCompat.setTransitionName(holder.imageView, imageTransitionName); - DrawableRequestBuilder request = Glide.with(mActivity) - .load(data) + + RequestOptions options = new RequestOptions() .skipMemoryCache(true) - .fitCenter() - .listener(new ImageLoadingCallback(position)); + .fitCenter(); if (mDontAnimate) { - request.dontAnimate(); + options.dontAnimate(); } - request.into(holder.imageView); + Glide.with(mActivity) + .load(data) + .apply(options) + .listener(new ImageLoadingCallback(position)) + .into(holder.imageView); } private boolean isSelected(int position) { @@ -222,12 +227,12 @@ private static class ViewHolder { ViewHolder(View view) { itemView = view; - imageView = (ImageView) view.findViewById(R.id.image); + imageView = view.findViewById(R.id.image); } } - private class ImageLoadingCallback implements RequestListener { + private class ImageLoadingCallback implements RequestListener { final int mPosition; @@ -236,13 +241,13 @@ private class ImageLoadingCallback implements RequestListener target, boolean isFromMemoryCache, boolean isFirstResource) { + public boolean onResourceReady(Drawable resource, Object model, Target target, DataSource dataSource, boolean isFirstResource) { startPostponedEnterTransition(mPosition); return false; } @Override - public boolean onException(Exception e, Uri model, Target target, boolean isFirstResource) { + public boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) { startPostponedEnterTransition(mPosition); return false; } diff --git a/sample/src/main/java/com/andremion/louvre/sample/MainAdapter.java b/sample/src/main/java/com/andremion/louvre/sample/MainAdapter.java index 07f3ae5..4084e7f 100644 --- a/sample/src/main/java/com/andremion/louvre/sample/MainAdapter.java +++ b/sample/src/main/java/com/andremion/louvre/sample/MainAdapter.java @@ -25,6 +25,7 @@ import android.widget.ImageView; import com.bumptech.glide.Glide; +import com.bumptech.glide.request.RequestOptions; import java.util.ArrayList; import java.util.List; @@ -49,9 +50,9 @@ public void onBindViewHolder(ViewHolder holder, int position) { Uri data = mData.get(position); Glide.with(holder.mImageView.getContext()) .load(data) - .skipMemoryCache(true) - .centerCrop() - .placeholder(R.color.gallery_item_background) + .apply(RequestOptions.skipMemoryCacheOf(true) + .centerCrop() + .placeholder(com.andremion.louvre.R.color.gallery_item_background)) .into(holder.mImageView); }