Don't flicker progress bar while refreshing

This commit is contained in:
ByteHamster 2021-02-19 20:39:34 +01:00
parent e5fc80e068
commit f0358eb344
1 changed files with 10 additions and 7 deletions

View File

@ -231,16 +231,19 @@ public class SubscriptionFragment extends Fragment implements Toolbar.OnMenuItem
disposable.dispose(); disposable.dispose();
} }
emptyView.hide(); emptyView.hide();
progressBar.setVisibility(View.VISIBLE);
disposable = Observable.fromCallable(DBReader::getNavDrawerData) disposable = Observable.fromCallable(DBReader::getNavDrawerData)
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe(result -> { .subscribe(
navDrawerData = result; result -> {
subscriptionAdapter.notifyDataSetChanged(); navDrawerData = result;
emptyView.updateVisibility(); subscriptionAdapter.notifyDataSetChanged();
progressBar.setVisibility(View.GONE); emptyView.updateVisibility();
}, error -> Log.e(TAG, Log.getStackTraceString(error))); progressBar.setVisibility(View.GONE); // Keep hidden to avoid flickering while refreshing
}, error -> {
Log.e(TAG, Log.getStackTraceString(error));
progressBar.setVisibility(View.GONE);
});
if (UserPreferences.getSubscriptionsFilter().isEnabled()) { if (UserPreferences.getSubscriptionsFilter().isEnabled()) {
feedsFilteredMsg.setText("{md-info-outline} " + getString(R.string.subscriptions_are_filtered)); feedsFilteredMsg.setText("{md-info-outline} " + getString(R.string.subscriptions_are_filtered));