Show loading indicator when loading many items

This commit is contained in:
Naveen Singh 2024-09-24 22:19:41 +05:30
parent ff836d8c24
commit 45db8c19aa
No known key found for this signature in database
GPG key ID: AF5D43C216778C0B
2 changed files with 16 additions and 0 deletions

View file

@ -164,6 +164,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
timeFormat = getTimeFormat() timeFormat = getTimeFormat()
} }
binding.loadingIndicator.setIndicatorColor(getProperPrimaryColor())
binding.mediaEmptyTextPlaceholder.setTextColor(getProperTextColor()) binding.mediaEmptyTextPlaceholder.setTextColor(getProperTextColor())
binding.mediaEmptyTextPlaceholder2.setTextColor(getProperPrimaryColor()) binding.mediaEmptyTextPlaceholder2.setTextColor(getProperPrimaryColor())
binding.mediaEmptyTextPlaceholder2.bringToFront() binding.mediaEmptyTextPlaceholder2.bringToFront()
@ -394,6 +395,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
} }
} }
binding.loadingIndicator.show()
getMedia() getMedia()
setupLayoutManager() setupLayoutManager()
} }
@ -858,6 +860,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
mMedia = media mMedia = media
runOnUiThread { runOnUiThread {
binding.loadingIndicator.hide()
binding.mediaRefreshLayout.isRefreshing = false binding.mediaRefreshLayout.isRefreshing = false
binding.mediaEmptyTextPlaceholder.beVisibleIf(media.isEmpty() && !isFromCache) binding.mediaEmptyTextPlaceholder.beVisibleIf(media.isEmpty() && !isFromCache)
binding.mediaEmptyTextPlaceholder2.beVisibleIf(media.isEmpty() && !isFromCache) binding.mediaEmptyTextPlaceholder2.beVisibleIf(media.isEmpty() && !isFromCache)

View file

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/media_coordinator" android:id="@+id/media_coordinator"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
@ -10,6 +11,18 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" /> android:layout_height="wrap_content" />
<com.google.android.material.progressindicator.CircularProgressIndicator
android:id="@+id/loading_indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:indeterminate="true"
android:visibility="gone"
app:hideAnimationBehavior="inward"
app:showAnimationBehavior="outward"
app:showDelay="500"
tools:visibility="visible" />
<RelativeLayout <RelativeLayout
android:id="@+id/media_holder" android:id="@+id/media_holder"
android:layout_width="match_parent" android:layout_width="match_parent"