use subsamplingScaleImageView for fullscreen images again
This commit is contained in:
parent
599f93b458
commit
7a3acad04b
6 changed files with 84 additions and 3 deletions
|
@ -33,6 +33,7 @@ android {
|
|||
|
||||
dependencies {
|
||||
compile 'com.simplemobiletools:commons:2.14.7'
|
||||
compile 'com.davemorrissey.labs:subsampling-scale-image-view:3.6.0'
|
||||
compile 'com.theartofdev.edmodo:android-image-cropper:2.3.1'
|
||||
compile 'com.bignerdranch.android:recyclerview-multiselect:0.2'
|
||||
compile 'com.google.code.gson:gson:2.8.0'
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.simplemobiletools.gallery.activities
|
|||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.content.pm.ActivityInfo
|
||||
import android.content.res.Configuration
|
||||
import android.database.Cursor
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.BitmapFactory
|
||||
|
@ -13,6 +14,7 @@ import android.os.Build
|
|||
import android.os.Bundle
|
||||
import android.provider.MediaStore
|
||||
import android.support.v4.view.ViewPager
|
||||
import android.util.DisplayMetrics
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
|
@ -50,6 +52,11 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
|||
private var mShowAll = false
|
||||
private var mRotationDegrees = 0f
|
||||
|
||||
companion object {
|
||||
var screenWidth = 0
|
||||
var screenHeight = 0
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_medium)
|
||||
|
@ -59,6 +66,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
|||
return
|
||||
}
|
||||
|
||||
measureScreen()
|
||||
val uri = intent.data
|
||||
if (uri != null) {
|
||||
var cursor: Cursor? = null
|
||||
|
@ -344,6 +352,18 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
|||
}
|
||||
}
|
||||
|
||||
override fun onConfigurationChanged(newConfig: Configuration?) {
|
||||
super.onConfigurationChanged(newConfig)
|
||||
measureScreen()
|
||||
}
|
||||
|
||||
private fun measureScreen() {
|
||||
val metrics = DisplayMetrics()
|
||||
windowManager.defaultDisplay.getMetrics(metrics)
|
||||
screenWidth = metrics.widthPixels
|
||||
screenHeight = metrics.heightPixels
|
||||
}
|
||||
|
||||
private fun reloadViewPager() {
|
||||
mCurrAsyncTask = GetMediaAsynctask(applicationContext, mDirectory, false, false, mShowAll) {
|
||||
mMedia = it
|
||||
|
|
|
@ -138,7 +138,7 @@ fun Activity.hasNavBar(): Boolean {
|
|||
|
||||
fun SimpleActivity.launchAbout() {
|
||||
startAboutActivity(R.string.app_name, LICENSE_KOTLIN or LICENSE_GLIDE or LICENSE_CROPPER or LICENSE_MULTISELECT or LICENSE_RTL
|
||||
or LICENSE_PHOTOVIEW, BuildConfig.VERSION_NAME)
|
||||
or LICENSE_PHOTOVIEW or LICENSE_SUBSAMPLING, BuildConfig.VERSION_NAME)
|
||||
}
|
||||
|
||||
fun AppCompatActivity.showSystemUI() {
|
||||
|
|
|
@ -13,8 +13,15 @@ import com.bumptech.glide.Glide
|
|||
import com.bumptech.glide.Priority
|
||||
import com.bumptech.glide.load.DecodeFormat
|
||||
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.gallery.R
|
||||
import com.simplemobiletools.gallery.activities.ViewPagerActivity
|
||||
import com.simplemobiletools.gallery.extensions.getRealPathFromURI
|
||||
import com.simplemobiletools.gallery.helpers.GlideRotateTransformation
|
||||
import com.simplemobiletools.gallery.helpers.MEDIUM
|
||||
|
@ -72,6 +79,7 @@ class PhotoFragment : ViewPagerFragment() {
|
|||
}
|
||||
}
|
||||
|
||||
view.subsampling_view.apply { setOnClickListener({ photoClicked() }) }
|
||||
view.photo_view.apply {
|
||||
maximumScale = 8f
|
||||
mediumScale = 3f
|
||||
|
@ -140,9 +148,18 @@ class PhotoFragment : ViewPagerFragment() {
|
|||
.load(medium.path)
|
||||
.asBitmap()
|
||||
.format(DecodeFormat.PREFER_ARGB_8888)
|
||||
.thumbnail(0.1f)
|
||||
.diskCacheStrategy(DiskCacheStrategy.NONE)
|
||||
.into(view.photo_view)
|
||||
.override(ViewPagerActivity.screenWidth, ViewPagerActivity.screenHeight)
|
||||
.listener(object : RequestListener<String, Bitmap> {
|
||||
override fun onException(e: java.lang.Exception?, model: String?, target: Target<Bitmap>?, isFirstResource: Boolean): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
override fun onResourceReady(resource: Bitmap?, model: String?, target: Target<Bitmap>?, isFromMemoryCache: Boolean, isFirstResource: Boolean): Boolean {
|
||||
addZoomableView()
|
||||
return false
|
||||
}
|
||||
}).into(view.photo_view)
|
||||
} else {
|
||||
Glide.with(this)
|
||||
.load(medium.path)
|
||||
|
@ -155,6 +172,39 @@ class PhotoFragment : ViewPagerFragment() {
|
|||
}
|
||||
}
|
||||
|
||||
private fun addZoomableView() {
|
||||
if (!medium.isPng()) {
|
||||
view.subsampling_view.apply {
|
||||
beVisible()
|
||||
setDoubleTapZoomScale(1.4f)
|
||||
setImage(ImageSource.uri(medium.path))
|
||||
orientation = SubsamplingScaleImageView.ORIENTATION_USE_EXIF
|
||||
setOnImageEventListener(object : SubsamplingScaleImageView.OnImageEventListener {
|
||||
override fun onImageLoaded() {
|
||||
}
|
||||
|
||||
override fun onReady() {
|
||||
view.photo_view.beGone()
|
||||
view.photo_view.setImageBitmap(null)
|
||||
}
|
||||
|
||||
override fun onTileLoadError(p0: Exception?) {
|
||||
}
|
||||
|
||||
override fun onPreviewReleased() {
|
||||
}
|
||||
|
||||
override fun onImageLoadError(p0: Exception?) {
|
||||
beGone()
|
||||
}
|
||||
|
||||
override fun onPreviewLoadError(p0: Exception?) {
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun rotateImageViewBy(degrees: Float) {
|
||||
loadBitmap(degrees)
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.simplemobiletools.gallery.models
|
|||
|
||||
import com.simplemobiletools.commons.extensions.getMimeType
|
||||
import com.simplemobiletools.commons.extensions.isGif
|
||||
import com.simplemobiletools.commons.extensions.isPng
|
||||
import com.simplemobiletools.commons.helpers.SORT_BY_DATE_MODIFIED
|
||||
import com.simplemobiletools.commons.helpers.SORT_BY_NAME
|
||||
import com.simplemobiletools.commons.helpers.SORT_BY_SIZE
|
||||
|
@ -15,6 +16,8 @@ data class Medium(val name: String, var path: String, val isVideo: Boolean, val
|
|||
var sorting: Int = 0
|
||||
}
|
||||
|
||||
fun isPng() = path.isPng()
|
||||
|
||||
fun isGif() = path.isGif()
|
||||
|
||||
fun isImage() = !isGif() && !isVideo
|
||||
|
|
|
@ -9,4 +9,11 @@
|
|||
android:id="@+id/photo_view"
|
||||
android:layout_width="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>
|
||||
|
|
Loading…
Reference in a new issue