From 32f74273f07bf3b764565feca02c8cadb0e425ef Mon Sep 17 00:00:00 2001 From: TobiGr Date: Sat, 5 Aug 2023 03:50:28 +0200 Subject: [PATCH] Adjust empty state message for ListInfoFragments depending on Info stream type Show "no streams" for SoundClound. Show "no live streams" for MeidaCCCLiveStreamKiosk. Otherwise show "no videos" --- app/build.gradle | 2 +- .../newpipe/fragments/BaseStateFragment.java | 17 ++++++++++++++--- .../fragments/list/BaseListInfoFragment.java | 16 ++++++++++++++++ .../fragments/list/channel/ChannelFragment.java | 2 +- .../fragments/list/kiosk/KioskFragment.java | 12 ++++++++++++ app/src/main/res/layout/fragment_channel.xml | 2 +- app/src/main/res/layout/fragment_kiosk.xml | 1 + app/src/main/res/layout/fragment_playlist.xml | 1 + app/src/main/res/values/strings.xml | 2 ++ 9 files changed, 49 insertions(+), 6 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 1a0af662b..e48f6e907 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -200,7 +200,7 @@ dependencies { // name and the commit hash with the commit hash of the (pushed) commit you want to test // This works thanks to JitPack: https://jitpack.io/ implementation 'com.github.TeamNewPipe:nanojson:1d9e1aea9049fc9f85e68b43ba39fe7be1c1f751' - implementation 'com.github.TeamNewPipe:NewPipeExtractor:v0.22.7' + implementation 'com.github.TeamNewPipe:NewPipeExtractor:340095515d45ecbee576872c7198992ebd8e4f08' implementation 'com.github.TeamNewPipe:NoNonsense-FilePicker:5.0.0' /** Checkstyle **/ 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 9b4bf8377..85603d337 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/BaseStateFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/BaseStateFragment.java @@ -1,12 +1,16 @@ package org.schabi.newpipe.fragments; +import static org.schabi.newpipe.ktx.ViewUtils.animate; + import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.ProgressBar; +import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.annotation.StringRes; import androidx.fragment.app.Fragment; import org.schabi.newpipe.BaseFragment; @@ -20,15 +24,15 @@ import java.util.concurrent.atomic.AtomicBoolean; import icepick.State; -import static org.schabi.newpipe.ktx.ViewUtils.animate; - public abstract class BaseStateFragment extends BaseFragment implements ViewContract { @State protected AtomicBoolean wasLoading = new AtomicBoolean(); protected AtomicBoolean isLoading = new AtomicBoolean(); @Nullable - private View emptyStateView; + protected View emptyStateView; + @Nullable + protected TextView emptyStateMessageView; @Nullable private ProgressBar loadingProgressBar; @@ -65,6 +69,7 @@ public abstract class BaseStateFragment extends BaseFragment implements ViewC protected void initViews(final View rootView, final Bundle savedInstanceState) { super.initViews(rootView, savedInstanceState); emptyStateView = rootView.findViewById(R.id.empty_state_view); + emptyStateMessageView = rootView.findViewById(R.id.empty_state_message); loadingProgressBar = rootView.findViewById(R.id.loading_progress_bar); errorPanelHelper = new ErrorPanelHelper(this, rootView, this::onRetryButtonClicked); } @@ -189,6 +194,12 @@ public abstract class BaseStateFragment extends BaseFragment implements ViewC errorPanelHelper.showTextError(errorString); } + protected void setEmptyStateMessage(@StringRes final int text) { + if (emptyStateMessageView != null) { + emptyStateMessageView.setText(text); + } + } + public final void hideErrorPanel() { errorPanelHelper.hide(); lastPanelError = null; diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/BaseListInfoFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/BaseListInfoFragment.java index 35424437d..d4d31a110 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/BaseListInfoFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/BaseListInfoFragment.java @@ -1,5 +1,7 @@ package org.schabi.newpipe.fragments.list; +import static org.schabi.newpipe.extractor.ServiceList.SoundCloud; + import android.os.Bundle; import android.text.TextUtils; import android.util.Log; @@ -7,6 +9,7 @@ import android.view.View; import androidx.annotation.NonNull; +import org.schabi.newpipe.R; import org.schabi.newpipe.error.ErrorInfo; import org.schabi.newpipe.error.UserAction; import org.schabi.newpipe.extractor.InfoItem; @@ -252,6 +255,19 @@ public abstract class BaseListInfoFragment No comments Comments are disabled + No streams + No live streams %s new stream %s new streams