From d0f7eb9fb18c0d005a3a6e8c6c536967a3970877 Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 8 Nov 2017 12:09:48 +0100 Subject: [PATCH] reordering some ViewPagerActivity functions --- .../gallery/activities/ViewPagerActivity.kt | 102 +++++++++--------- 1 file changed, 51 insertions(+), 51 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt index 84803c157..5db8b92ce 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt @@ -90,6 +90,57 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View 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() { setupOrientationEventListener() 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() { mOrientationEventListener = object : OrientationEventListener(this, SensorManager.SENSOR_DELAY_NORMAL) { 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 { menuInflater.inflate(R.menu.menu_viewpager, menu) val currentMedium = getCurrentMedium() ?: return true