mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-22 12:38:00 +01:00
improve GIF support
This commit is contained in:
parent
b3359d44d6
commit
569ce03f80
4 changed files with 24 additions and 4 deletions
|
@ -9,6 +9,7 @@ import android.widget.ImageView;
|
|||
import android.widget.TextView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.load.engine.DiskCacheStrategy;
|
||||
import com.simplemobiletools.gallery.R;
|
||||
import com.simplemobiletools.gallery.models.Directory;
|
||||
|
||||
|
@ -42,8 +43,13 @@ public class DirectoryAdapter extends BaseAdapter {
|
|||
final Directory dir = mDirs.get(position);
|
||||
viewHolder.dirName.setText(dir.getName());
|
||||
viewHolder.photoCnt.setText(String.valueOf(dir.getMediaCnt()));
|
||||
Glide.with(mContext).load(dir.getThumbnail()).placeholder(R.color.tmb_background).centerCrop().crossFade()
|
||||
.into(viewHolder.dirThumbnail);
|
||||
final String tmb = dir.getThumbnail();
|
||||
if (tmb.endsWith(".gif")) {
|
||||
Glide.with(mContext).load(tmb).asGif().diskCacheStrategy(DiskCacheStrategy.NONE).placeholder(R.color.tmb_background)
|
||||
.centerCrop().crossFade().into(viewHolder.dirThumbnail);
|
||||
} else {
|
||||
Glide.with(mContext).load(tmb).placeholder(R.color.tmb_background).centerCrop().crossFade().into(viewHolder.dirThumbnail);
|
||||
}
|
||||
|
||||
return convertView;
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import android.widget.BaseAdapter;
|
|||
import android.widget.ImageView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.load.engine.DiskCacheStrategy;
|
||||
import com.simplemobiletools.gallery.R;
|
||||
import com.simplemobiletools.gallery.models.Medium;
|
||||
|
||||
|
@ -46,7 +47,11 @@ public class MediaAdapter extends BaseAdapter {
|
|||
}
|
||||
|
||||
final String path = medium.getPath();
|
||||
if (medium.isGif()) {
|
||||
Glide.with(mContext).load(path).asGif().diskCacheStrategy(DiskCacheStrategy.NONE).into(viewHolder.photoThumbnail);
|
||||
} else {
|
||||
Glide.with(mContext).load(path).placeholder(R.color.tmb_background).centerCrop().crossFade().into(viewHolder.photoThumbnail);
|
||||
}
|
||||
|
||||
return convertView;
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import android.view.View;
|
|||
import android.view.ViewGroup;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.load.engine.DiskCacheStrategy;
|
||||
import com.bumptech.glide.request.animation.ViewPropertyAnimation;
|
||||
import com.simplemobiletools.gallery.Constants;
|
||||
import com.simplemobiletools.gallery.R;
|
||||
|
@ -26,7 +27,11 @@ public class PhotoFragment extends ViewPagerFragment implements PhotoViewAttache
|
|||
return view;
|
||||
|
||||
final PhotoView photoView = (PhotoView) view.findViewById(R.id.photo_view);
|
||||
if (medium.isGif()) {
|
||||
Glide.with(getContext()).load(medium.getPath()).asGif().diskCacheStrategy(DiskCacheStrategy.NONE).into(photoView);
|
||||
} else {
|
||||
Glide.with(getContext()).load(medium.getPath()).asBitmap().thumbnail(0.2f).animate(fadeInAnimator).into(photoView);
|
||||
}
|
||||
new PhotoViewAttacher(photoView).setOnPhotoTapListener(this);
|
||||
|
||||
return view;
|
||||
|
|
|
@ -26,6 +26,10 @@ public class Medium implements Serializable, Comparable {
|
|||
return timestamp;
|
||||
}
|
||||
|
||||
public boolean isGif() {
|
||||
return getPath().endsWith(".gif");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Object object) {
|
||||
final Medium medium = (Medium) object;
|
||||
|
|
Loading…
Reference in a new issue