remove Subsampling scale image view, its not worth it

This commit is contained in:
tibbi 2017-03-16 19:11:51 +01:00
parent 875c7ed190
commit 9d88f7bf7d
4 changed files with 17 additions and 91 deletions

View file

@ -33,7 +33,6 @@ android {
dependencies { dependencies {
compile 'com.simplemobiletools:commons:2.11.4' compile 'com.simplemobiletools:commons:2.11.4'
compile 'com.davemorrissey.labs:subsampling-scale-image-view:3.6.0'
compile 'com.theartofdev.edmodo:android-image-cropper:2.3.1' compile 'com.theartofdev.edmodo:android-image-cropper:2.3.1'
compile 'com.bignerdranch.android:recyclerview-multiselect:0.2' compile 'com.bignerdranch.android:recyclerview-multiselect:0.2'
compile 'com.google.code.gson:gson:2.8.0' compile 'com.google.code.gson:gson:2.8.0'

View file

@ -133,8 +133,8 @@ fun Activity.hasNavBar(): Boolean {
} }
fun SimpleActivity.launchAbout() { fun SimpleActivity.launchAbout() {
startAboutActivity(R.string.app_name, LICENSE_KOTLIN or LICENSE_SUBSAMPLING or LICENSE_GLIDE or LICENSE_CROPPER or startAboutActivity(R.string.app_name, LICENSE_KOTLIN or LICENSE_GLIDE or LICENSE_CROPPER or LICENSE_MULTISELECT or LICENSE_RTL
LICENSE_MULTISELECT or LICENSE_RTL or LICENSE_PHOTOVIEW, BuildConfig.VERSION_NAME) or LICENSE_PHOTOVIEW, BuildConfig.VERSION_NAME)
} }
fun AppCompatActivity.showSystemUI() { fun AppCompatActivity.showSystemUI() {

View file

@ -13,12 +13,6 @@ import com.bumptech.glide.Glide
import com.bumptech.glide.Priority import com.bumptech.glide.Priority
import com.bumptech.glide.load.DecodeFormat import com.bumptech.glide.load.DecodeFormat
import com.bumptech.glide.load.engine.DiskCacheStrategy import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.bumptech.glide.request.RequestListener
import com.bumptech.glide.request.target.Target
import com.davemorrissey.labs.subscaleview.ImageSource
import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
import com.simplemobiletools.commons.extensions.beGone
import com.simplemobiletools.commons.extensions.beVisible
import com.simplemobiletools.commons.extensions.toast import com.simplemobiletools.commons.extensions.toast
import com.simplemobiletools.gallery.R import com.simplemobiletools.gallery.R
import com.simplemobiletools.gallery.extensions.getRealPathFromURI import com.simplemobiletools.gallery.extensions.getRealPathFromURI
@ -26,8 +20,6 @@ import com.simplemobiletools.gallery.helpers.GlideRotateTransformation
import com.simplemobiletools.gallery.helpers.MEDIUM import com.simplemobiletools.gallery.helpers.MEDIUM
import com.simplemobiletools.gallery.models.Medium import com.simplemobiletools.gallery.models.Medium
import it.sephiroth.android.library.exif2.ExifInterface import it.sephiroth.android.library.exif2.ExifInterface
import kotlinx.android.synthetic.main.pager_photo_item.*
import kotlinx.android.synthetic.main.pager_photo_item.view.*
import uk.co.senab.photoview.PhotoView import uk.co.senab.photoview.PhotoView
import uk.co.senab.photoview.PhotoViewAttacher import uk.co.senab.photoview.PhotoViewAttacher
import java.io.File import java.io.File
@ -36,12 +28,11 @@ import java.io.IOException
class PhotoFragment : ViewPagerFragment() { class PhotoFragment : ViewPagerFragment() {
lateinit var medium: Medium lateinit var medium: Medium
lateinit var subsamplingView: SubsamplingScaleImageView lateinit var view: PhotoView
lateinit var glideView: PhotoView
private var isFragmentVisible = false private var isFragmentVisible = false
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
val view = inflater.inflate(R.layout.pager_photo_item, container, false) view = inflater.inflate(R.layout.pager_photo_item, container, false) as PhotoView
medium = arguments.getSerializable(MEDIUM) as Medium medium = arguments.getSerializable(MEDIUM) as Medium
@ -80,9 +71,7 @@ class PhotoFragment : ViewPagerFragment() {
} }
} }
subsamplingView = view.subsampling_view.apply { setOnClickListener({ photoClicked() }) } view.setOnPhotoTapListener(object : PhotoViewAttacher.OnPhotoTapListener {
glideView = view.photo_view.apply {
setOnPhotoTapListener(object : PhotoViewAttacher.OnPhotoTapListener {
override fun onPhotoTap(view: View?, x: Float, y: Float) { override fun onPhotoTap(view: View?, x: Float, y: Float) {
photoClicked() photoClicked()
} }
@ -91,7 +80,6 @@ class PhotoFragment : ViewPagerFragment() {
photoClicked() photoClicked()
} }
}) })
}
loadImage() loadImage()
activity.window.decorView.setOnSystemUiVisibilityChangeListener { visibility -> activity.window.decorView.setOnSystemUiVisibilityChangeListener { visibility ->
@ -133,7 +121,7 @@ class PhotoFragment : ViewPagerFragment() {
.asGif() .asGif()
.diskCacheStrategy(DiskCacheStrategy.NONE) .diskCacheStrategy(DiskCacheStrategy.NONE)
.priority(if (isFragmentVisible) Priority.IMMEDIATE else Priority.NORMAL) .priority(if (isFragmentVisible) Priority.IMMEDIATE else Priority.NORMAL)
.into(glideView) .into(view)
} else { } else {
loadBitmap() loadBitmap()
} }
@ -148,61 +136,13 @@ class PhotoFragment : ViewPagerFragment() {
.priority(if (isFragmentVisible) Priority.IMMEDIATE else Priority.NORMAL) .priority(if (isFragmentVisible) Priority.IMMEDIATE else Priority.NORMAL)
.thumbnail(0.3f) .thumbnail(0.3f)
.diskCacheStrategy(DiskCacheStrategy.NONE) .diskCacheStrategy(DiskCacheStrategy.NONE)
.listener(object : RequestListener<String, Bitmap> { .into(view)
override fun onException(e: Exception?, model: String?, target: Target<Bitmap>?, isFirstResource: Boolean): Boolean {
return false
}
override fun onResourceReady(bitmap: Bitmap, model: String?, target: Target<Bitmap>?, isFromMemoryCache: Boolean, isFirstResource: Boolean): Boolean {
if (degrees == 0f) {
addZoomableView()
} else {
photo_view.beVisible()
subsampling_view.beGone()
}
return false
}
}).into(glideView)
} }
fun rotateImageViewBy(degrees: Float) { fun rotateImageViewBy(degrees: Float) {
loadBitmap(degrees) loadBitmap(degrees)
} }
private fun addZoomableView() {
if (!medium.isPng()) {
subsamplingView.apply {
beVisible()
setDoubleTapZoomScale(1.4f)
setImage(ImageSource.uri(medium.path))
orientation = SubsamplingScaleImageView.ORIENTATION_USE_EXIF
maxScale = 5f
setOnImageEventListener(object : SubsamplingScaleImageView.OnImageEventListener {
override fun onImageLoaded() {
}
override fun onReady() {
glideView.beGone()
glideView.setImageBitmap(null)
}
override fun onTileLoadError(p0: Exception?) {
}
override fun onPreviewReleased() {
}
override fun onImageLoadError(p0: Exception?) {
beGone()
}
override fun onPreviewLoadError(p0: Exception?) {
}
})
}
}
}
override fun onConfigurationChanged(newConfig: Configuration?) { override fun onConfigurationChanged(newConfig: Configuration?) {
super.onConfigurationChanged(newConfig) super.onConfigurationChanged(newConfig)
loadImage() loadImage()

View file

@ -1,19 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout <uk.co.senab.photoview.PhotoView
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/photo_holder"
android:layout_width="match_parent"
android:layout_height="match_parent">
<uk.co.senab.photoview.PhotoView
android:id="@+id/photo_view" android:id="@+id/photo_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"/> android:layout_height="match_parent"/>
<com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
android:id="@+id/subsampling_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"/>
</RelativeLayout>