Skip to content

Commit

Permalink
Merge pull request #23 from nikiizvorski/master
Browse files Browse the repository at this point in the history
Update to glide 4.1
  • Loading branch information
mzelzoghbi authored Nov 13, 2018
2 parents bf300da + 3e941e1 commit 0b9a7ea
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 21 deletions.
15 changes: 1 addition & 14 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
buildscript {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
Expand All @@ -16,6 +20,10 @@ allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion zgallery/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ dependencies {
compile ("com.android.support:support-v4:$rootProject.ext.supportLibVersion") {
ext.optional = true
}
compile("com.github.bumptech.glide:glide:$rootProject.ext.glideVersion") { ext.optional = true }
compile 'com.github.bumptech.glide:glide:4.3.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.3.1'
compile("com.android.support:recyclerview-v7:$rootProject.ext.supportLibVersion") {
ext.optional = true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import android.view.ViewGroup;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.mzelzoghbi.zgallery.ImageViewHolder;
import com.mzelzoghbi.zgallery.R;
import com.mzelzoghbi.zgallery.adapters.listeners.GridClickListener;
Expand Down Expand Up @@ -36,8 +37,9 @@ public ImageViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {

@Override
public void onBindViewHolder(ImageViewHolder holder, final int position) {
RequestOptions requestOptions = new RequestOptions().placeholder(imgPlaceHolderResId != -1 ? imgPlaceHolderResId : R.drawable.placeholder);
Glide.with(mActivity).load(imageURLs.get(position))
.placeholder(imgPlaceHolderResId != -1 ? imgPlaceHolderResId : R.drawable.placeholder)
.apply(requestOptions)
.into(holder.image);

holder.itemView.setOnClickListener(new View.OnClickListener() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import android.app.Activity;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.support.annotation.Nullable;
import android.support.v4.view.PagerAdapter;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
Expand All @@ -14,7 +16,8 @@
import android.widget.RelativeLayout;

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.target.Target;
import com.mzelzoghbi.zgallery.R;
Expand Down Expand Up @@ -59,14 +62,14 @@ public Object instantiateItem(ViewGroup container, int position) {
View itemView = mLayoutInflater.inflate(R.layout.z_pager_item, container, false);

final ImageView imageView = (ImageView) itemView.findViewById(R.id.iv);
Glide.with(activity).load(images.get(position)).listener(new RequestListener<String, GlideDrawable>() {
Glide.with(activity).load(images.get(position)).listener(new RequestListener<Drawable>() {
@Override
public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
return false;
}

@Override
public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
mPhotoViewAttacher = new PhotoViewAttacher(imageView);

mPhotoViewAttacher.setOnPhotoTapListener(new PhotoViewAttacher.OnPhotoTapListener() {
Expand All @@ -89,8 +92,10 @@ public void onOutsidePhotoTap() {
}
});


return false;
}

}).into(imageView);

container.addView(itemView);
Expand Down

0 comments on commit 0b9a7ea

Please sign in to comment.