From b744bb0a5a7f998ce37f7e9351a6d97c9bffccb8 Mon Sep 17 00:00:00 2001 From: Viktor De Pasquale Date: Sat, 16 Nov 2019 19:20:44 +0100 Subject: [PATCH] Fixed loading showing in incorrect view-states --- .../com/topjohnwu/magisk/redesign/module/ModuleViewModel.kt | 5 ++--- app/src/main/res/layout/fragment_module_md2.xml | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/topjohnwu/magisk/redesign/module/ModuleViewModel.kt b/app/src/main/java/com/topjohnwu/magisk/redesign/module/ModuleViewModel.kt index 728150575..22261169e 100644 --- a/app/src/main/java/com/topjohnwu/magisk/redesign/module/ModuleViewModel.kt +++ b/app/src/main/java/com/topjohnwu/magisk/redesign/module/ModuleViewModel.kt @@ -122,9 +122,8 @@ class ModuleViewModel( moveToState() } - fun loadRemoteImplicit() = downloadRepos() - .observeOn(AndroidSchedulers.mainThread()) - .doOnComplete { items.clear(); itemsSearch.clear() } + fun loadRemoteImplicit() = let { items.clear(); itemsSearch.clear() } + .run { downloadRepos() } .applyViewModel(this, false) .subscribeK { refresh(); submitQuery() } .add() diff --git a/app/src/main/res/layout/fragment_module_md2.xml b/app/src/main/res/layout/fragment_module_md2.xml index 5387c7b84..4bcc577b1 100644 --- a/app/src/main/res/layout/fragment_module_md2.xml +++ b/app/src/main/res/layout/fragment_module_md2.xml @@ -24,7 +24,7 @@ adapter="@{viewModel.adapter}" dividerHorizontal="@{R.drawable.divider_l1}" dividerVertical="@{R.drawable.divider_l1}" - gone="@{viewModel.loading}" + gone="@{viewModel.loading && viewModel.items.empty}" itemBinding="@{viewModel.itemBinding}" items="@{viewModel.items}" android:layout_width="match_parent" @@ -71,7 +71,7 @@