From 47d111c642ae9d6e37430b328bb9970c8e045850 Mon Sep 17 00:00:00 2001 From: tibbi Date: Thu, 17 Nov 2016 19:47:54 +0100 Subject: [PATCH] some code style edits --- .../gallery/adapters/MediaAdapter.kt | 12 +++--------- .../gallery/adapters/MyPagerAdapter.kt | 16 +++++----------- 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt index ecca9242c..09d85beec 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt @@ -60,17 +60,11 @@ class MediaAdapter(private val context: Context, private val media: MutableList< notifyDataSetChanged() } - override fun getCount(): Int { - return media.size - } + override fun getCount() = media.size - override fun getItem(position: Int): Any { - return media[position] - } + override fun getItem(position: Int) = media[position] - override fun getItemId(position: Int): Long { - return 0 - } + override fun getItemId(position: Int) = 0L fun updateItems(newPhotos: List) { media.clear() diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MyPagerAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MyPagerAdapter.kt index 14839006e..60a0f3b74 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MyPagerAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MyPagerAdapter.kt @@ -19,9 +19,7 @@ class MyPagerAdapter(val activity: ViewPagerActivity, fm: FragmentManager, val m mFragments = SparseArray() } - override fun getCount(): Int { - return media.size - } + override fun getCount() = media.size override fun getItem(position: Int): Fragment { val medium = media[position] @@ -46,17 +44,13 @@ class MyPagerAdapter(val activity: ViewPagerActivity, fm: FragmentManager, val m } fun updateUiVisibility(isFullscreen: Boolean, pos: Int) { - for (i in -1..1) { - val fragment = mFragments[pos + i] - fragment?.systemUiVisibilityChanged(isFullscreen) - } + (-1..1).map { mFragments[pos + it] } + .forEach { it?.systemUiVisibilityChanged(isFullscreen) } } fun updateItems(pos: Int) { - for (i in -1..1) { - val fragment = mFragments[pos + i] - fragment?.updateItem() - } + (-1..1).map { mFragments[pos + it] } + .forEach { it?.updateItem() } } fun updateItems(newPaths: List) {