From 19a2aa71bfee80970f63841bcb10183022ef5ea1 Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 26 Jun 2017 22:30:36 +0200 Subject: [PATCH] make adapters nullable at resume too --- .../gallery/activities/MainActivity.kt | 10 ++++++---- .../gallery/activities/MediaActivity.kt | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt index 0b0134d3c..18e80805a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -109,16 +109,18 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { override fun onResume() { super.onResume() if (mStoredAnimateGifs != config.animateGifs) { - directories_grid.adapter.notifyDataSetChanged() + directories_grid.adapter?.notifyDataSetChanged() } if (mStoredCropThumbnails != config.cropThumbnails) { - directories_grid.adapter.notifyDataSetChanged() + directories_grid.adapter?.notifyDataSetChanged() } if (mStoredScrollHorizontally != config.scrollHorizontally) { - (directories_grid.adapter as DirectoryAdapter).scrollVertically = !config.scrollHorizontally - directories_grid.adapter.notifyDataSetChanged() + directories_grid.adapter?.let { + (it as DirectoryAdapter).scrollVertically = !config.scrollHorizontally + it.notifyDataSetChanged() + } setupScrollDirection() } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt index ef9344764..78c2d610e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt @@ -79,16 +79,18 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { override fun onResume() { super.onResume() if (mShowAll && mStoredAnimateGifs != config.animateGifs) { - media_grid.adapter.notifyDataSetChanged() + media_grid.adapter?.notifyDataSetChanged() } if (mStoredCropThumbnails != config.cropThumbnails) { - media_grid.adapter.notifyDataSetChanged() + media_grid.adapter?.notifyDataSetChanged() } if (mStoredScrollHorizontally != config.scrollHorizontally) { - (media_grid.adapter as MediaAdapter).scrollVertically = !config.scrollHorizontally - media_grid.adapter.notifyDataSetChanged() + media_grid.adapter?.let { + (it as MediaAdapter).scrollVertically = !config.scrollHorizontally + it.notifyDataSetChanged() + } setupScrollDirection() }