Added progressbar indicating content loading on modules screen

This commit is contained in:
Viktor De Pasquale 2020-03-29 12:38:41 +02:00 committed by John Wu
parent 6e14a727b1
commit 1920a52829
2 changed files with 36 additions and 3 deletions

View File

@ -85,6 +85,13 @@ class ModuleViewModel(
private val itemsUpdatable = diffListOf<RepoItem.Update>() private val itemsUpdatable = diffListOf<RepoItem.Update>()
private val itemsRemote = diffListOf<RepoItem.Remote>() private val itemsRemote = diffListOf<RepoItem.Remote>()
var isRemoteLoading = false
@Bindable get
private set(value) {
field = value
notifyPropertyChanged(BR.remoteLoading)
}
val adapter = adapterOf<ComparableRvItem<*>>() val adapter = adapterOf<ComparableRvItem<*>>()
val items = MergeObservableList<ComparableRvItem<*>>() val items = MergeObservableList<ComparableRvItem<*>>()
.insertList(itemsCoreOnly) .insertList(itemsCoreOnly)
@ -215,9 +222,13 @@ class ModuleViewModel(
repoUpdater(refetch).andThen(loadRemoteDB(0)) repoUpdater(refetch).andThen(loadRemoteDB(0))
} else { } else {
loadRemoteDB(itemsRemote.size) loadRemoteDB(itemsRemote.size)
}.subscribeK(onError = Timber::e) { }.observeOn(AndroidSchedulers.mainThread())
itemsRemote.addAll(it) .doOnSubscribe { isRemoteLoading = true }
} .doOnSuccess { isRemoteLoading = false }
.doOnError { isRemoteLoading = false }
.subscribeK(onError = Timber::e) {
itemsRemote.addAll(it)
}
refetch = false refetch = false
} }

View File

@ -90,6 +90,28 @@
</LinearLayout> </LinearLayout>
<FrameLayout
goneUnless="@{viewModel.remoteLoading}"
android:layout_width="match_parent"
android:layout_height="4dp"
android:layout_gravity="bottom">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="16dp"
android:layout_gravity="center"
tools:ignore="UselessParent">
<ProgressBar
style="@style/WidgetFoundation.ProgressBar.Indeterminate"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center" />
</FrameLayout>
</FrameLayout>
</FrameLayout> </FrameLayout>