removing the static ViewPagerActivity variables for screen size
This commit is contained in:
parent
3376e14f20
commit
11f437794c
2 changed files with 14 additions and 28 deletions
|
@ -19,7 +19,6 @@ import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
import android.provider.MediaStore
|
import android.provider.MediaStore
|
||||||
import android.util.DisplayMetrics
|
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
@ -74,11 +73,6 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
private var mMediaFiles = ArrayList<Medium>()
|
private var mMediaFiles = ArrayList<Medium>()
|
||||||
private var mFavoritePaths = ArrayList<String>()
|
private var mFavoritePaths = ArrayList<String>()
|
||||||
|
|
||||||
companion object {
|
|
||||||
var screenWidth = 0
|
|
||||||
var screenHeight = 0
|
|
||||||
}
|
|
||||||
|
|
||||||
@TargetApi(Build.VERSION_CODES.P)
|
@TargetApi(Build.VERSION_CODES.P)
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
@ -225,7 +219,6 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initViewPager() {
|
private fun initViewPager() {
|
||||||
measureScreen()
|
|
||||||
val uri = intent.data
|
val uri = intent.data
|
||||||
if (uri != null) {
|
if (uri != null) {
|
||||||
var cursor: Cursor? = null
|
var cursor: Cursor? = null
|
||||||
|
@ -1005,17 +998,9 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
|
|
||||||
override fun onConfigurationChanged(newConfig: Configuration?) {
|
override fun onConfigurationChanged(newConfig: Configuration?) {
|
||||||
super.onConfigurationChanged(newConfig)
|
super.onConfigurationChanged(newConfig)
|
||||||
measureScreen()
|
|
||||||
initBottomActionsLayout()
|
initBottomActionsLayout()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun measureScreen() {
|
|
||||||
val metrics = DisplayMetrics()
|
|
||||||
windowManager.defaultDisplay.getRealMetrics(metrics)
|
|
||||||
screenWidth = metrics.widthPixels
|
|
||||||
screenHeight = metrics.heightPixels
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun refreshViewPager() {
|
private fun refreshViewPager() {
|
||||||
if (config.getFileSorting(mDirectory) and SORT_BY_RANDOM == 0) {
|
if (config.getFileSorting(mDirectory) and SORT_BY_RANDOM == 0) {
|
||||||
GetMediaAsynctask(applicationContext, mDirectory, false, false, mShowAll) {
|
GetMediaAsynctask(applicationContext, mDirectory, false, false, mShowAll) {
|
||||||
|
|
|
@ -34,7 +34,6 @@ import com.simplemobiletools.commons.helpers.OTG_PATH
|
||||||
import com.simplemobiletools.gallery.pro.R
|
import com.simplemobiletools.gallery.pro.R
|
||||||
import com.simplemobiletools.gallery.pro.activities.PanoramaPhotoActivity
|
import com.simplemobiletools.gallery.pro.activities.PanoramaPhotoActivity
|
||||||
import com.simplemobiletools.gallery.pro.activities.PhotoActivity
|
import com.simplemobiletools.gallery.pro.activities.PhotoActivity
|
||||||
import com.simplemobiletools.gallery.pro.activities.ViewPagerActivity
|
|
||||||
import com.simplemobiletools.gallery.pro.extensions.*
|
import com.simplemobiletools.gallery.pro.extensions.*
|
||||||
import com.simplemobiletools.gallery.pro.helpers.MEDIUM
|
import com.simplemobiletools.gallery.pro.helpers.MEDIUM
|
||||||
import com.simplemobiletools.gallery.pro.helpers.PATH
|
import com.simplemobiletools.gallery.pro.helpers.PATH
|
||||||
|
@ -69,14 +68,16 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
private var isPanorama = false
|
private var isPanorama = false
|
||||||
private var isSubsamplingVisible = false // checking view.visibility is unreliable, use an extra variable for it
|
private var isSubsamplingVisible = false // checking view.visibility is unreliable, use an extra variable for it
|
||||||
private var imageOrientation = -1
|
private var imageOrientation = -1
|
||||||
|
private var mOriginalSubsamplingScale = 0f
|
||||||
private var loadZoomableViewHandler = Handler()
|
private var loadZoomableViewHandler = Handler()
|
||||||
|
private var mScreenWidth = 0
|
||||||
|
private var mScreenHeight = 0
|
||||||
|
|
||||||
private var storedShowExtendedDetails = false
|
private var storedShowExtendedDetails = false
|
||||||
private var storedHideExtendedDetails = false
|
private var storedHideExtendedDetails = false
|
||||||
private var storedAllowDeepZoomableImages = false
|
private var storedAllowDeepZoomableImages = false
|
||||||
private var storedShowHighestQuality = false
|
private var storedShowHighestQuality = false
|
||||||
private var storedAllowOneFingerZoom = false
|
private var storedAllowOneFingerZoom = false
|
||||||
private var mOriginalSubsamplingScale = 0f
|
|
||||||
private var storedExtendedDetails = 0
|
private var storedExtendedDetails = 0
|
||||||
|
|
||||||
lateinit var view: ViewGroup
|
lateinit var view: ViewGroup
|
||||||
|
@ -225,7 +226,7 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun checkScreenDimensions() {
|
private fun checkScreenDimensions() {
|
||||||
if (ViewPagerActivity.screenWidth == 0 || ViewPagerActivity.screenHeight == 0) {
|
if (mScreenWidth == 0 || mScreenHeight == 0) {
|
||||||
measureScreen()
|
measureScreen()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -233,8 +234,8 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
private fun measureScreen() {
|
private fun measureScreen() {
|
||||||
val metrics = DisplayMetrics()
|
val metrics = DisplayMetrics()
|
||||||
activity!!.windowManager.defaultDisplay.getRealMetrics(metrics)
|
activity!!.windowManager.defaultDisplay.getRealMetrics(metrics)
|
||||||
ViewPagerActivity.screenWidth = metrics.widthPixels
|
mScreenWidth = metrics.widthPixels
|
||||||
ViewPagerActivity.screenHeight = metrics.heightPixels
|
mScreenHeight = metrics.heightPixels
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun photoFragmentVisibilityChanged(isVisible: Boolean) {
|
private fun photoFragmentVisibilityChanged(isVisible: Boolean) {
|
||||||
|
@ -308,7 +309,7 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
val picasso = Picasso.get()
|
val picasso = Picasso.get()
|
||||||
.load(pathToLoad)
|
.load(pathToLoad)
|
||||||
.centerInside()
|
.centerInside()
|
||||||
.resize(ViewPagerActivity.screenWidth, ViewPagerActivity.screenHeight)
|
.resize(mScreenWidth, mScreenHeight)
|
||||||
|
|
||||||
if (degrees != 0) {
|
if (degrees != 0) {
|
||||||
picasso.rotate(degrees.toFloat())
|
picasso.rotate(degrees.toFloat())
|
||||||
|
@ -333,8 +334,8 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun tryLoadingWithGlide() {
|
private fun tryLoadingWithGlide() {
|
||||||
var targetWidth = if (ViewPagerActivity.screenWidth == 0) com.bumptech.glide.request.target.Target.SIZE_ORIGINAL else ViewPagerActivity.screenWidth
|
var targetWidth = if (mScreenWidth == 0) com.bumptech.glide.request.target.Target.SIZE_ORIGINAL else mScreenWidth
|
||||||
var targetHeight = if (ViewPagerActivity.screenHeight == 0) com.bumptech.glide.request.target.Target.SIZE_ORIGINAL else ViewPagerActivity.screenHeight
|
var targetHeight = if (mScreenHeight == 0) com.bumptech.glide.request.target.Target.SIZE_ORIGINAL else mScreenHeight
|
||||||
|
|
||||||
if (imageOrientation == ORIENTATION_ROTATE_90) {
|
if (imageOrientation == ORIENTATION_ROTATE_90) {
|
||||||
targetWidth = targetHeight
|
targetWidth = targetHeight
|
||||||
|
@ -489,18 +490,18 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
|
|
||||||
private fun getDoubleTapZoomScale(width: Int, height: Int): Float {
|
private fun getDoubleTapZoomScale(width: Int, height: Int): Float {
|
||||||
val bitmapAspectRatio = height / width.toFloat()
|
val bitmapAspectRatio = height / width.toFloat()
|
||||||
val screenAspectRatio = ViewPagerActivity.screenHeight / ViewPagerActivity.screenWidth.toFloat()
|
val screenAspectRatio = mScreenHeight / mScreenWidth.toFloat()
|
||||||
|
|
||||||
return if (context == null || bitmapAspectRatio == screenAspectRatio) {
|
return if (context == null || bitmapAspectRatio == screenAspectRatio) {
|
||||||
DEFAULT_DOUBLE_TAP_ZOOM
|
DEFAULT_DOUBLE_TAP_ZOOM
|
||||||
} else if (context!!.portrait && bitmapAspectRatio <= screenAspectRatio) {
|
} else if (context!!.portrait && bitmapAspectRatio <= screenAspectRatio) {
|
||||||
ViewPagerActivity.screenHeight / height.toFloat()
|
mScreenHeight / height.toFloat()
|
||||||
} else if (context!!.portrait && bitmapAspectRatio > screenAspectRatio) {
|
} else if (context!!.portrait && bitmapAspectRatio > screenAspectRatio) {
|
||||||
ViewPagerActivity.screenWidth / width.toFloat()
|
mScreenWidth / width.toFloat()
|
||||||
} else if (!context!!.portrait && bitmapAspectRatio >= screenAspectRatio) {
|
} else if (!context!!.portrait && bitmapAspectRatio >= screenAspectRatio) {
|
||||||
ViewPagerActivity.screenWidth / width.toFloat()
|
mScreenWidth / width.toFloat()
|
||||||
} else if (!context!!.portrait && bitmapAspectRatio < screenAspectRatio) {
|
} else if (!context!!.portrait && bitmapAspectRatio < screenAspectRatio) {
|
||||||
ViewPagerActivity.screenHeight / height.toFloat()
|
mScreenHeight / height.toFloat()
|
||||||
} else {
|
} else {
|
||||||
DEFAULT_DOUBLE_TAP_ZOOM
|
DEFAULT_DOUBLE_TAP_ZOOM
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue