Skip to content

Commit 6c99557

Browse files
TobiGrStypox
authored andcommitted
Add playlist description to PlaylistFragment
1 parent ee3455e commit 6c99557

2 files changed

Lines changed: 27 additions & 1 deletion

File tree

app/src/main/java/org/schabi/newpipe/fragments/list/playlist/PlaylistFragment.java

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

3+
import static org.schabi.newpipe.extractor.utils.Utils.isBlank;
34
import static org.schabi.newpipe.ktx.ViewUtils.animate;
45
import static org.schabi.newpipe.ktx.ViewUtils.animateHideRecyclerViewAllowingScrolling;
6+
import static org.schabi.newpipe.util.text.TextLinkifier.SET_LINK_MOVEMENT_METHOD;
57

68
import android.content.Context;
79
import android.os.Bundle;
@@ -17,6 +19,7 @@
1719
import androidx.annotation.NonNull;
1820
import androidx.annotation.Nullable;
1921
import androidx.appcompat.content.res.AppCompatResources;
22+
import androidx.core.text.HtmlCompat;
2023

2124
import com.google.android.material.shape.CornerFamily;
2225
import com.google.android.material.shape.ShapeAppearanceModel;
@@ -37,6 +40,7 @@
3740
import org.schabi.newpipe.extractor.ServiceList;
3841
import org.schabi.newpipe.extractor.playlist.PlaylistInfo;
3942
import org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper;
43+
import org.schabi.newpipe.extractor.stream.Description;
4044
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
4145
import org.schabi.newpipe.fragments.list.BaseListInfoFragment;
4246
import org.schabi.newpipe.info_list.dialog.InfoItemDialog;
@@ -51,6 +55,7 @@
5155
import org.schabi.newpipe.util.image.PicassoHelper;
5256
import org.schabi.newpipe.util.external_communication.ShareUtils;
5357
import org.schabi.newpipe.util.PlayButtonHelper;
58+
import org.schabi.newpipe.util.text.TextLinkifier;
5459

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

329+
final Description description = result.getDescription();
330+
if (description != null && description != Description.EMPTY_DESCRIPTION
331+
&& !isBlank(description.getContent())) {
332+
TextLinkifier.fromDescription(headerBinding.playlistDescription,
333+
description, HtmlCompat.FROM_HTML_MODE_LEGACY,
334+
result.getService(), result.getUrl(),
335+
disposables, SET_LINK_MOVEMENT_METHOD);
336+
headerBinding.playlistDescription.setVisibility(View.VISIBLE);
337+
} else {
338+
headerBinding.playlistDescription.setVisibility(View.GONE);
339+
}
340+
324341
if (!result.getErrors().isEmpty()) {
325342
showSnackBarError(new ErrorInfo(result.getErrors(), UserAction.REQUESTED_PLAYLIST,
326343
result.getUrl(), result));

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,19 @@
8080
tools:text="234 videos" />
8181
</RelativeLayout>
8282

83+
<org.schabi.newpipe.views.NewPipeTextView
84+
android:id="@+id/playlist_description"
85+
android:layout_width="match_parent"
86+
android:layout_height="wrap_content"
87+
android:layout_below="@id/playlist_meta"
88+
android:paddingHorizontal="@dimen/video_item_search_padding"
89+
android:paddingTop="6dp"
90+
tools:text="This is a multiline playlist description. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc tristique vitae sem vitae blandit" />
91+
8392
<LinearLayout
8493
android:layout_width="match_parent"
8594
android:layout_height="wrap_content"
86-
android:layout_below="@id/playlist_meta">
95+
android:layout_below="@id/playlist_description">
8796

8897
<include
8998
android:id="@+id/playlist_control"

0 commit comments

Comments
 (0)