Skip to content

Commit

Permalink
Merge pull request #22 from andremion/development
Browse files Browse the repository at this point in the history
Update master
  • Loading branch information
andremion authored Nov 16, 2017
2 parents 6db413b + 196b549 commit 3d12411
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 26 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]'
}
```

Expand Down
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
}

Expand All @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
}

Expand All @@ -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);
}

Expand All @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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<Uri> 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) {
Expand Down Expand Up @@ -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<Uri, GlideDrawable> {
private class ImageLoadingCallback implements RequestListener<Drawable> {

final int mPosition;

Expand All @@ -236,13 +241,13 @@ private class ImageLoadingCallback implements RequestListener<Uri, GlideDrawable
}

@Override
public boolean onResourceReady(GlideDrawable resource, Uri model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
startPostponedEnterTransition(mPosition);
return false;
}

@Override
public boolean onException(Exception e, Uri model, Target<GlideDrawable> target, boolean isFirstResource) {
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
startPostponedEnterTransition(mPosition);
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}

Expand Down

0 comments on commit 3d12411

Please sign in to comment.