From 09441f80c7d25912f37d6584503b5f952c5215d0 Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 20 Jun 2017 22:41:27 +0200 Subject: [PATCH] couple adapter changes --- .../simplemobiletools/gallery/activities/MainActivity.kt | 8 +++----- .../simplemobiletools/gallery/activities/MediaActivity.kt | 8 +++----- .../gallery/adapters/DirectoryAdapter.kt | 3 +-- .../simplemobiletools/gallery/adapters/MediaAdapter.kt | 3 +-- 4 files changed, 8 insertions(+), 14 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 26bf5b88f..c147ff035 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -387,15 +387,13 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { } private fun setupAdapter() { - val adapter = DirectoryAdapter(this, mDirs, this) { - itemClicked(it.path) - } - val currAdapter = directories_grid.adapter if (currAdapter != null) { (currAdapter as DirectoryAdapter).updateDirs(mDirs) } else { - directories_grid.adapter = adapter + directories_grid.adapter = DirectoryAdapter(this, mDirs, this) { + itemClicked(it.path) + } } directories_fastscroller.setViews(directories_grid, directories_refresh_layout) } 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 107dc2a39..363104c0a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt @@ -136,15 +136,13 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { if (isDirEmpty()) return - val adapter = MediaAdapter(this, mMedia, this) { - itemClicked(it.path) - } - val currAdapter = media_grid.adapter if (currAdapter != null) { (currAdapter as MediaAdapter).updateMedia(mMedia) } else { - media_grid.adapter = adapter + media_grid.adapter = MediaAdapter(this, mMedia, this) { + itemClicked(it.path) + } } media_fastscroller.setViews(media_grid, media_refresh_layout) } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt index d42de7466..e0dec09e6 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt @@ -58,7 +58,6 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList, } updateTitle(selectedPositions.size) - actMode?.invalidate() } fun getProperView(itemView: View): View { @@ -63,6 +62,7 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList, fun updateTitle(cnt: Int) { actMode?.title = "$cnt / ${media.size}" + actMode?.invalidate() } fun updatePrimaryColor(color: Int) { @@ -214,7 +214,6 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList, notifyItemChanged(i) } updateTitle(cnt) - actMode?.invalidate() } private fun askConfirmDelete() {