mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2025-02-19 20:24:23 +01:00
reordering some ViewPagerActivity functions
This commit is contained in:
parent
3a23e2b0bf
commit
d0f7eb9fb1
1 changed files with 51 additions and 51 deletions
|
@ -90,6 +90,57 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
storeStateVariables()
|
storeStateVariables()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onResume() {
|
||||||
|
super.onResume()
|
||||||
|
if (!hasPermission(PERMISSION_WRITE_STORAGE)) {
|
||||||
|
finish()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mStoredUseEnglish != config.useEnglish) {
|
||||||
|
restartActivity()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
supportActionBar?.setBackgroundDrawable(resources.getDrawable(R.drawable.actionbar_gradient_background))
|
||||||
|
|
||||||
|
if (config.maxBrightness) {
|
||||||
|
val attributes = window.attributes
|
||||||
|
attributes.screenBrightness = 1f
|
||||||
|
window.attributes = attributes
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config.screenRotation == ROTATE_BY_DEVICE_ROTATION && mOrientationEventListener?.canDetectOrientation() == true) {
|
||||||
|
mOrientationEventListener?.enable()
|
||||||
|
} else if (config.screenRotation == ROTATE_BY_SYSTEM_SETTING) {
|
||||||
|
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED
|
||||||
|
}
|
||||||
|
|
||||||
|
invalidateOptionsMenu()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onPause() {
|
||||||
|
super.onPause()
|
||||||
|
mOrientationEventListener?.disable()
|
||||||
|
stopSlideshow()
|
||||||
|
storeStateVariables()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDestroy() {
|
||||||
|
super.onDestroy()
|
||||||
|
if (intent.extras?.containsKey(IS_VIEW_INTENT) == true) {
|
||||||
|
config.temporarilyShowHidden = false
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config.isThirdPartyIntent) {
|
||||||
|
config.isThirdPartyIntent = false
|
||||||
|
|
||||||
|
if (intent.extras == null || !intent.getBooleanExtra(IS_FROM_GALLERY, false)) {
|
||||||
|
mMedia.clear()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun initViewPager() {
|
private fun initViewPager() {
|
||||||
setupOrientationEventListener()
|
setupOrientationEventListener()
|
||||||
measureScreen()
|
measureScreen()
|
||||||
|
@ -163,21 +214,6 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroy() {
|
|
||||||
super.onDestroy()
|
|
||||||
if (intent.extras?.containsKey(IS_VIEW_INTENT) == true) {
|
|
||||||
config.temporarilyShowHidden = false
|
|
||||||
}
|
|
||||||
|
|
||||||
if (config.isThirdPartyIntent) {
|
|
||||||
config.isThirdPartyIntent = false
|
|
||||||
|
|
||||||
if (intent.extras == null || !intent.getBooleanExtra(IS_FROM_GALLERY, false)) {
|
|
||||||
mMedia.clear()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun setupOrientationEventListener() {
|
private fun setupOrientationEventListener() {
|
||||||
mOrientationEventListener = object : OrientationEventListener(this, SensorManager.SENSOR_DELAY_NORMAL) {
|
mOrientationEventListener = object : OrientationEventListener(this, SensorManager.SENSOR_DELAY_NORMAL) {
|
||||||
override fun onOrientationChanged(orientation: Int) {
|
override fun onOrientationChanged(orientation: Int) {
|
||||||
|
@ -200,42 +236,6 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
|
||||||
super.onResume()
|
|
||||||
if (!hasPermission(PERMISSION_WRITE_STORAGE)) {
|
|
||||||
finish()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mStoredUseEnglish != config.useEnglish) {
|
|
||||||
restartActivity()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
supportActionBar?.setBackgroundDrawable(resources.getDrawable(R.drawable.actionbar_gradient_background))
|
|
||||||
|
|
||||||
if (config.maxBrightness) {
|
|
||||||
val attributes = window.attributes
|
|
||||||
attributes.screenBrightness = 1f
|
|
||||||
window.attributes = attributes
|
|
||||||
}
|
|
||||||
|
|
||||||
if (config.screenRotation == ROTATE_BY_DEVICE_ROTATION && mOrientationEventListener?.canDetectOrientation() == true) {
|
|
||||||
mOrientationEventListener?.enable()
|
|
||||||
} else if (config.screenRotation == ROTATE_BY_SYSTEM_SETTING) {
|
|
||||||
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED
|
|
||||||
}
|
|
||||||
|
|
||||||
invalidateOptionsMenu()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onPause() {
|
|
||||||
super.onPause()
|
|
||||||
mOrientationEventListener?.disable()
|
|
||||||
stopSlideshow()
|
|
||||||
storeStateVariables()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||||
menuInflater.inflate(R.menu.menu_viewpager, menu)
|
menuInflater.inflate(R.menu.menu_viewpager, menu)
|
||||||
val currentMedium = getCurrentMedium() ?: return true
|
val currentMedium = getCurrentMedium() ?: return true
|
||||||
|
|
Loading…
Reference in a new issue