|
1 | 1 | package org.schabi.newpipe.fragments; |
2 | 2 |
|
| 3 | +import static org.schabi.newpipe.ktx.ViewUtils.animate; |
| 4 | + |
3 | 5 | import android.os.Bundle; |
4 | 6 | import android.util.Log; |
5 | 7 | import android.view.View; |
6 | 8 | import android.widget.ProgressBar; |
| 9 | +import android.widget.TextView; |
7 | 10 |
|
8 | 11 | import androidx.annotation.NonNull; |
9 | 12 | import androidx.annotation.Nullable; |
| 13 | +import androidx.annotation.StringRes; |
10 | 14 | import androidx.fragment.app.Fragment; |
11 | 15 |
|
12 | 16 | import org.schabi.newpipe.BaseFragment; |
|
20 | 24 |
|
21 | 25 | import icepick.State; |
22 | 26 |
|
23 | | -import static org.schabi.newpipe.ktx.ViewUtils.animate; |
24 | | - |
25 | 27 | public abstract class BaseStateFragment<I> extends BaseFragment implements ViewContract<I> { |
26 | 28 | @State |
27 | 29 | protected AtomicBoolean wasLoading = new AtomicBoolean(); |
28 | 30 | protected AtomicBoolean isLoading = new AtomicBoolean(); |
29 | 31 |
|
30 | 32 | @Nullable |
31 | | - private View emptyStateView; |
| 33 | + protected View emptyStateView; |
| 34 | + @Nullable |
| 35 | + protected TextView emptyStateMessageView; |
32 | 36 | @Nullable |
33 | 37 | private ProgressBar loadingProgressBar; |
34 | 38 |
|
@@ -65,6 +69,7 @@ public void onResume() { |
65 | 69 | protected void initViews(final View rootView, final Bundle savedInstanceState) { |
66 | 70 | super.initViews(rootView, savedInstanceState); |
67 | 71 | emptyStateView = rootView.findViewById(R.id.empty_state_view); |
| 72 | + emptyStateMessageView = rootView.findViewById(R.id.empty_state_message); |
68 | 73 | loadingProgressBar = rootView.findViewById(R.id.loading_progress_bar); |
69 | 74 | errorPanelHelper = new ErrorPanelHelper(this, rootView, this::onRetryButtonClicked); |
70 | 75 | } |
@@ -189,6 +194,12 @@ public final void showTextError(@NonNull final String errorString) { |
189 | 194 | errorPanelHelper.showTextError(errorString); |
190 | 195 | } |
191 | 196 |
|
| 197 | + protected void setEmptyStateMessage(@StringRes final int text) { |
| 198 | + if (emptyStateMessageView != null) { |
| 199 | + emptyStateMessageView.setText(text); |
| 200 | + } |
| 201 | + } |
| 202 | + |
192 | 203 | public final void hideErrorPanel() { |
193 | 204 | errorPanelHelper.hide(); |
194 | 205 | lastPanelError = null; |
|
0 commit comments