adding some search related grid improvements
This commit is contained in:
parent
7f2db07892
commit
c68f8522b8
4 changed files with 15 additions and 16 deletions
|
@ -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<ThumbnailItem> = 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)
|
||||
|
|
|
@ -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<ThumbnailItem>) {
|
||||
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)
|
||||
|
|
|
@ -457,12 +457,10 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: ArrayList<ThumbnailI
|
|||
val thumbnailItems = newMedia.clone() as ArrayList<ThumbnailItem>
|
||||
if (thumbnailItems.hashCode() != currentMediaHash) {
|
||||
currentMediaHash = thumbnailItems.hashCode()
|
||||
Handler().postDelayed({
|
||||
media = thumbnailItems
|
||||
enableInstantLoad()
|
||||
notifyDataSetChanged()
|
||||
finishActMode()
|
||||
}, 100L)
|
||||
media = thumbnailItems
|
||||
enableInstantLoad()
|
||||
notifyDataSetChanged()
|
||||
finishActMode()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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">
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/media_empty_text_placeholder"
|
||||
|
|
Loading…
Reference in a new issue