From 2139b19ca8341046eacfef6d40bf2ff57a59714d Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 22 Jun 2018 11:16:45 +0200 Subject: [PATCH] make sure item group section titles span across the whole line --- .../gallery/activities/MediaActivity.kt | 11 +++++++++++ .../gallery/adapters/MediaAdapter.kt | 2 ++ app/src/main/res/layout/thumbnail_section.xml | 1 + 3 files changed, 14 insertions(+) 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 fdb2b876d..5bdcc90ed 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt @@ -325,6 +325,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { setupZoomListener(mZoomListener) media_grid.adapter = this } + setupLayoutManager() } else { (currAdapter as MediaAdapter).updateMedia(media) } @@ -553,6 +554,16 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { } layoutManager.spanCount = config.mediaColumnCnt + val adapter = getMediaAdapter() + layoutManager.spanSizeLookup = object : GridLayoutManager.SpanSizeLookup() { + override fun getSpanSize(position: Int): Int { + return if (adapter?.isASectionTitle(position) == true) { + layoutManager.spanCount + } else { + 1 + } + } + } } private fun initZoomListener() { 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 070e7e4c5..7b8c4b5b2 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt @@ -160,6 +160,8 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList, } } + fun isASectionTitle(position: Int) = thumbnailItems.getOrNull(position) is ThumbnailSection + private fun checkHideBtnVisibility(menu: Menu) { var hiddenCnt = 0 var unhiddenCnt = 0 diff --git a/app/src/main/res/layout/thumbnail_section.xml b/app/src/main/res/layout/thumbnail_section.xml index 54218ef69..8278e2058 100644 --- a/app/src/main/res/layout/thumbnail_section.xml +++ b/app/src/main/res/layout/thumbnail_section.xml @@ -4,4 +4,5 @@ android:id="@+id/thumbnail_section" android:layout_width="match_parent" android:layout_height="wrap_content" + android:padding="@dimen/activity_margin" android:textSize="@dimen/bigger_text_size"/>