Skip to content

Commit 57eaa1b

Browse files
TobiGrAudricV
authored andcommitted
Apply review
Co-Authored-By: Audric V <74829229+AudricV@users.noreply.github.com>
1 parent 109d06b commit 57eaa1b

12 files changed

Lines changed: 58 additions & 36 deletions

File tree

app/src/main/java/org/schabi/newpipe/fragments/detail/BaseDescriptionFragment.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
import io.reactivex.rxjava3.disposables.CompositeDisposable;
3535

3636
public abstract class BaseDescriptionFragment extends BaseFragment {
37-
final CompositeDisposable descriptionDisposables = new CompositeDisposable();
37+
private final CompositeDisposable descriptionDisposables = new CompositeDisposable();
3838
protected FragmentDescriptionBinding binding;
3939

4040
@Override
@@ -75,7 +75,7 @@ public void onDestroy() {
7575
protected abstract int getServiceId();
7676

7777
/**
78-
* Get the URL of the described video. Used for generating description links.
78+
* Get the URL of the described video or audio, used to generate description links.
7979
* @return stream URL
8080
*/
8181
@Nullable

app/src/main/java/org/schabi/newpipe/fragments/detail/DescriptionFragment.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ protected StreamingService getService() {
5252

5353
@Override
5454
protected int getServiceId() {
55+
if (streamInfo == null) {
56+
return -1;
57+
}
5558
return streamInfo.getServiceId();
5659
}
5760

@@ -76,13 +79,17 @@ public List<String> getTags() {
7679
@Override
7780
protected void setupMetadata(final LayoutInflater inflater,
7881
final LinearLayout layout) {
79-
if (streamInfo.getUploadDate() != null) {
82+
if (streamInfo != null && streamInfo.getUploadDate() != null) {
8083
binding.detailUploadDateView.setText(Localization
8184
.localizeUploadDate(activity, streamInfo.getUploadDate().offsetDateTime()));
8285
} else {
8386
binding.detailUploadDateView.setVisibility(View.GONE);
8487
}
8588

89+
if (streamInfo == null) {
90+
return;
91+
}
92+
8693
addMetadataItem(inflater, layout, false, R.string.metadata_category,
8794
streamInfo.getCategory());
8895

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,6 @@ public void handleResult(@NonNull final L result) {
233233
showListFooter(hasMoreItems());
234234
} else {
235235
infoListAdapter.clearStreamItemList();
236-
// showEmptyState should be called only if there is no item as
237-
// well as no header in infoListAdapter
238236
showEmptyState();
239237
}
240238
}

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ protected StreamingService getService() {
6262

6363
@Override
6464
protected int getServiceId() {
65+
if (channelInfo == null) {
66+
return -1;
67+
}
6568
return channelInfo.getServiceId();
6669
}
6770

@@ -83,10 +86,14 @@ public List<String> getTags() {
8386
@Override
8487
protected void setupMetadata(final LayoutInflater inflater,
8588
final LinearLayout layout) {
86-
final Context context = getContext();
8789
// There is no upload date available for channels, so hide the relevant UI element
8890
binding.detailUploadDateView.setVisibility(View.GONE);
8991

92+
if (channelInfo == null) {
93+
return;
94+
}
95+
96+
final Context context = getContext();
9097
if (channelInfo.getSubscriberCount() != UNKNOWN_SUBSCRIBER_COUNT) {
9198
addMetadataItem(inflater, layout, false, R.string.metadata_subscribers,
9299
Localization.localizeNumber(context, channelInfo.getSubscriberCount()));

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public void onCreate(final Bundle savedInstanceState) {
125125
}
126126

127127
@Override
128-
public void onAttach(final @NonNull Context context) {
128+
public void onAttach(@NonNull final Context context) {
129129
super.onAttach(context);
130130
subscriptionManager = new SubscriptionManager(activity);
131131
}
@@ -138,7 +138,7 @@ public View onCreateView(@NonNull final LayoutInflater inflater,
138138
return binding.getRoot();
139139
}
140140

141-
@Override // called from onViewCreated in {@link BaseFragment#onViewCreated}
141+
@Override // called from onViewCreated in BaseFragment.onViewCreated
142142
protected void initViews(final View rootView, final Bundle savedInstanceState) {
143143
super.initViews(rootView, savedInstanceState);
144144

@@ -202,15 +202,15 @@ public void onCreateOptionsMenu(@NonNull final Menu menu,
202202
}
203203

204204
@Override
205-
public void onPrepareOptionsMenu(final @NonNull Menu menu) {
205+
public void onPrepareOptionsMenu(@NonNull final Menu menu) {
206206
super.onPrepareOptionsMenu(menu);
207207
menuRssButton = menu.findItem(R.id.menu_item_rss);
208208
menuNotifyButton = menu.findItem(R.id.menu_item_notify);
209209
updateNotifyButton(channelSubscription);
210210
}
211211

212212
@Override
213-
public boolean onOptionsItemSelected(final MenuItem item) {
213+
public boolean onOptionsItemSelected(@NonNull final MenuItem item) {
214214
switch (item.getItemId()) {
215215
case R.id.menu_item_notify:
216216
final boolean value = !item.isChecked();
@@ -561,8 +561,8 @@ private void runWorker(final boolean forceLoad) {
561561
.subscribe(result -> {
562562
isLoading.set(false);
563563
handleResult(result);
564-
}, throwable -> showError(new ErrorInfo(throwable, UserAction.REQUESTED_STREAM,
565-
url == null ? "no url" : url, serviceId)));
564+
}, throwable -> showError(new ErrorInfo(throwable, UserAction.REQUESTED_CHANNEL,
565+
url == null ? "No URL" : url, serviceId)));
566566
}
567567

568568
@Override

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,15 @@
3434
public class ChannelTabFragment extends BaseListInfoFragment<InfoItem, ChannelTabInfo>
3535
implements PlaylistControlViewHolder {
3636

37+
// states must be protected and not private for IcePick being able to access them
3738
@State
3839
protected ListLinkHandler tabHandler;
3940
@State
4041
protected String channelName;
4142

4243
private PlaylistControlBinding playlistControlBinding;
44+
45+
@NonNull
4346
public static ChannelTabFragment getInstance(final int serviceId,
4447
final ListLinkHandler tabHandler,
4548
final String channelName) {
@@ -99,11 +102,16 @@ protected Single<ListExtractor.InfoItemsPage<InfoItem>> loadMoreItemsLogic() {
99102

100103
@Override
101104
public void setTitle(final String title) {
105+
// The channel name is displayed as title in the toolbar.
106+
// The title is always a description of the content of the tab fragment.
107+
// It should be unique for each channel because multiple channel tabs
108+
// can be added to the main page. Therefore, the channel name is used.
109+
// Using the title variable would cause the title to be the same for all channel tabs.
102110
super.setTitle(channelName);
103111
}
104112

105113
@Override
106-
public void handleResult(final @NonNull ChannelTabInfo result) {
114+
public void handleResult(@NonNull final ChannelTabInfo result) {
107115
super.handleResult(result);
108116

109117
if (playlistControlBinding != null) {

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,5 @@
77
* to give access to the play queue.
88
*/
99
public interface PlaylistControlViewHolder {
10-
1110
PlayQueue getPlayQueue();
12-
1311
}

app/src/main/java/org/schabi/newpipe/local/feed/service/FeedLoadManager.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,7 @@ class FeedLoadManager(private val context: Context) {
140140
subscriptionEntity: SubscriptionEntity,
141141
useFeedExtractor: Boolean,
142142
defaultSharedPreferences: SharedPreferences
143-
):
144-
Notification<FeedUpdateInfo> {
143+
): Notification<FeedUpdateInfo> {
145144
var error: Throwable? = null
146145
val storeOriginalErrorAndRethrow = { e: Throwable ->
147146
// keep original to prevent blockingGet() from wrapping it into RuntimeException

app/src/main/java/org/schabi/newpipe/player/playqueue/AbstractInfoPlayQueue.java

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,12 @@ abstract class AbstractInfoPlayQueue<T extends ListInfo<? extends InfoItem>>
2929

3030
protected AbstractInfoPlayQueue(final T info) {
3131
this(info.getServiceId(), info.getUrl(), info.getNextPage(),
32-
info.getRelatedItems().stream().filter(StreamInfoItem.class::isInstance)
33-
.map(StreamInfoItem.class::cast).collect(
34-
Collectors.toList()), 0);
32+
info.getRelatedItems()
33+
.stream()
34+
.filter(StreamInfoItem.class::isInstance)
35+
.map(StreamInfoItem.class::cast)
36+
.collect(Collectors.toList()),
37+
0);
3538
}
3639

3740
protected AbstractInfoPlayQueue(final int serviceId,
@@ -76,10 +79,11 @@ public void onSuccess(@NonNull final T result) {
7679
}
7780
nextPage = result.getNextPage();
7881

79-
append(extractListItems(result.getRelatedItems().stream()
82+
append(extractListItems(result.getRelatedItems()
83+
.stream()
8084
.filter(StreamInfoItem.class::isInstance)
81-
.map(StreamInfoItem.class::cast).collect(
82-
Collectors.toList())));
85+
.map(StreamInfoItem.class::cast)
86+
.collect(Collectors.toList())));
8387

8488
fetchReactor.dispose();
8589
fetchReactor = null;
@@ -114,10 +118,11 @@ public void onSuccess(
114118
}
115119
nextPage = result.getNextPage();
116120

117-
append(extractListItems(result.getItems().stream()
121+
append(extractListItems(result.getItems()
122+
.stream()
118123
.filter(StreamInfoItem.class::isInstance)
119-
.map(StreamInfoItem.class::cast).collect(
120-
Collectors.toList())));
124+
.map(StreamInfoItem.class::cast)
125+
.collect(Collectors.toList())));
121126

122127
fetchReactor.dispose();
123128
fetchReactor = null;

app/src/main/java/org/schabi/newpipe/util/ExtractorHelper.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,10 @@ public static Single<ChannelTabInfo> getChannelTab(final int serviceId,
135135
ChannelTabInfo.getInfo(NewPipe.getService(serviceId), listLinkHandler)));
136136
}
137137

138-
public static Single<InfoItemsPage<InfoItem>> getMoreChannelTabItems(final int serviceId,
139-
final ListLinkHandler
140-
listLinkHandler,
141-
final Page nextPage) {
138+
public static Single<InfoItemsPage<InfoItem>> getMoreChannelTabItems(
139+
final int serviceId,
140+
final ListLinkHandler listLinkHandler,
141+
final Page nextPage) {
142142
checkServiceId(serviceId);
143143
return Single.fromCallable(() ->
144144
ChannelTabInfo.getMoreItems(NewPipe.getService(serviceId),

0 commit comments

Comments
 (0)