Skip to content

Commit 6d1c2fe

Browse files
committed
Show progress when loading files
1 parent eedb9ea commit 6d1c2fe

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

app/src/main/kotlin/com/simplemobiletools/filemanager/pro/fragments/ItemsFragment.kt

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
5858

5959
val properPrimaryColor = context!!.getProperPrimaryColor()
6060
items_fastscroller.updateColors(properPrimaryColor)
61-
search_progress.setIndicatorColor(properPrimaryColor)
62-
search_progress.trackColor = properPrimaryColor.adjustAlpha(LOWER_ALPHA)
61+
progress_bar.setIndicatorColor(properPrimaryColor)
62+
progress_bar.trackColor = properPrimaryColor.adjustAlpha(LOWER_ALPHA)
6363

6464
if (currentPath != "") {
6565
breadcrumbs.updateColor(textColor)
@@ -95,6 +95,7 @@ class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
9595
scrollStates[currentPath] = getScrollState()!!
9696
currentPath = realPath
9797
showHidden = context!!.config.shouldShowHidden
98+
showProgressBar()
9899
getItems(currentPath) { originalPath, listItems ->
99100
if (currentPath != originalPath) {
100101
return@getItems
@@ -120,6 +121,7 @@ class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
120121
if (context != null && currentViewType != context!!.config.getFolderViewType(currentPath)) {
121122
setupLayoutManager()
122123
}
124+
hideProgressBar()
123125
}
124126
}
125127
}
@@ -298,16 +300,16 @@ class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
298300
getRecyclerAdapter()?.updateItems(itemsIgnoringSearch)
299301
items_placeholder.beGone()
300302
items_placeholder_2.beGone()
301-
search_progress.hide()
303+
hideProgressBar()
302304
}
303305
searchText.length == 1 -> {
304306
items_fastscroller.beGone()
305307
items_placeholder.beVisible()
306308
items_placeholder_2.beVisible()
307-
search_progress.hide()
309+
hideProgressBar()
308310
}
309311
else -> {
310-
search_progress.show()
312+
showProgressBar()
311313
ensureBackgroundThread {
312314
val files = searchFiles(searchText, currentPath)
313315
files.sortBy { it.getParentPath() }
@@ -343,7 +345,7 @@ class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
343345
items_fastscroller.beVisibleIf(listItems.isNotEmpty())
344346
items_placeholder.beVisibleIf(listItems.isEmpty())
345347
items_placeholder_2.beGone()
346-
search_progress.hide()
348+
hideProgressBar()
347349
}
348350
}
349351
}
@@ -404,7 +406,7 @@ class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
404406
items_fastscroller.beVisible()
405407
items_placeholder.beGone()
406408
items_placeholder_2.beGone()
407-
search_progress.hide()
409+
hideProgressBar()
408410
}
409411

410412
private fun createNewItem() {
@@ -498,6 +500,14 @@ class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
498500
}
499501
}
500502

503+
private fun showProgressBar() {
504+
progress_bar.show()
505+
}
506+
507+
private fun hideProgressBar() {
508+
progress_bar.hide()
509+
}
510+
501511
override fun toggleFilenameVisibility() {
502512
getRecyclerAdapter()?.updateDisplayFilenamesInGrid()
503513
}

app/src/main/res/layout/items_fragment.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,14 @@
2727
android:paddingBottom="@dimen/small_margin" />
2828

2929
<com.google.android.material.progressindicator.LinearProgressIndicator
30-
android:id="@+id/search_progress"
30+
android:id="@+id/progress_bar"
3131
android:layout_width="match_parent"
3232
android:layout_height="wrap_content"
3333
android:layout_alignParentTop="true"
3434
android:indeterminate="true"
3535
android:visibility="gone"
36+
app:hideAnimationBehavior="outward"
37+
app:showAnimationBehavior="inward"
3638
app:showDelay="250"
3739
tools:visibility="visible" />
3840

0 commit comments

Comments
 (0)