properly handle file thumbnails at search
This commit is contained in:
parent
146cb1a052
commit
b5c993ed51
|
@ -26,7 +26,12 @@ import com.simplemobiletools.gallery.pro.interfaces.MediaOperationsListener
|
|||
import com.simplemobiletools.gallery.pro.models.Medium
|
||||
import com.simplemobiletools.gallery.pro.models.ThumbnailItem
|
||||
import com.simplemobiletools.gallery.pro.models.ThumbnailSection
|
||||
import kotlinx.android.synthetic.main.activity_media.*
|
||||
import kotlinx.android.synthetic.main.activity_search.*
|
||||
import kotlinx.android.synthetic.main.activity_search.media_empty_text_placeholder
|
||||
import kotlinx.android.synthetic.main.activity_search.media_grid
|
||||
import kotlinx.android.synthetic.main.activity_search.media_horizontal_fastscroller
|
||||
import kotlinx.android.synthetic.main.activity_search.media_vertical_fastscroller
|
||||
import java.io.File
|
||||
|
||||
class SearchActivity : SimpleActivity(), MediaOperationsListener {
|
||||
|
@ -120,6 +125,7 @@ class SearchActivity : SimpleActivity(), MediaOperationsListener {
|
|||
}
|
||||
|
||||
getMediaAdapter()?.updateMedia(grouped)
|
||||
handleGridSpacing(grouped)
|
||||
measureRecyclerViewContent(grouped)
|
||||
}
|
||||
} catch (ignored: Exception) {
|
||||
|
@ -139,9 +145,11 @@ class SearchActivity : SimpleActivity(), MediaOperationsListener {
|
|||
media_grid.adapter = this
|
||||
}
|
||||
setupLayoutManager()
|
||||
handleGridSpacing(mAllMedia)
|
||||
measureRecyclerViewContent(mAllMedia)
|
||||
} else if (mLastSearchedText.isEmpty()) {
|
||||
(currAdapter as MediaAdapter).updateMedia(mAllMedia)
|
||||
handleGridSpacing(mAllMedia)
|
||||
measureRecyclerViewContent(mAllMedia)
|
||||
} else {
|
||||
textChanged(mLastSearchedText)
|
||||
|
@ -150,6 +158,20 @@ class SearchActivity : SimpleActivity(), MediaOperationsListener {
|
|||
setupScrollDirection()
|
||||
}
|
||||
|
||||
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) {
|
||||
val spanCount = config.mediaColumnCnt
|
||||
val spacing = config.thumbnailSpacing
|
||||
val decoration = GridSpacingItemDecoration(spanCount, spacing, config.scrollHorizontally, config.fileRoundedCorners, media, true)
|
||||
media_grid.addItemDecoration(decoration)
|
||||
}
|
||||
}
|
||||
|
||||
private fun getMediaAdapter() = media_grid.adapter as? MediaAdapter
|
||||
|
||||
private fun toggleFilenameVisibility() {
|
||||
|
|
Loading…
Reference in New Issue