Skip to content

Commit 5be40f6

Browse files
authored
Merge pull request #7904 from Stypox/fix-raw-use-of-parameterized-class
Solve Java warning "Raw use of parameterized class"
2 parents fb75519 + 4789cf6 commit 5be40f6

15 files changed

Lines changed: 85 additions & 89 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ public void held(final StreamInfoItem selectedItem) {
272272
}
273273
});
274274

275-
infoListAdapter.setOnChannelSelectedListener(new OnClickGesture<ChannelInfoItem>() {
275+
infoListAdapter.setOnChannelSelectedListener(new OnClickGesture<>() {
276276
@Override
277277
public void selected(final ChannelInfoItem selectedItem) {
278278
try {
@@ -288,7 +288,7 @@ public void selected(final ChannelInfoItem selectedItem) {
288288
}
289289
});
290290

291-
infoListAdapter.setOnPlaylistSelectedListener(new OnClickGesture<PlaylistInfoItem>() {
291+
infoListAdapter.setOnPlaylistSelectedListener(new OnClickGesture<>() {
292292
@Override
293293
public void selected(final PlaylistInfoItem selectedItem) {
294294
try {

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

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import org.schabi.newpipe.error.ErrorInfo;
1111
import org.schabi.newpipe.error.UserAction;
12+
import org.schabi.newpipe.extractor.InfoItem;
1213
import org.schabi.newpipe.extractor.ListExtractor;
1314
import org.schabi.newpipe.extractor.ListInfo;
1415
import org.schabi.newpipe.extractor.Page;
@@ -27,8 +28,8 @@
2728
import io.reactivex.rxjava3.disposables.Disposable;
2829
import io.reactivex.rxjava3.schedulers.Schedulers;
2930

30-
public abstract class BaseListInfoFragment<I extends ListInfo>
31-
extends BaseListFragment<I, ListExtractor.InfoItemsPage> {
31+
public abstract class BaseListInfoFragment<I extends InfoItem, L extends ListInfo<I>>
32+
extends BaseListFragment<L, ListExtractor.InfoItemsPage<I>> {
3233
@State
3334
protected int serviceId = Constants.NO_SERVICE_ID;
3435
@State
@@ -37,7 +38,7 @@ public abstract class BaseListInfoFragment<I extends ListInfo>
3738
protected String url;
3839

3940
private final UserAction errorUserAction;
40-
protected I currentInfo;
41+
protected L currentInfo;
4142
protected Page currentNextPage;
4243
protected Disposable currentWorker;
4344

@@ -97,7 +98,7 @@ public void writeTo(final Queue<Object> objectsToSave) {
9798
@SuppressWarnings("unchecked")
9899
public void readFrom(@NonNull final Queue<Object> savedObjects) throws Exception {
99100
super.readFrom(savedObjects);
100-
currentInfo = (I) savedObjects.poll();
101+
currentInfo = (L) savedObjects.poll();
101102
currentNextPage = (Page) savedObjects.poll();
102103
}
103104

@@ -124,7 +125,7 @@ protected void doInitialLoadLogic() {
124125
* @param forceLoad allow or disallow the result to come from the cache
125126
* @return Rx {@link Single} containing the {@link ListInfo}
126127
*/
127-
protected abstract Single<I> loadResult(boolean forceLoad);
128+
protected abstract Single<L> loadResult(boolean forceLoad);
128129

129130
@Override
130131
public void startLoading(final boolean forceLoad) {
@@ -140,7 +141,7 @@ public void startLoading(final boolean forceLoad) {
140141
currentWorker = loadResult(forceLoad)
141142
.subscribeOn(Schedulers.io())
142143
.observeOn(AndroidSchedulers.mainThread())
143-
.subscribe((@NonNull I result) -> {
144+
.subscribe((@NonNull L result) -> {
144145
isLoading.set(false);
145146
currentInfo = result;
146147
currentNextPage = result.getNextPage();
@@ -157,7 +158,7 @@ public void startLoading(final boolean forceLoad) {
157158
*
158159
* @return Rx {@link Single} containing the {@link ListExtractor.InfoItemsPage}
159160
*/
160-
protected abstract Single<ListExtractor.InfoItemsPage> loadMoreItemsLogic();
161+
protected abstract Single<ListExtractor.InfoItemsPage<I>> loadMoreItemsLogic();
161162

162163
@Override
163164
protected void loadMoreItems() {
@@ -194,7 +195,7 @@ private void allowDownwardFocusScroll() {
194195
}
195196

196197
@Override
197-
public void handleNextItems(final ListExtractor.InfoItemsPage result) {
198+
public void handleNextItems(final ListExtractor.InfoItemsPage<I> result) {
198199
super.handleNextItems(result);
199200

200201
currentNextPage = result.getNextPage();
@@ -218,7 +219,7 @@ protected boolean hasMoreItems() {
218219
//////////////////////////////////////////////////////////////////////////*/
219220

220221
@Override
221-
public void handleResult(@NonNull final I result) {
222+
public void handleResult(@NonNull final L result) {
222223
super.handleResult(result);
223224

224225
name = result.getName();

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
import io.reactivex.rxjava3.functions.Function;
6565
import io.reactivex.rxjava3.schedulers.Schedulers;
6666

67-
public class ChannelFragment extends BaseListInfoFragment<ChannelInfo>
67+
public class ChannelFragment extends BaseListInfoFragment<StreamInfoItem, ChannelInfo>
6868
implements View.OnClickListener {
6969

7070
private static final int BUTTON_DEBOUNCE_INTERVAL = 100;
@@ -374,7 +374,7 @@ private void updateSubscribeButton(final boolean isSubscribed) {
374374
//////////////////////////////////////////////////////////////////////////*/
375375

376376
@Override
377-
protected Single<ListExtractor.InfoItemsPage> loadMoreItemsLogic() {
377+
protected Single<ListExtractor.InfoItemsPage<StreamInfoItem>> loadMoreItemsLogic() {
378378
return ExtractorHelper.getMoreChannelItems(serviceId, url, currentNextPage);
379379
}
380380

app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentsFragment.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,15 @@
1515
import org.schabi.newpipe.error.UserAction;
1616
import org.schabi.newpipe.extractor.ListExtractor;
1717
import org.schabi.newpipe.extractor.comments.CommentsInfo;
18+
import org.schabi.newpipe.extractor.comments.CommentsInfoItem;
1819
import org.schabi.newpipe.fragments.list.BaseListInfoFragment;
1920
import org.schabi.newpipe.ktx.ViewUtils;
2021
import org.schabi.newpipe.util.ExtractorHelper;
2122

2223
import io.reactivex.rxjava3.core.Single;
2324
import io.reactivex.rxjava3.disposables.CompositeDisposable;
2425

25-
public class CommentsFragment extends BaseListInfoFragment<CommentsInfo> {
26+
public class CommentsFragment extends BaseListInfoFragment<CommentsInfoItem, CommentsInfo> {
2627
private final CompositeDisposable disposables = new CompositeDisposable();
2728

2829
private TextView emptyStateDesc;
@@ -67,7 +68,7 @@ public void onDestroy() {
6768
//////////////////////////////////////////////////////////////////////////*/
6869

6970
@Override
70-
protected Single<ListExtractor.InfoItemsPage> loadMoreItemsLogic() {
71+
protected Single<ListExtractor.InfoItemsPage<CommentsInfoItem>> loadMoreItemsLogic() {
7172
return ExtractorHelper.getMoreCommentItems(serviceId, currentInfo, currentNextPage);
7273
}
7374

app/src/main/java/org/schabi/newpipe/fragments/list/kiosk/KioskFragment.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import org.schabi.newpipe.extractor.kiosk.KioskInfo;
2222
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandlerFactory;
2323
import org.schabi.newpipe.extractor.localization.ContentCountry;
24+
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
2425
import org.schabi.newpipe.fragments.list.BaseListInfoFragment;
2526
import org.schabi.newpipe.util.ExtractorHelper;
2627
import org.schabi.newpipe.util.KioskTranslator;
@@ -53,7 +54,7 @@
5354
* </p>
5455
*/
5556

56-
public class KioskFragment extends BaseListInfoFragment<KioskInfo> {
57+
public class KioskFragment extends BaseListInfoFragment<StreamInfoItem, KioskInfo> {
5758
@State
5859
String kioskId = "";
5960
String kioskTranslatedName;
@@ -145,7 +146,7 @@ public Single<KioskInfo> loadResult(final boolean forceReload) {
145146
}
146147

147148
@Override
148-
public Single<ListExtractor.InfoItemsPage> loadMoreItemsLogic() {
149+
public Single<ListExtractor.InfoItemsPage<StreamInfoItem>> loadMoreItemsLogic() {
149150
return ExtractorHelper.getMoreKioskItems(serviceId, url, currentNextPage);
150151
}
151152

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
import io.reactivex.rxjava3.disposables.CompositeDisposable;
7070
import io.reactivex.rxjava3.disposables.Disposable;
7171

72-
public class PlaylistFragment extends BaseListInfoFragment<PlaylistInfo> {
72+
public class PlaylistFragment extends BaseListInfoFragment<StreamInfoItem, PlaylistInfo> {
7373

7474
private static final String PICASSO_PLAYLIST_TAG = "PICASSO_PLAYLIST_TAG";
7575

@@ -254,7 +254,7 @@ public void onDestroy() {
254254
//////////////////////////////////////////////////////////////////////////*/
255255

256256
@Override
257-
protected Single<ListExtractor.InfoItemsPage> loadMoreItemsLogic() {
257+
protected Single<ListExtractor.InfoItemsPage<StreamInfoItem>> loadMoreItemsLogic() {
258258
return ExtractorHelper.getMorePlaylistItems(serviceId, url, currentNextPage);
259259
}
260260

app/src/main/java/org/schabi/newpipe/fragments/list/videos/RelatedItemsFragment.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import org.schabi.newpipe.R;
1616
import org.schabi.newpipe.databinding.RelatedItemsHeaderBinding;
1717
import org.schabi.newpipe.error.UserAction;
18+
import org.schabi.newpipe.extractor.InfoItem;
1819
import org.schabi.newpipe.extractor.ListExtractor;
1920
import org.schabi.newpipe.extractor.stream.StreamInfo;
2021
import org.schabi.newpipe.fragments.list.BaseListInfoFragment;
@@ -26,7 +27,7 @@
2627

2728
import io.reactivex.rxjava3.core.Single;
2829

29-
public class RelatedItemsFragment extends BaseListInfoFragment<RelatedItemInfo>
30+
public class RelatedItemsFragment extends BaseListInfoFragment<InfoItem, RelatedItemInfo>
3031
implements SharedPreferences.OnSharedPreferenceChangeListener {
3132
private static final String INFO_KEY = "related_info_key";
3233

@@ -86,7 +87,7 @@ protected Supplier<View> getListHeaderSupplier() {
8687
}
8788

8889
@Override
89-
protected Single<ListExtractor.InfoItemsPage> loadMoreItemsLogic() {
90+
protected Single<ListExtractor.InfoItemsPage<InfoItem>> loadMoreItemsLogic() {
9091
return Single.fromCallable(ListExtractor.InfoItemsPage::emptyPage);
9192
}
9293

app/src/main/java/org/schabi/newpipe/local/subscription/services/ImportExportJsonHelper.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import com.grack.nanojson.JsonArray;
2626
import com.grack.nanojson.JsonObject;
2727
import com.grack.nanojson.JsonParser;
28-
import com.grack.nanojson.JsonSink;
2928
import com.grack.nanojson.JsonWriter;
3029

3130
import org.schabi.newpipe.BuildConfig;
@@ -125,10 +124,11 @@ public static void writeTo(final List<SubscriptionItem> items, final OutputStrea
125124
/**
126125
* @see #writeTo(List, OutputStream, ImportExportEventListener)
127126
* @param items the list of subscriptions items
128-
* @param writer the output {@link JsonSink}
127+
* @param writer the output {@link JsonAppendableWriter}
129128
* @param eventListener listener for the events generated
130129
*/
131-
public static void writeTo(final List<SubscriptionItem> items, final JsonSink writer,
130+
public static void writeTo(final List<SubscriptionItem> items,
131+
final JsonAppendableWriter writer,
132132
@Nullable final ImportExportEventListener eventListener) {
133133
if (eventListener != null) {
134134
eventListener.onSizeReceived(items.size());

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

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,19 @@
44

55
import androidx.annotation.NonNull;
66

7-
import org.schabi.newpipe.extractor.InfoItem;
87
import org.schabi.newpipe.extractor.ListExtractor;
98
import org.schabi.newpipe.extractor.ListInfo;
109
import org.schabi.newpipe.extractor.Page;
1110
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
1211

13-
import java.util.ArrayList;
14-
import java.util.Collections;
1512
import java.util.List;
13+
import java.util.stream.Collectors;
1614

1715
import io.reactivex.rxjava3.core.SingleObserver;
1816
import io.reactivex.rxjava3.disposables.Disposable;
1917

20-
abstract class AbstractInfoPlayQueue<T extends ListInfo, U extends InfoItem> extends PlayQueue {
18+
abstract class AbstractInfoPlayQueue<T extends ListInfo<StreamInfoItem>>
19+
extends PlayQueue {
2120
boolean isInitial;
2221
private boolean isComplete;
2322

@@ -27,12 +26,15 @@ abstract class AbstractInfoPlayQueue<T extends ListInfo, U extends InfoItem> ext
2726

2827
private transient Disposable fetchReactor;
2928

30-
AbstractInfoPlayQueue(final U item) {
31-
this(item.getServiceId(), item.getUrl(), null, Collections.emptyList(), 0);
29+
protected AbstractInfoPlayQueue(final T info) {
30+
this(info.getServiceId(), info.getUrl(), info.getNextPage(), info.getRelatedItems(), 0);
3231
}
3332

34-
AbstractInfoPlayQueue(final int serviceId, final String url, final Page nextPage,
35-
final List<StreamInfoItem> streams, final int index) {
33+
protected AbstractInfoPlayQueue(final int serviceId,
34+
final String url,
35+
final Page nextPage,
36+
final List<StreamInfoItem> streams,
37+
final int index) {
3638
super(index, extractListItems(streams));
3739

3840
this.baseUrl = url;
@@ -51,7 +53,7 @@ public boolean isComplete() {
5153
}
5254

5355
SingleObserver<T> getHeadListObserver() {
54-
return new SingleObserver<T>() {
56+
return new SingleObserver<>() {
5557
@Override
5658
public void onSubscribe(@NonNull final Disposable d) {
5759
if (isComplete || !isInitial || (fetchReactor != null
@@ -85,8 +87,8 @@ public void onError(@NonNull final Throwable e) {
8587
};
8688
}
8789

88-
SingleObserver<ListExtractor.InfoItemsPage> getNextPageObserver() {
89-
return new SingleObserver<ListExtractor.InfoItemsPage>() {
90+
SingleObserver<ListExtractor.InfoItemsPage<StreamInfoItem>> getNextPageObserver() {
91+
return new SingleObserver<>() {
9092
@Override
9193
public void onSubscribe(@NonNull final Disposable d) {
9294
if (isComplete || isInitial || (fetchReactor != null
@@ -98,7 +100,8 @@ public void onSubscribe(@NonNull final Disposable d) {
98100
}
99101

100102
@Override
101-
public void onSuccess(@NonNull final ListExtractor.InfoItemsPage result) {
103+
public void onSuccess(
104+
@NonNull final ListExtractor.InfoItemsPage<StreamInfoItem> result) {
102105
if (!result.hasNextPage()) {
103106
isComplete = true;
104107
}
@@ -129,12 +132,6 @@ public void dispose() {
129132
}
130133

131134
private static List<PlayQueueItem> extractListItems(final List<StreamInfoItem> infoItems) {
132-
final List<PlayQueueItem> result = new ArrayList<>();
133-
for (final InfoItem stream : infoItems) {
134-
if (stream instanceof StreamInfoItem) {
135-
result.add(new PlayQueueItem((StreamInfoItem) stream));
136-
}
137-
}
138-
return result;
135+
return infoItems.stream().map(PlayQueueItem::new).collect(Collectors.toList());
139136
}
140137
}

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
import org.schabi.newpipe.extractor.Page;
55
import org.schabi.newpipe.extractor.channel.ChannelInfo;
6-
import org.schabi.newpipe.extractor.channel.ChannelInfoItem;
76
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
87
import org.schabi.newpipe.util.ExtractorHelper;
98

@@ -12,13 +11,10 @@
1211
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
1312
import io.reactivex.rxjava3.schedulers.Schedulers;
1413

15-
public final class ChannelPlayQueue extends AbstractInfoPlayQueue<ChannelInfo, ChannelInfoItem> {
16-
public ChannelPlayQueue(final ChannelInfoItem item) {
17-
super(item);
18-
}
14+
public final class ChannelPlayQueue extends AbstractInfoPlayQueue<ChannelInfo> {
1915

2016
public ChannelPlayQueue(final ChannelInfo info) {
21-
this(info.getServiceId(), info.getUrl(), info.getNextPage(), info.getRelatedItems(), 0);
17+
super(info);
2218
}
2319

2420
public ChannelPlayQueue(final int serviceId,

0 commit comments

Comments
 (0)