diff --git a/app/src/main/java/org/schabi/newpipe/fragments/BaseStateFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/BaseStateFragment.java index 51f1e55bb..0de3ea012 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/BaseStateFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/BaseStateFragment.java @@ -30,7 +30,11 @@ public abstract class BaseStateFragment extends BaseFragment implements ViewC private View emptyStateView; @Nullable private ProgressBar loadingProgressBar; + private ErrorPanelHelper errorPanelHelper; + @Nullable + @State + protected ErrorInfo lastPanelError = null; @Override public void onViewCreated(@NonNull final View rootView, final Bundle savedInstanceState) { @@ -44,6 +48,14 @@ public abstract class BaseStateFragment extends BaseFragment implements ViewC wasLoading.set(isLoading.get()); } + @Override + public void onResume() { + super.onResume(); + if (lastPanelError != null) { + showError(lastPanelError); + } + } + @Override public void onDestroy() { super.onDestroy(); @@ -98,7 +110,7 @@ public abstract class BaseStateFragment extends BaseFragment implements ViewC if (loadingProgressBar != null) { animate(loadingProgressBar, true, 400); } - errorPanelHelper.hide(); + hideErrorPanel(); } @Override @@ -109,7 +121,7 @@ public abstract class BaseStateFragment extends BaseFragment implements ViewC if (loadingProgressBar != null) { animate(loadingProgressBar, false, 0); } - errorPanelHelper.hide(); + hideErrorPanel(); } public void showEmptyState() { @@ -120,7 +132,7 @@ public abstract class BaseStateFragment extends BaseFragment implements ViewC if (loadingProgressBar != null) { animate(loadingProgressBar, false, 0); } - errorPanelHelper.hide(); + hideErrorPanel(); } @Override @@ -158,6 +170,7 @@ public abstract class BaseStateFragment extends BaseFragment implements ViewC } errorPanelHelper.showError(errorInfo); + lastPanelError = errorInfo; } public final void showTextError(@NonNull final String errorString) { @@ -175,6 +188,7 @@ public abstract class BaseStateFragment extends BaseFragment implements ViewC public final void hideErrorPanel() { errorPanelHelper.hide(); + lastPanelError = null; } public final boolean isErrorPanelVisible() { diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java index 12695acf9..26360137e 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java @@ -256,13 +256,19 @@ public class SearchFragment extends BaseListFragment observable = suggestionPublisher + suggestionDisposable = suggestionPublisher .debounce(SUGGESTIONS_DEBOUNCE, TimeUnit.MILLISECONDS) .startWithItem(searchString != null ? searchString : "") - .filter(ss -> isSuggestionsEnabled); - - suggestionDisposable = observable + .filter(ss -> isSuggestionsEnabled) .switchMap(query -> { final Flowable> flowable = historyRecordManager .getRelatedSearches(query, 3, 25); diff --git a/app/src/main/res/layout/fragment_search.xml b/app/src/main/res/layout/fragment_search.xml index 2e225e77a..7033a158a 100644 --- a/app/src/main/res/layout/fragment_search.xml +++ b/app/src/main/res/layout/fragment_search.xml @@ -107,8 +107,7 @@ layout="@layout/error_panel" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_centerHorizontal="true" - android:layout_marginTop="50dp" + android:layout_centerInParent="true" android:visibility="gone" tools:visibility="visible" />