mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-22 20:48:00 +01:00
calculate double click scaling factor differently
This commit is contained in:
parent
db9ddac55d
commit
5f4a926faa
2 changed files with 9 additions and 5 deletions
|
@ -2,6 +2,7 @@ package com.simplemobiletools.gallery.extensions
|
|||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.res.Configuration
|
||||
import android.database.Cursor
|
||||
import android.net.Uri
|
||||
import android.provider.MediaStore
|
||||
|
@ -19,6 +20,8 @@ import com.simplemobiletools.gallery.models.Medium
|
|||
import java.io.File
|
||||
import java.util.*
|
||||
|
||||
val Context.portrait get() = resources.configuration.orientation == Configuration.ORIENTATION_PORTRAIT
|
||||
|
||||
fun Context.getRealPathFromURI(uri: Uri): String? {
|
||||
var cursor: Cursor? = null
|
||||
try {
|
||||
|
|
|
@ -27,6 +27,7 @@ import com.simplemobiletools.gallery.activities.ViewPagerActivity
|
|||
import com.simplemobiletools.gallery.extensions.config
|
||||
import com.simplemobiletools.gallery.extensions.getFileSignature
|
||||
import com.simplemobiletools.gallery.extensions.getRealPathFromURI
|
||||
import com.simplemobiletools.gallery.extensions.portrait
|
||||
import com.simplemobiletools.gallery.helpers.GlideRotateTransformation
|
||||
import com.simplemobiletools.gallery.helpers.MEDIUM
|
||||
import com.simplemobiletools.gallery.models.Medium
|
||||
|
@ -238,12 +239,12 @@ class PhotoFragment : ViewPagerFragment() {
|
|||
val height = bitmapOptions.outHeight
|
||||
val bitmapAspectRatio = height / (width).toFloat()
|
||||
|
||||
return if (Math.abs(displayAspectRatio - bitmapAspectRatio) < RATIO_THRESHOLD) {
|
||||
2f
|
||||
} else if (bitmapAspectRatio > 1f) {
|
||||
width / (height).toFloat()
|
||||
return if (context.portrait && bitmapAspectRatio <= 1f) {
|
||||
ViewPagerActivity.screenHeight / height.toFloat()
|
||||
} else if (!context.portrait && bitmapAspectRatio >= 1f) {
|
||||
ViewPagerActivity.screenWidth / width.toFloat()
|
||||
} else {
|
||||
bitmapAspectRatio
|
||||
2f
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue