From c68f8522b857768e1923267c5a43e1d148afe80a Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 20 Jan 2021 23:37:28 +0100 Subject: [PATCH] adding some search related grid improvements --- .../gallery/pro/activities/MediaActivity.kt | 9 +++++---- .../gallery/pro/activities/SearchActivity.kt | 10 +++++----- .../gallery/pro/adapters/MediaAdapter.kt | 10 ++++------ app/src/main/res/layout/activity_search.xml | 2 +- 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MediaActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MediaActivity.kt index 763295a73..19c361a43 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MediaActivity.kt @@ -371,6 +371,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener { media_empty_text_placeholder.beGone() } + handleGridSpacing(grouped) getMediaAdapter()?.updateMedia(grouped) measureRecyclerViewContent(grouped) } @@ -742,20 +743,20 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener { media_vertical_fastscroller.setScrollToY(media_grid.computeVerticalScrollOffset()) } - private fun handleGridSpacing() { + private fun handleGridSpacing(media: ArrayList = mMedia) { val viewType = config.getFolderViewType(if (mShowAll) SHOW_ALL else mPath) if (viewType == VIEW_TYPE_GRID) { val spanCount = config.mediaColumnCnt val spacing = config.thumbnailSpacing - val useGridPosition = mMedia.firstOrNull() is ThumbnailSection + val useGridPosition = media.firstOrNull() is ThumbnailSection var currentGridDecoration: GridSpacingItemDecoration? = null if (media_grid.itemDecorationCount > 0) { currentGridDecoration = media_grid.getItemDecorationAt(0) as GridSpacingItemDecoration - currentGridDecoration.items = mMedia + currentGridDecoration.items = media } - val newGridDecoration = GridSpacingItemDecoration(spanCount, spacing, config.scrollHorizontally, config.fileRoundedCorners, mMedia, useGridPosition) + val newGridDecoration = GridSpacingItemDecoration(spanCount, spacing, config.scrollHorizontally, config.fileRoundedCorners, media, useGridPosition) if (currentGridDecoration.toString() != newGridDecoration.toString()) { if (currentGridDecoration != null) { media_grid.removeItemDecoration(currentGridDecoration) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SearchActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SearchActivity.kt index 6a5b30483..769d65e90 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SearchActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SearchActivity.kt @@ -124,8 +124,8 @@ class SearchActivity : SimpleActivity(), MediaOperationsListener { media_empty_text_placeholder.beGone() } - getMediaAdapter()?.updateMedia(grouped) handleGridSpacing(grouped) + getMediaAdapter()?.updateMedia(grouped) measureRecyclerViewContent(grouped) } } catch (ignored: Exception) { @@ -159,12 +159,12 @@ class SearchActivity : SimpleActivity(), MediaOperationsListener { } private fun handleGridSpacing(media: ArrayList) { - if (media_grid.itemDecorationCount > 0) { - media_grid.removeItemDecorationAt(0) - } - val viewType = config.getFolderViewType(SHOW_ALL) if (viewType == VIEW_TYPE_GRID) { + if (media_grid.itemDecorationCount > 0) { + media_grid.removeItemDecorationAt(0) + } + val spanCount = config.mediaColumnCnt val spacing = config.thumbnailSpacing val decoration = GridSpacingItemDecoration(spanCount, spacing, config.scrollHorizontally, config.fileRoundedCorners, media, true) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/MediaAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/MediaAdapter.kt index fa04937fc..6f9b3a168 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/MediaAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/MediaAdapter.kt @@ -457,12 +457,10 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: ArrayList if (thumbnailItems.hashCode() != currentMediaHash) { currentMediaHash = thumbnailItems.hashCode() - Handler().postDelayed({ - media = thumbnailItems - enableInstantLoad() - notifyDataSetChanged() - finishActMode() - }, 100L) + media = thumbnailItems + enableInstantLoad() + notifyDataSetChanged() + finishActMode() } } diff --git a/app/src/main/res/layout/activity_search.xml b/app/src/main/res/layout/activity_search.xml index cee91220e..6ab0974b7 100644 --- a/app/src/main/res/layout/activity_search.xml +++ b/app/src/main/res/layout/activity_search.xml @@ -3,7 +3,7 @@ xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/media_holder" android:layout_width="match_parent" - android:layout_height="wrap_content"> + android:layout_height="match_parent">