stop orientation checking if the activity is destroyed

This commit is contained in:
tibbi
2017-06-16 21:17:51 +02:00
parent 7acdcd60e6
commit b7615013aa

View File

@ -506,6 +506,11 @@ class MainActivity : SimpleActivity(), PreviewListener, PhotoProcessor.MediaSave
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) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 && isDestroyed) {
mOrientationEventListener.disable()
return
}
val currOrient = if (orientation in 45..134) { val currOrient = if (orientation in 45..134) {
ORIENT_LANDSCAPE_RIGHT ORIENT_LANDSCAPE_RIGHT
} else if (orientation in 225..314) { } else if (orientation in 225..314) {