use helper extension functions for checking if the activity is alive

This commit is contained in:
tibbi 2017-12-08 17:13:52 +01:00
parent 660f67f644
commit 039d1f8431
1 changed files with 2 additions and 2 deletions

View File

@ -401,7 +401,7 @@ class MainActivity : SimpleActivity(), PreviewListener, PhotoProcessor.MediaSave
mPreviewUri = Uri.withAppendedPath(uri, lastMediaId.toString()) mPreviewUri = Uri.withAppendedPath(uri, lastMediaId.toString())
runOnUiThread { runOnUiThread {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1 || !isDestroyed) { if (!isActivityDestroyed()) {
val options = RequestOptions() val options = RequestOptions()
.centerCrop() .centerCrop()
.diskCacheStrategy(DiskCacheStrategy.NONE) .diskCacheStrategy(DiskCacheStrategy.NONE)
@ -488,7 +488,7 @@ 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) { if (isActivityDestroyed()) {
mOrientationEventListener.disable() mOrientationEventListener.disable()
return return
} }