Merge pull request #635 from Naveen3Singh/loading_progress

Show progress when loading files
This commit is contained in:
Tibor Kaputa 2022-09-19 14:33:21 +02:00 committed by GitHub
commit 0ef1f473d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 8 deletions

View File

@ -58,8 +58,8 @@ class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
val properPrimaryColor = context!!.getProperPrimaryColor() val properPrimaryColor = context!!.getProperPrimaryColor()
items_fastscroller.updateColors(properPrimaryColor) items_fastscroller.updateColors(properPrimaryColor)
search_progress.setIndicatorColor(properPrimaryColor) progress_bar.setIndicatorColor(properPrimaryColor)
search_progress.trackColor = properPrimaryColor.adjustAlpha(LOWER_ALPHA) progress_bar.trackColor = properPrimaryColor.adjustAlpha(LOWER_ALPHA)
if (currentPath != "") { if (currentPath != "") {
breadcrumbs.updateColor(textColor) breadcrumbs.updateColor(textColor)
@ -95,6 +95,7 @@ class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
scrollStates[currentPath] = getScrollState()!! scrollStates[currentPath] = getScrollState()!!
currentPath = realPath currentPath = realPath
showHidden = context!!.config.shouldShowHidden showHidden = context!!.config.shouldShowHidden
showProgressBar()
getItems(currentPath) { originalPath, listItems -> getItems(currentPath) { originalPath, listItems ->
if (currentPath != originalPath) { if (currentPath != originalPath) {
return@getItems return@getItems
@ -120,6 +121,7 @@ class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
if (context != null && currentViewType != context!!.config.getFolderViewType(currentPath)) { if (context != null && currentViewType != context!!.config.getFolderViewType(currentPath)) {
setupLayoutManager() setupLayoutManager()
} }
hideProgressBar()
} }
} }
} }
@ -298,16 +300,16 @@ class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
getRecyclerAdapter()?.updateItems(itemsIgnoringSearch) getRecyclerAdapter()?.updateItems(itemsIgnoringSearch)
items_placeholder.beGone() items_placeholder.beGone()
items_placeholder_2.beGone() items_placeholder_2.beGone()
search_progress.hide() hideProgressBar()
} }
searchText.length == 1 -> { searchText.length == 1 -> {
items_fastscroller.beGone() items_fastscroller.beGone()
items_placeholder.beVisible() items_placeholder.beVisible()
items_placeholder_2.beVisible() items_placeholder_2.beVisible()
search_progress.hide() hideProgressBar()
} }
else -> { else -> {
search_progress.show() showProgressBar()
ensureBackgroundThread { ensureBackgroundThread {
val files = searchFiles(searchText, currentPath) val files = searchFiles(searchText, currentPath)
files.sortBy { it.getParentPath() } files.sortBy { it.getParentPath() }
@ -343,7 +345,7 @@ class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
items_fastscroller.beVisibleIf(listItems.isNotEmpty()) items_fastscroller.beVisibleIf(listItems.isNotEmpty())
items_placeholder.beVisibleIf(listItems.isEmpty()) items_placeholder.beVisibleIf(listItems.isEmpty())
items_placeholder_2.beGone() items_placeholder_2.beGone()
search_progress.hide() hideProgressBar()
} }
} }
} }
@ -404,7 +406,7 @@ class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
items_fastscroller.beVisible() items_fastscroller.beVisible()
items_placeholder.beGone() items_placeholder.beGone()
items_placeholder_2.beGone() items_placeholder_2.beGone()
search_progress.hide() hideProgressBar()
} }
private fun createNewItem() { private fun createNewItem() {
@ -498,6 +500,14 @@ class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
} }
} }
private fun showProgressBar() {
progress_bar.show()
}
private fun hideProgressBar() {
progress_bar.hide()
}
override fun toggleFilenameVisibility() { override fun toggleFilenameVisibility() {
getRecyclerAdapter()?.updateDisplayFilenamesInGrid() getRecyclerAdapter()?.updateDisplayFilenamesInGrid()
} }

View File

@ -27,12 +27,14 @@
android:paddingBottom="@dimen/small_margin" /> android:paddingBottom="@dimen/small_margin" />
<com.google.android.material.progressindicator.LinearProgressIndicator <com.google.android.material.progressindicator.LinearProgressIndicator
android:id="@+id/search_progress" android:id="@+id/progress_bar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentTop="true" android:layout_alignParentTop="true"
android:indeterminate="true" android:indeterminate="true"
android:visibility="gone" android:visibility="gone"
app:hideAnimationBehavior="outward"
app:showAnimationBehavior="inward"
app:showDelay="250" app:showDelay="250"
tools:visibility="visible" /> tools:visibility="visible" />