diff --git a/app/build.gradle b/app/build.gradle index 61358e969..b8faa4951 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -33,7 +33,7 @@ dependencies { compile 'com.android.support:design:23.4.0' compile 'com.github.bumptech.glide:glide:3.7.0' compile 'com.jakewharton:butterknife:8.0.1' - compile 'com.github.chrisbanes:PhotoView:1.2.6' + compile 'com.davemorrissey.labs:subsampling-scale-image-view:3.5.0' apt 'com.jakewharton:butterknife-compiler:8.0.1' } diff --git a/app/src/main/java/com/simplemobiletools/gallery/fragments/PhotoFragment.java b/app/src/main/java/com/simplemobiletools/gallery/fragments/PhotoFragment.java index 132b45d82..2f98c7f05 100644 --- a/app/src/main/java/com/simplemobiletools/gallery/fragments/PhotoFragment.java +++ b/app/src/main/java/com/simplemobiletools/gallery/fragments/PhotoFragment.java @@ -1,22 +1,20 @@ package com.simplemobiletools.gallery.fragments; -import android.animation.ObjectAnimator; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.ImageView; import com.bumptech.glide.Glide; import com.bumptech.glide.load.engine.DiskCacheStrategy; -import com.bumptech.glide.request.animation.ViewPropertyAnimation; +import com.davemorrissey.labs.subscaleview.ImageSource; +import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView; import com.simplemobiletools.gallery.Constants; import com.simplemobiletools.gallery.R; import com.simplemobiletools.gallery.models.Medium; -import uk.co.senab.photoview.PhotoView; -import uk.co.senab.photoview.PhotoViewAttacher; - -public class PhotoFragment extends ViewPagerFragment implements PhotoViewAttacher.OnPhotoTapListener { +public class PhotoFragment extends ViewPagerFragment implements View.OnClickListener { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { @@ -26,27 +24,24 @@ public class PhotoFragment extends ViewPagerFragment implements PhotoViewAttache if (medium == null) return view; - final PhotoView photoView = (PhotoView) view.findViewById(R.id.photo_view); + final SubsamplingScaleImageView subsamplingView = (SubsamplingScaleImageView) view.findViewById(R.id.photo_view); if (medium.isGif()) { - Glide.with(getContext()).load(medium.getPath()).asGif().diskCacheStrategy(DiskCacheStrategy.NONE).into(photoView); + subsamplingView.setVisibility(View.GONE); + final ImageView imageView = (ImageView) view.findViewById(R.id.gif_view); + imageView.setVisibility(View.VISIBLE); + Glide.with(getContext()).load(medium.getPath()).asGif().diskCacheStrategy(DiskCacheStrategy.NONE).into(imageView); + imageView.setOnClickListener(this); } else { - Glide.with(getContext()).load(medium.getPath()).asBitmap().thumbnail(0.2f).animate(fadeInAnimator).into(photoView); + subsamplingView.setOrientation(SubsamplingScaleImageView.ORIENTATION_USE_EXIF); + subsamplingView.setImage(ImageSource.uri(medium.getPath())); + subsamplingView.setMaxScale(4f); + subsamplingView.setMinimumTileDpi(200); + subsamplingView.setOnClickListener(this); } - new PhotoViewAttacher(photoView).setOnPhotoTapListener(this); return view; } - ViewPropertyAnimation.Animator fadeInAnimator = new ViewPropertyAnimation.Animator() { - @Override - public void animate(View view) { - view.setAlpha(0f); - ObjectAnimator fadeAnim = ObjectAnimator.ofFloat(view, "alpha", 0f, 1f); - fadeAnim.setDuration(250); - fadeAnim.start(); - } - }; - @Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); @@ -63,12 +58,7 @@ public class PhotoFragment extends ViewPagerFragment implements PhotoViewAttache } @Override - public void onPhotoTap(View view, float v, float v1) { - photoClicked(); - } - - @Override - public void onOutsidePhotoTap() { + public void onClick(View v) { photoClicked(); } diff --git a/app/src/main/res/layout/pager_photo_item.xml b/app/src/main/res/layout/pager_photo_item.xml index 02d37b84f..9810a621f 100644 --- a/app/src/main/res/layout/pager_photo_item.xml +++ b/app/src/main/res/layout/pager_photo_item.xml @@ -1,6 +1,20 @@ - + android:layout_height="match_parent"> + + + + + +