Skip to content

Commit 4201723

Browse files
authored
Merge pull request #10304 from TeamNewPipe/fix/media.ccc.de
Adjust empty state message for ListInfoFragments depending on Info stream type
2 parents c69bcaa + bef79e7 commit 4201723

9 files changed

Lines changed: 50 additions & 6 deletions

File tree

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ dependencies {
200200
// name and the commit hash with the commit hash of the (pushed) commit you want to test
201201
// This works thanks to JitPack: https://jitpack.io/
202202
implementation 'com.github.TeamNewPipe:nanojson:1d9e1aea9049fc9f85e68b43ba39fe7be1c1f751'
203-
implementation 'com.github.TeamNewPipe:NewPipeExtractor:v0.22.7'
203+
implementation 'com.github.TeamNewPipe:NewPipeExtractor:340095515d45ecbee576872c7198992ebd8e4f08'
204204
implementation 'com.github.TeamNewPipe:NoNonsense-FilePicker:5.0.0'
205205

206206
/** Checkstyle **/

app/src/main/java/org/schabi/newpipe/fragments/BaseStateFragment.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
package org.schabi.newpipe.fragments;
22

3+
import static org.schabi.newpipe.ktx.ViewUtils.animate;
4+
35
import android.os.Bundle;
46
import android.util.Log;
57
import android.view.View;
68
import android.widget.ProgressBar;
9+
import android.widget.TextView;
710

811
import androidx.annotation.NonNull;
912
import androidx.annotation.Nullable;
13+
import androidx.annotation.StringRes;
1014
import androidx.fragment.app.Fragment;
1115

1216
import org.schabi.newpipe.BaseFragment;
@@ -20,15 +24,15 @@
2024

2125
import icepick.State;
2226

23-
import static org.schabi.newpipe.ktx.ViewUtils.animate;
24-
2527
public abstract class BaseStateFragment<I> extends BaseFragment implements ViewContract<I> {
2628
@State
2729
protected AtomicBoolean wasLoading = new AtomicBoolean();
2830
protected AtomicBoolean isLoading = new AtomicBoolean();
2931

3032
@Nullable
31-
private View emptyStateView;
33+
protected View emptyStateView;
34+
@Nullable
35+
protected TextView emptyStateMessageView;
3236
@Nullable
3337
private ProgressBar loadingProgressBar;
3438

@@ -65,6 +69,7 @@ public void onResume() {
6569
protected void initViews(final View rootView, final Bundle savedInstanceState) {
6670
super.initViews(rootView, savedInstanceState);
6771
emptyStateView = rootView.findViewById(R.id.empty_state_view);
72+
emptyStateMessageView = rootView.findViewById(R.id.empty_state_message);
6873
loadingProgressBar = rootView.findViewById(R.id.loading_progress_bar);
6974
errorPanelHelper = new ErrorPanelHelper(this, rootView, this::onRetryButtonClicked);
7075
}
@@ -189,6 +194,12 @@ public final void showTextError(@NonNull final String errorString) {
189194
errorPanelHelper.showTextError(errorString);
190195
}
191196

197+
protected void setEmptyStateMessage(@StringRes final int text) {
198+
if (emptyStateMessageView != null) {
199+
emptyStateMessageView.setText(text);
200+
}
201+
}
202+
192203
public final void hideErrorPanel() {
193204
errorPanelHelper.hide();
194205
lastPanelError = null;

app/src/main/java/org/schabi/newpipe/fragments/list/BaseListInfoFragment.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
package org.schabi.newpipe.fragments.list;
22

3+
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
4+
35
import android.os.Bundle;
46
import android.text.TextUtils;
57
import android.util.Log;
68
import android.view.View;
79

810
import androidx.annotation.NonNull;
911

12+
import org.schabi.newpipe.R;
1013
import org.schabi.newpipe.error.ErrorInfo;
1114
import org.schabi.newpipe.error.UserAction;
1215
import org.schabi.newpipe.extractor.InfoItem;
@@ -252,6 +255,20 @@ public void handleResult(@NonNull final L result) {
252255
}
253256
}
254257

258+
@Override
259+
public void showEmptyState() {
260+
// show "no streams" for SoundCloud; otherwise "no videos"
261+
// showing "no live streams" is handled in KioskFragment
262+
if (emptyStateView != null) {
263+
if (currentInfo.getService() == SoundCloud) {
264+
setEmptyStateMessage(R.string.no_streams);
265+
} else {
266+
setEmptyStateMessage(R.string.no_videos);
267+
}
268+
}
269+
super.showEmptyState();
270+
}
271+
255272
/*//////////////////////////////////////////////////////////////////////////
256273
// Utils
257274
//////////////////////////////////////////////////////////////////////////*/

app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ private void showContentNotSupportedIfNeeded() {
573573
channelBinding.errorContentNotSupported.setVisibility(View.VISIBLE);
574574
channelBinding.channelKaomoji.setText("(︶︹︺)");
575575
channelBinding.channelKaomoji.setTextSize(TypedValue.COMPLEX_UNIT_SP, 45f);
576-
channelBinding.channelNoVideos.setVisibility(View.GONE);
576+
channelBinding.emptyStateMessage.setVisibility(View.GONE);
577577
}
578578

579579
private PlayQueue getPlayQueue() {

app/src/main/java/org/schabi/newpipe/fragments/list/kiosk/KioskFragment.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@
1616
import org.schabi.newpipe.error.UserAction;
1717
import org.schabi.newpipe.extractor.ListExtractor;
1818
import org.schabi.newpipe.extractor.NewPipe;
19+
import org.schabi.newpipe.extractor.ServiceList;
1920
import org.schabi.newpipe.extractor.StreamingService;
2021
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
2122
import org.schabi.newpipe.extractor.kiosk.KioskInfo;
2223
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandlerFactory;
2324
import org.schabi.newpipe.extractor.localization.ContentCountry;
25+
import org.schabi.newpipe.extractor.services.media_ccc.extractors.MediaCCCLiveStreamKiosk;
2426
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
2527
import org.schabi.newpipe.fragments.list.BaseListInfoFragment;
2628
import org.schabi.newpipe.util.ExtractorHelper;
@@ -161,4 +163,14 @@ public void handleResult(@NonNull final KioskInfo result) {
161163
name = kioskTranslatedName;
162164
setTitle(kioskTranslatedName);
163165
}
166+
167+
@Override
168+
public void showEmptyState() {
169+
// show "no live streams" for live stream kiosk
170+
super.showEmptyState();
171+
if (MediaCCCLiveStreamKiosk.KIOSK_ID.equals(currentInfo.getId())
172+
&& ServiceList.MediaCCC.getServiceId() == currentInfo.getServiceId()) {
173+
setEmptyStateMessage(R.string.no_live_streams);
174+
}
175+
}
164176
}

app/src/main/res/layout/fragment_channel.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
tools:ignore="HardcodedText,UnusedAttribute" />
4343

4444
<org.schabi.newpipe.views.NewPipeTextView
45-
android:id="@+id/channel_no_videos"
45+
android:id="@+id/empty_state_message"
4646
android:layout_width="wrap_content"
4747
android:layout_height="wrap_content"
4848
android:layout_gravity="center"

app/src/main/res/layout/fragment_kiosk.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
tools:ignore="HardcodedText,UnusedAttribute" />
4343

4444
<org.schabi.newpipe.views.NewPipeTextView
45+
android:id="@+id/empty_state_message"
4546
android:layout_width="wrap_content"
4647
android:layout_height="wrap_content"
4748
android:layout_gravity="center"

app/src/main/res/layout/fragment_playlist.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
tools:ignore="HardcodedText,UnusedAttribute" />
4242

4343
<org.schabi.newpipe.views.NewPipeTextView
44+
android:id="@+id/empty_state_message"
4445
android:layout_width="wrap_content"
4546
android:layout_height="wrap_content"
4647
android:layout_gravity="center"

app/src/main/res/values/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,8 @@
317317
</plurals>
318318
<string name="no_comments">No comments</string>
319319
<string name="comments_are_disabled">Comments are disabled</string>
320+
<string name="no_streams">No streams</string>
321+
<string name="no_live_streams">No live streams</string>
320322
<plurals name="new_streams">
321323
<item quantity="one">%s new stream</item>
322324
<item quantity="other">%s new streams</item>

0 commit comments

Comments
 (0)