mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-25 22:18: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 android.widget.TextView;
|
||||||
|
|
||||||
import com.bumptech.glide.Glide;
|
import com.bumptech.glide.Glide;
|
||||||
|
import com.bumptech.glide.load.engine.DiskCacheStrategy;
|
||||||
import com.simplemobiletools.gallery.R;
|
import com.simplemobiletools.gallery.R;
|
||||||
import com.simplemobiletools.gallery.models.Directory;
|
import com.simplemobiletools.gallery.models.Directory;
|
||||||
|
|
||||||
|
@ -42,8 +43,13 @@ public class DirectoryAdapter extends BaseAdapter {
|
||||||
final Directory dir = mDirs.get(position);
|
final Directory dir = mDirs.get(position);
|
||||||
viewHolder.dirName.setText(dir.getName());
|
viewHolder.dirName.setText(dir.getName());
|
||||||
viewHolder.photoCnt.setText(String.valueOf(dir.getMediaCnt()));
|
viewHolder.photoCnt.setText(String.valueOf(dir.getMediaCnt()));
|
||||||
Glide.with(mContext).load(dir.getThumbnail()).placeholder(R.color.tmb_background).centerCrop().crossFade()
|
final String tmb = dir.getThumbnail();
|
||||||
.into(viewHolder.dirThumbnail);
|
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;
|
return convertView;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import android.widget.BaseAdapter;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
|
||||||
import com.bumptech.glide.Glide;
|
import com.bumptech.glide.Glide;
|
||||||
|
import com.bumptech.glide.load.engine.DiskCacheStrategy;
|
||||||
import com.simplemobiletools.gallery.R;
|
import com.simplemobiletools.gallery.R;
|
||||||
import com.simplemobiletools.gallery.models.Medium;
|
import com.simplemobiletools.gallery.models.Medium;
|
||||||
|
|
||||||
|
@ -46,7 +47,11 @@ public class MediaAdapter extends BaseAdapter {
|
||||||
}
|
}
|
||||||
|
|
||||||
final String path = medium.getPath();
|
final String path = medium.getPath();
|
||||||
Glide.with(mContext).load(path).placeholder(R.color.tmb_background).centerCrop().crossFade().into(viewHolder.photoThumbnail);
|
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;
|
return convertView;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
import com.bumptech.glide.Glide;
|
import com.bumptech.glide.Glide;
|
||||||
|
import com.bumptech.glide.load.engine.DiskCacheStrategy;
|
||||||
import com.bumptech.glide.request.animation.ViewPropertyAnimation;
|
import com.bumptech.glide.request.animation.ViewPropertyAnimation;
|
||||||
import com.simplemobiletools.gallery.Constants;
|
import com.simplemobiletools.gallery.Constants;
|
||||||
import com.simplemobiletools.gallery.R;
|
import com.simplemobiletools.gallery.R;
|
||||||
|
@ -26,7 +27,11 @@ public class PhotoFragment extends ViewPagerFragment implements PhotoViewAttache
|
||||||
return view;
|
return view;
|
||||||
|
|
||||||
final PhotoView photoView = (PhotoView) view.findViewById(R.id.photo_view);
|
final PhotoView photoView = (PhotoView) view.findViewById(R.id.photo_view);
|
||||||
Glide.with(getContext()).load(medium.getPath()).asBitmap().thumbnail(0.2f).animate(fadeInAnimator).into(photoView);
|
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);
|
new PhotoViewAttacher(photoView).setOnPhotoTapListener(this);
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
|
|
|
@ -26,6 +26,10 @@ public class Medium implements Serializable, Comparable {
|
||||||
return timestamp;
|
return timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isGif() {
|
||||||
|
return getPath().endsWith(".gif");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(Object object) {
|
public int compareTo(Object object) {
|
||||||
final Medium medium = (Medium) object;
|
final Medium medium = (Medium) object;
|
||||||
|
|
Loading…
Reference in a new issue