mirror of
https://github.com/SimpleMobileTools/Simple-Gallery.git
synced 2024-12-23 14:41:06 +01:00
make orientationEventListener nullable
This commit is contained in:
parent
434b98b5e6
commit
f06fe6a299
@ -44,15 +44,11 @@ import com.simplemobiletools.gallery.fragments.ViewPagerFragment
|
|||||||
import com.simplemobiletools.gallery.helpers.*
|
import com.simplemobiletools.gallery.helpers.*
|
||||||
import com.simplemobiletools.gallery.models.Medium
|
import com.simplemobiletools.gallery.models.Medium
|
||||||
import kotlinx.android.synthetic.main.activity_medium.*
|
import kotlinx.android.synthetic.main.activity_medium.*
|
||||||
import java.io.File
|
import java.io.*
|
||||||
import java.io.FileInputStream
|
|
||||||
import java.io.FileOutputStream
|
|
||||||
import java.io.InputStream
|
|
||||||
import java.io.OutputStream
|
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, ViewPagerFragment.FragmentListener {
|
class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, ViewPagerFragment.FragmentListener {
|
||||||
lateinit var mOrientationEventListener: OrientationEventListener
|
private var mOrientationEventListener: OrientationEventListener? = null
|
||||||
private var mPath = ""
|
private var mPath = ""
|
||||||
private var mDirectory = ""
|
private var mDirectory = ""
|
||||||
|
|
||||||
@ -214,8 +210,8 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
|||||||
window.attributes = attributes
|
window.attributes = attributes
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.screenRotation == ROTATE_BY_DEVICE_ROTATION && mOrientationEventListener.canDetectOrientation()) {
|
if (config.screenRotation == ROTATE_BY_DEVICE_ROTATION && mOrientationEventListener?.canDetectOrientation() == true) {
|
||||||
mOrientationEventListener.enable()
|
mOrientationEventListener?.enable()
|
||||||
} else if (config.screenRotation == ROTATE_BY_SYSTEM_SETTING) {
|
} else if (config.screenRotation == ROTATE_BY_SYSTEM_SETTING) {
|
||||||
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED
|
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED
|
||||||
}
|
}
|
||||||
@ -225,7 +221,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
|||||||
|
|
||||||
override fun onPause() {
|
override fun onPause() {
|
||||||
super.onPause()
|
super.onPause()
|
||||||
mOrientationEventListener.disable()
|
mOrientationEventListener?.disable()
|
||||||
stopSlideshow()
|
stopSlideshow()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -241,11 +237,11 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
|||||||
findItem(R.id.menu_hide).isVisible = !currentMedium.name.startsWith('.')
|
findItem(R.id.menu_hide).isVisible = !currentMedium.name.startsWith('.')
|
||||||
findItem(R.id.menu_unhide).isVisible = currentMedium.name.startsWith('.')
|
findItem(R.id.menu_unhide).isVisible = currentMedium.name.startsWith('.')
|
||||||
findItem(R.id.menu_rotate).setShowAsAction(
|
findItem(R.id.menu_rotate).setShowAsAction(
|
||||||
if (mRotationDegrees !== 0f) {
|
if (mRotationDegrees != 0f) {
|
||||||
MenuItem.SHOW_AS_ACTION_ALWAYS
|
MenuItem.SHOW_AS_ACTION_ALWAYS
|
||||||
} else {
|
} else {
|
||||||
MenuItem.SHOW_AS_ACTION_IF_ROOM
|
MenuItem.SHOW_AS_ACTION_IF_ROOM
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
Loading…
Reference in New Issue
Block a user