Skip to content

Commit

Permalink
change display when there is a ContentNotSupportedException in channe…
Browse files Browse the repository at this point in the history
…l fragment
  • Loading branch information
B0pol committed Apr 8, 2020
1 parent a91d197 commit 7012fba
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ dependencies {
exclude module: 'support-annotations'
})

implementation 'com.github.B0pol:NewPipeExtractor:9a7c6b7ab00c0f5b8337232fc66d3d9b538c229f'
implementation 'com.github.TeamNewPipe:NewPipeExtractor:a5155fb'
testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-core:2.23.0'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
Expand Down Expand Up @@ -86,6 +87,8 @@ public class ChannelFragment extends BaseListInfoFragment<ChannelInfo> {
private LinearLayout headerBackgroundButton;
private MenuItem menuRssButton;
private TextView contentNotSupportedTextView;
private TextView kaomojiTextView;
private TextView noVideosTextView;

public static ChannelFragment getInstance(final int serviceId, final String url,
final String name) {
Expand Down Expand Up @@ -125,6 +128,8 @@ public View onCreateView(@NonNull final LayoutInflater inflater,
public void onViewCreated(final View rootView, final Bundle savedInstanceState) {
super.onViewCreated(rootView, savedInstanceState);
contentNotSupportedTextView = rootView.findViewById(R.id.error_content_not_supported);
kaomojiTextView = rootView.findViewById(R.id.channel_kaomoji);
noVideosTextView = rootView.findViewById(R.id.channel_no_videos);
}

@Override
Expand Down Expand Up @@ -435,7 +440,7 @@ public void handleResult(@NonNull final ChannelInfo result) {
while (it.hasNext()) {
Throwable throwable = it.next();
if (throwable instanceof ContentNotSupportedException) {
contentNotSupportedTextView.setVisibility(View.VISIBLE);
updateNoVideoDisplay();
it.remove();
}
}
Expand Down Expand Up @@ -463,6 +468,13 @@ public void handleResult(@NonNull final ChannelInfo result) {
.playOnBackgroundPlayer(activity, getPlayQueue(), false));
}

private void updateNoVideoDisplay() {
contentNotSupportedTextView.setVisibility(View.VISIBLE);
kaomojiTextView.setText("(︶︹︺)");
kaomojiTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 45f);
noVideosTextView.setVisibility(View.GONE);
}

private PlayQueue getPlayQueue() {
return getPlayQueue(0);
}
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/layout/fragment_channel.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
tools:visibility="visible">

<TextView
android:id="@+id/channel_kaomoji"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
Expand All @@ -42,6 +43,7 @@
tools:ignore="HardcodedText,UnusedAttribute"/>

<TextView
android:id="@+id/channel_no_videos"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
Expand Down

0 comments on commit 7012fba

Please sign in to comment.