Skip to content

Commit

Permalink
Merge pull request TeamNewPipe#10304 from TeamNewPipe/fix/media.ccc.de
Browse files Browse the repository at this point in the history
Adjust empty state message for ListInfoFragments depending on Info stream type
  • Loading branch information
Stypox committed Aug 6, 2023
2 parents c69bcaa + bef79e7 commit 4201723
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 **/
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -20,15 +24,15 @@

import icepick.State;

import static org.schabi.newpipe.ktx.ViewUtils.animate;

public abstract class BaseStateFragment<I> extends BaseFragment implements ViewContract<I> {
@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;

Expand Down Expand Up @@ -65,6 +69,7 @@ public void onResume() {
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);
}
Expand Down Expand Up @@ -189,6 +194,12 @@ public final void showTextError(@NonNull final String errorString) {
errorPanelHelper.showTextError(errorString);
}

protected void setEmptyStateMessage(@StringRes final int text) {
if (emptyStateMessageView != null) {
emptyStateMessageView.setText(text);
}
}

public final void hideErrorPanel() {
errorPanelHelper.hide();
lastPanelError = null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
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;
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;
Expand Down Expand Up @@ -252,6 +255,20 @@ public void handleResult(@NonNull final L result) {
}
}

@Override
public void showEmptyState() {
// show "no streams" for SoundCloud; otherwise "no videos"
// showing "no live streams" is handled in KioskFragment
if (emptyStateView != null) {
if (currentInfo.getService() == SoundCloud) {
setEmptyStateMessage(R.string.no_streams);
} else {
setEmptyStateMessage(R.string.no_videos);
}
}
super.showEmptyState();
}

/*//////////////////////////////////////////////////////////////////////////
// Utils
//////////////////////////////////////////////////////////////////////////*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ private void showContentNotSupportedIfNeeded() {
channelBinding.errorContentNotSupported.setVisibility(View.VISIBLE);
channelBinding.channelKaomoji.setText("(︶︹︺)");
channelBinding.channelKaomoji.setTextSize(TypedValue.COMPLEX_UNIT_SP, 45f);
channelBinding.channelNoVideos.setVisibility(View.GONE);
channelBinding.emptyStateMessage.setVisibility(View.GONE);
}

private PlayQueue getPlayQueue() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@
import org.schabi.newpipe.error.UserAction;
import org.schabi.newpipe.extractor.ListExtractor;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.ServiceList;
import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
import org.schabi.newpipe.extractor.kiosk.KioskInfo;
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandlerFactory;
import org.schabi.newpipe.extractor.localization.ContentCountry;
import org.schabi.newpipe.extractor.services.media_ccc.extractors.MediaCCCLiveStreamKiosk;
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
import org.schabi.newpipe.fragments.list.BaseListInfoFragment;
import org.schabi.newpipe.util.ExtractorHelper;
Expand Down Expand Up @@ -161,4 +163,14 @@ public void handleResult(@NonNull final KioskInfo result) {
name = kioskTranslatedName;
setTitle(kioskTranslatedName);
}

@Override
public void showEmptyState() {
// show "no live streams" for live stream kiosk
super.showEmptyState();
if (MediaCCCLiveStreamKiosk.KIOSK_ID.equals(currentInfo.getId())
&& ServiceList.MediaCCC.getServiceId() == currentInfo.getServiceId()) {
setEmptyStateMessage(R.string.no_live_streams);
}
}
}
2 changes: 1 addition & 1 deletion app/src/main/res/layout/fragment_channel.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
tools:ignore="HardcodedText,UnusedAttribute" />

<org.schabi.newpipe.views.NewPipeTextView
android:id="@+id/channel_no_videos"
android:id="@+id/empty_state_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/fragment_kiosk.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
tools:ignore="HardcodedText,UnusedAttribute" />

<org.schabi.newpipe.views.NewPipeTextView
android:id="@+id/empty_state_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/fragment_playlist.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
tools:ignore="HardcodedText,UnusedAttribute" />

<org.schabi.newpipe.views.NewPipeTextView
android:id="@+id/empty_state_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,8 @@
</plurals>
<string name="no_comments">No comments</string>
<string name="comments_are_disabled">Comments are disabled</string>
<string name="no_streams">No streams</string>
<string name="no_live_streams">No live streams</string>
<plurals name="new_streams">
<item quantity="one">%s new stream</item>
<item quantity="other">%s new streams</item>
Expand Down

0 comments on commit 4201723

Please sign in to comment.