Skip to content

Commit

Permalink
Add playlist description to PlaylistFragment
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiGr committed May 13, 2023
1 parent df430ba commit 45320da
Show file tree
Hide file tree
Showing 3 changed files with 28 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 @@ -201,7 +201,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.6'
implementation 'com.github.ChunkyProgrammer:NewPipeExtractor:b218bf69bd9172481f2ae06ef834e5916e83780a'
implementation 'com.github.TeamNewPipe:NoNonsense-FilePicker:5.0.0'

/** Checkstyle **/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package org.schabi.newpipe.fragments.list.playlist;

import static org.schabi.newpipe.extractor.utils.Utils.isBlank;
import static org.schabi.newpipe.ktx.ViewUtils.animate;
import static org.schabi.newpipe.ktx.ViewUtils.animateHideRecyclerViewAllowingScrolling;
import static org.schabi.newpipe.util.text.TextLinkifier.SET_LINK_MOVEMENT_METHOD;

import android.content.Context;
import android.os.Bundle;
Expand All @@ -17,6 +19,7 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.content.res.AppCompatResources;
import androidx.core.text.HtmlCompat;

import com.google.android.material.shape.CornerFamily;
import com.google.android.material.shape.ShapeAppearanceModel;
Expand All @@ -37,6 +40,7 @@
import org.schabi.newpipe.extractor.ServiceList;
import org.schabi.newpipe.extractor.playlist.PlaylistInfo;
import org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper;
import org.schabi.newpipe.extractor.stream.Description;
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
import org.schabi.newpipe.fragments.list.BaseListInfoFragment;
import org.schabi.newpipe.info_list.dialog.InfoItemDialog;
Expand All @@ -51,6 +55,7 @@
import org.schabi.newpipe.util.NavigationHelper;
import org.schabi.newpipe.util.PicassoHelper;
import org.schabi.newpipe.util.external_communication.ShareUtils;
import org.schabi.newpipe.util.text.TextLinkifier;

import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -321,6 +326,18 @@ public void handleResult(@NonNull final PlaylistInfo result) {
headerBinding.playlistStreamCount.setText(Localization
.localizeStreamCount(getContext(), result.getStreamCount()));

final Description description = result.getDescription();
if (description != null && description != Description.EMPTY_DESCRIPTION
&& !isBlank(description.getContent())) {
TextLinkifier.fromDescription(headerBinding.playlistDescription,
description, HtmlCompat.FROM_HTML_MODE_LEGACY,
result.getService(), result.getUrl(),
disposables, SET_LINK_MOVEMENT_METHOD);
headerBinding.playlistDescription.setVisibility(View.VISIBLE);
} else {
headerBinding.playlistDescription.setVisibility(View.GONE);
}

if (!result.getErrors().isEmpty()) {
showSnackBarError(new ErrorInfo(result.getErrors(), UserAction.REQUESTED_PLAYLIST,
result.getUrl(), result));
Expand Down
11 changes: 10 additions & 1 deletion app/src/main/res/layout/playlist_header.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,19 @@
tools:text="234 videos" />
</RelativeLayout>

<org.schabi.newpipe.views.NewPipeTextView
android:id="@+id/playlist_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/playlist_meta"
android:paddingHorizontal="@dimen/video_item_search_padding"
android:paddingTop="6dp"
tools:text="This is a multiline playlist description. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc tristique vitae sem vitae blandit" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/playlist_meta">
android:layout_below="@id/playlist_description">

<include
android:id="@+id/playlist_control"
Expand Down

0 comments on commit 45320da

Please sign in to comment.