store the screen resolution at view pager activity
This commit is contained in:
parent
ebd14626cb
commit
19d4ff53cb
|
@ -2,6 +2,7 @@ package com.simplemobiletools.gallery.activities
|
||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
import android.content.res.Configuration
|
||||||
import android.database.Cursor
|
import android.database.Cursor
|
||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
import android.graphics.BitmapFactory
|
import android.graphics.BitmapFactory
|
||||||
|
@ -12,6 +13,7 @@ import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.provider.MediaStore
|
import android.provider.MediaStore
|
||||||
import android.support.v4.view.ViewPager
|
import android.support.v4.view.ViewPager
|
||||||
|
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
|
||||||
|
@ -49,6 +51,11 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
private var mShowAll = false
|
private var mShowAll = false
|
||||||
private var mRotationDegrees = 0f
|
private var mRotationDegrees = 0f
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
var screenWidth = 0
|
||||||
|
var screenHeight = 0
|
||||||
|
}
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_medium)
|
setContentView(R.layout.activity_medium)
|
||||||
|
@ -58,6 +65,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
measureScreen()
|
||||||
val uri = intent.data
|
val uri = intent.data
|
||||||
if (uri != null) {
|
if (uri != null) {
|
||||||
var cursor: Cursor? = null
|
var cursor: Cursor? = null
|
||||||
|
@ -156,6 +164,18 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 updatePagerItems() {
|
private fun updatePagerItems() {
|
||||||
val pagerAdapter = MyPagerAdapter(this, supportFragmentManager, mMedia)
|
val pagerAdapter = MyPagerAdapter(this, supportFragmentManager, mMedia)
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 && !isDestroyed) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 && !isDestroyed) {
|
||||||
|
|
|
@ -6,7 +6,6 @@ import android.graphics.BitmapFactory
|
||||||
import android.graphics.Matrix
|
import android.graphics.Matrix
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.DisplayMetrics
|
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
@ -16,6 +15,7 @@ import com.simplemobiletools.commons.extensions.beGone
|
||||||
import com.simplemobiletools.commons.extensions.beVisible
|
import com.simplemobiletools.commons.extensions.beVisible
|
||||||
import com.simplemobiletools.commons.extensions.toast
|
import com.simplemobiletools.commons.extensions.toast
|
||||||
import com.simplemobiletools.gallery.R
|
import com.simplemobiletools.gallery.R
|
||||||
|
import com.simplemobiletools.gallery.activities.ViewPagerActivity
|
||||||
import com.simplemobiletools.gallery.extensions.getRealPathFromURI
|
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
|
||||||
|
@ -132,11 +132,9 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun loadBitmap(degrees: Float = 0f) {
|
private fun loadBitmap(degrees: Float = 0f) {
|
||||||
val metrics = DisplayMetrics()
|
|
||||||
activity.windowManager.defaultDisplay.getMetrics(metrics)
|
|
||||||
Picasso.with(activity)
|
Picasso.with(activity)
|
||||||
.load("file:${medium.path}")
|
.load("file:${medium.path}")
|
||||||
.resize(metrics.widthPixels * 2, metrics.heightPixels * 2)
|
.resize(ViewPagerActivity.screenWidth * 2, ViewPagerActivity.screenHeight * 2)
|
||||||
.rotate(degrees)
|
.rotate(degrees)
|
||||||
.centerInside()
|
.centerInside()
|
||||||
.into(view.photo_view)
|
.into(view.photo_view)
|
||||||
|
|
Loading…
Reference in New Issue