adding some search related grid improvements

This commit is contained in:
tibbi 2021-01-20 23:37:28 +01:00
parent 7f2db07892
commit c68f8522b8
4 changed files with 15 additions and 16 deletions

View file

@ -371,6 +371,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
media_empty_text_placeholder.beGone() media_empty_text_placeholder.beGone()
} }
handleGridSpacing(grouped)
getMediaAdapter()?.updateMedia(grouped) getMediaAdapter()?.updateMedia(grouped)
measureRecyclerViewContent(grouped) measureRecyclerViewContent(grouped)
} }
@ -742,20 +743,20 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
media_vertical_fastscroller.setScrollToY(media_grid.computeVerticalScrollOffset()) media_vertical_fastscroller.setScrollToY(media_grid.computeVerticalScrollOffset())
} }
private fun handleGridSpacing() { private fun handleGridSpacing(media: ArrayList<ThumbnailItem> = mMedia) {
val viewType = config.getFolderViewType(if (mShowAll) SHOW_ALL else mPath) val viewType = config.getFolderViewType(if (mShowAll) SHOW_ALL else mPath)
if (viewType == VIEW_TYPE_GRID) { if (viewType == VIEW_TYPE_GRID) {
val spanCount = config.mediaColumnCnt val spanCount = config.mediaColumnCnt
val spacing = config.thumbnailSpacing val spacing = config.thumbnailSpacing
val useGridPosition = mMedia.firstOrNull() is ThumbnailSection val useGridPosition = media.firstOrNull() is ThumbnailSection
var currentGridDecoration: GridSpacingItemDecoration? = null var currentGridDecoration: GridSpacingItemDecoration? = null
if (media_grid.itemDecorationCount > 0) { if (media_grid.itemDecorationCount > 0) {
currentGridDecoration = media_grid.getItemDecorationAt(0) as GridSpacingItemDecoration 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.toString() != newGridDecoration.toString()) {
if (currentGridDecoration != null) { if (currentGridDecoration != null) {
media_grid.removeItemDecoration(currentGridDecoration) media_grid.removeItemDecoration(currentGridDecoration)

View file

@ -124,8 +124,8 @@ class SearchActivity : SimpleActivity(), MediaOperationsListener {
media_empty_text_placeholder.beGone() media_empty_text_placeholder.beGone()
} }
getMediaAdapter()?.updateMedia(grouped)
handleGridSpacing(grouped) handleGridSpacing(grouped)
getMediaAdapter()?.updateMedia(grouped)
measureRecyclerViewContent(grouped) measureRecyclerViewContent(grouped)
} }
} catch (ignored: Exception) { } catch (ignored: Exception) {
@ -159,12 +159,12 @@ class SearchActivity : SimpleActivity(), MediaOperationsListener {
} }
private fun handleGridSpacing(media: ArrayList<ThumbnailItem>) { private fun handleGridSpacing(media: ArrayList<ThumbnailItem>) {
val viewType = config.getFolderViewType(SHOW_ALL)
if (viewType == VIEW_TYPE_GRID) {
if (media_grid.itemDecorationCount > 0) { if (media_grid.itemDecorationCount > 0) {
media_grid.removeItemDecorationAt(0) media_grid.removeItemDecorationAt(0)
} }
val viewType = config.getFolderViewType(SHOW_ALL)
if (viewType == VIEW_TYPE_GRID) {
val spanCount = config.mediaColumnCnt val spanCount = config.mediaColumnCnt
val spacing = config.thumbnailSpacing val spacing = config.thumbnailSpacing
val decoration = GridSpacingItemDecoration(spanCount, spacing, config.scrollHorizontally, config.fileRoundedCorners, media, true) val decoration = GridSpacingItemDecoration(spanCount, spacing, config.scrollHorizontally, config.fileRoundedCorners, media, true)

View file

@ -457,12 +457,10 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: ArrayList<ThumbnailI
val thumbnailItems = newMedia.clone() as ArrayList<ThumbnailItem> val thumbnailItems = newMedia.clone() as ArrayList<ThumbnailItem>
if (thumbnailItems.hashCode() != currentMediaHash) { if (thumbnailItems.hashCode() != currentMediaHash) {
currentMediaHash = thumbnailItems.hashCode() currentMediaHash = thumbnailItems.hashCode()
Handler().postDelayed({
media = thumbnailItems media = thumbnailItems
enableInstantLoad() enableInstantLoad()
notifyDataSetChanged() notifyDataSetChanged()
finishActMode() finishActMode()
}, 100L)
} }
} }

View file

@ -3,7 +3,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/media_holder" android:id="@+id/media_holder"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="match_parent">
<com.simplemobiletools.commons.views.MyTextView <com.simplemobiletools.commons.views.MyTextView
android:id="@+id/media_empty_text_placeholder" android:id="@+id/media_empty_text_placeholder"