add PhotoView for zoomable gifs and pngs

This commit is contained in:
tibbi 2017-01-07 11:41:31 +01:00
parent 3d104f3eac
commit b6fbe68643
3 changed files with 16 additions and 4 deletions

View file

@ -37,6 +37,7 @@ dependencies {
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'
compile 'com.github.chrisbanes:PhotoView:1.3.1'
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
} }

View file

@ -7,7 +7,6 @@ import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.ImageView
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
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
@ -20,11 +19,13 @@ import com.simplemobiletools.gallery.extensions.getRealPathFromURI
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 kotlinx.android.synthetic.main.pager_photo_item.view.* import kotlinx.android.synthetic.main.pager_photo_item.view.*
import uk.co.senab.photoview.PhotoView
import uk.co.senab.photoview.PhotoViewAttacher
class PhotoFragment : ViewPagerFragment() { class PhotoFragment : ViewPagerFragment() {
lateinit var medium: Medium lateinit var medium: Medium
lateinit var subsamplingView: SubsamplingScaleImageView lateinit var subsamplingView: SubsamplingScaleImageView
lateinit var glideView: ImageView lateinit var glideView: PhotoView
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) val view = inflater.inflate(R.layout.pager_photo_item, container, false)
@ -34,7 +35,17 @@ class PhotoFragment : ViewPagerFragment() {
medium.path = context.getRealPathFromURI(Uri.parse(medium.path)) ?: "" medium.path = context.getRealPathFromURI(Uri.parse(medium.path)) ?: ""
subsamplingView = view.photo_view.apply { setOnClickListener({ photoClicked() }) } subsamplingView = view.photo_view.apply { setOnClickListener({ photoClicked() }) }
glideView = view.glide_view.apply { setOnClickListener({ photoClicked() }) } glideView = view.glide_view.apply {
setOnPhotoTapListener(object : PhotoViewAttacher.OnPhotoTapListener {
override fun onPhotoTap(view: View?, x: Float, y: Float) {
photoClicked()
}
override fun onOutsidePhotoTap() {
photoClicked()
}
})
}
loadImage(medium) loadImage(medium)
activity.window.decorView.setOnSystemUiVisibilityChangeListener { visibility -> activity.window.decorView.setOnSystemUiVisibilityChangeListener { visibility ->

View file

@ -5,7 +5,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<ImageView <uk.co.senab.photoview.PhotoView
android:id="@+id/glide_view" android:id="@+id/glide_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"/> android:layout_height="match_parent"/>