mirror of
https://github.com/SimpleMobileTools/Simple-Gallery.git
synced 2025-06-05 21:59:19 +02:00
calculate minimal tile dpi at fullscreen view dynamically
This commit is contained in:
@@ -354,7 +354,9 @@ class PhotoFragment : ViewPagerFragment() {
|
|||||||
|
|
||||||
private fun addZoomableView() {
|
private fun addZoomableView() {
|
||||||
val rotation = degreesForRotation(imageOrientation)
|
val rotation = degreesForRotation(imageOrientation)
|
||||||
|
|
||||||
view.subsampling_view.apply {
|
view.subsampling_view.apply {
|
||||||
|
setMinimumTileDpi(getMinTileDpi())
|
||||||
background = ColorDrawable(Color.TRANSPARENT)
|
background = ColorDrawable(Color.TRANSPARENT)
|
||||||
setBitmapDecoderFactory { PicassoDecoder(medium.path, Picasso.get(), rotation) }
|
setBitmapDecoderFactory { PicassoDecoder(medium.path, Picasso.get(), rotation) }
|
||||||
setRegionDecoderFactory { PicassoRegionDecoder() }
|
setRegionDecoderFactory { PicassoRegionDecoder() }
|
||||||
@@ -396,6 +398,16 @@ class PhotoFragment : ViewPagerFragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun getMinTileDpi(): Int {
|
||||||
|
val metrics = resources.displayMetrics
|
||||||
|
val averageDpi = (metrics.xdpi + metrics.ydpi) / 2
|
||||||
|
return when {
|
||||||
|
averageDpi > 400 -> 320
|
||||||
|
averageDpi > 300 -> 240
|
||||||
|
else -> 160
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun checkIfPanorama() {
|
private fun checkIfPanorama() {
|
||||||
isPanorama = try {
|
isPanorama = try {
|
||||||
val inputStream = if (medium.path.startsWith("content:/")) context!!.contentResolver.openInputStream(Uri.parse(medium.path)) else File(medium.path).inputStream()
|
val inputStream = if (medium.path.startsWith("content:/")) context!!.contentResolver.openInputStream(Uri.parse(medium.path)) else File(medium.path).inputStream()
|
||||||
|
Reference in New Issue
Block a user