Skip to content

Commit 7d89043

Browse files
committed
Solve Java warning "Raw use of parameterized class"
1 parent af80d96 commit 7d89043

File tree

13 files changed

+66
-60
lines changed

13 files changed

+66
-60
lines changed

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

+2-2
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

+10-9
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

+2-2
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

+3-2
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

+3-2
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

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
import io.reactivex.rxjava3.disposables.CompositeDisposable;
6565
import io.reactivex.rxjava3.disposables.Disposable;
6666

67-
public class PlaylistFragment extends BaseListInfoFragment<PlaylistInfo> {
67+
public class PlaylistFragment extends BaseListInfoFragment<StreamInfoItem, PlaylistInfo> {
6868

6969
private static final String PICASSO_PLAYLIST_TAG = "PICASSO_PLAYLIST_TAG";
7070

@@ -249,7 +249,7 @@ public void onDestroy() {
249249
//////////////////////////////////////////////////////////////////////////*/
250250

251251
@Override
252-
protected Single<ListExtractor.InfoItemsPage> loadMoreItemsLogic() {
252+
protected Single<ListExtractor.InfoItemsPage<StreamInfoItem>> loadMoreItemsLogic() {
253253
return ExtractorHelper.getMorePlaylistItems(serviceId, url, currentNextPage);
254254
}
255255

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

+3-2
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

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public static void writeTo(final List<SubscriptionItem> items, final OutputStrea
128128
* @param writer the output {@link JsonSink}
129129
* @param eventListener listener for the events generated
130130
*/
131-
public static void writeTo(final List<SubscriptionItem> items, final JsonSink writer,
131+
public static void writeTo(final List<SubscriptionItem> items, final JsonSink<?> 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

+9-9
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
import io.reactivex.rxjava3.core.SingleObserver;
1818
import io.reactivex.rxjava3.disposables.Disposable;
1919

20-
abstract class AbstractInfoPlayQueue<T extends ListInfo, U extends InfoItem> extends PlayQueue {
20+
abstract class AbstractInfoPlayQueue<T extends ListInfo<StreamInfoItem>, U extends InfoItem>
21+
extends PlayQueue {
2122
boolean isInitial;
2223
private boolean isComplete;
2324

@@ -51,7 +52,7 @@ public boolean isComplete() {
5152
}
5253

5354
SingleObserver<T> getHeadListObserver() {
54-
return new SingleObserver<T>() {
55+
return new SingleObserver<>() {
5556
@Override
5657
public void onSubscribe(@NonNull final Disposable d) {
5758
if (isComplete || !isInitial || (fetchReactor != null
@@ -85,8 +86,8 @@ public void onError(@NonNull final Throwable e) {
8586
};
8687
}
8788

88-
SingleObserver<ListExtractor.InfoItemsPage> getNextPageObserver() {
89-
return new SingleObserver<ListExtractor.InfoItemsPage>() {
89+
SingleObserver<ListExtractor.InfoItemsPage<StreamInfoItem>> getNextPageObserver() {
90+
return new SingleObserver<>() {
9091
@Override
9192
public void onSubscribe(@NonNull final Disposable d) {
9293
if (isComplete || isInitial || (fetchReactor != null
@@ -98,7 +99,8 @@ public void onSubscribe(@NonNull final Disposable d) {
9899
}
99100

100101
@Override
101-
public void onSuccess(@NonNull final ListExtractor.InfoItemsPage result) {
102+
public void onSuccess(
103+
@NonNull final ListExtractor.InfoItemsPage<StreamInfoItem> result) {
102104
if (!result.hasNextPage()) {
103105
isComplete = true;
104106
}
@@ -130,10 +132,8 @@ public void dispose() {
130132

131133
private static List<PlayQueueItem> extractListItems(final List<StreamInfoItem> infoItems) {
132134
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-
}
135+
for (final StreamInfoItem stream : infoItems) {
136+
result.add(new PlayQueueItem(stream));
137137
}
138138
return result;
139139
}

app/src/main/java/org/schabi/newpipe/settings/tabs/Tab.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public int hashCode() {
132132
// JSON Handling
133133
//////////////////////////////////////////////////////////////////////////*/
134134

135-
public void writeJsonOn(final JsonSink jsonSink) {
135+
public void writeJsonOn(final JsonSink<?> jsonSink) {
136136
jsonSink.object();
137137

138138
jsonSink.value(JSON_TAB_ID_KEY, getTabId());
@@ -141,7 +141,7 @@ public void writeJsonOn(final JsonSink jsonSink) {
141141
jsonSink.end();
142142
}
143143

144-
protected void writeDataToJson(final JsonSink writerSink) {
144+
protected void writeDataToJson(final JsonSink<?> writerSink) {
145145
// No-op
146146
}
147147

@@ -355,7 +355,7 @@ public KioskFragment getFragment(final Context context) throws ExtractionExcepti
355355
}
356356

357357
@Override
358-
protected void writeDataToJson(final JsonSink writerSink) {
358+
protected void writeDataToJson(final JsonSink<?> writerSink) {
359359
writerSink.value(JSON_KIOSK_SERVICE_ID_KEY, kioskServiceId)
360360
.value(JSON_KIOSK_ID_KEY, kioskId);
361361
}
@@ -437,7 +437,7 @@ public ChannelFragment getFragment(final Context context) {
437437
}
438438

439439
@Override
440-
protected void writeDataToJson(final JsonSink writerSink) {
440+
protected void writeDataToJson(final JsonSink<?> writerSink) {
441441
writerSink.value(JSON_CHANNEL_SERVICE_ID_KEY, channelServiceId)
442442
.value(JSON_CHANNEL_URL_KEY, channelUrl)
443443
.value(JSON_CHANNEL_NAME_KEY, channelName);
@@ -584,7 +584,7 @@ public Fragment getFragment(final Context context) {
584584
}
585585

586586
@Override
587-
protected void writeDataToJson(final JsonSink writerSink) {
587+
protected void writeDataToJson(final JsonSink<?> writerSink) {
588588
writerSink.value(JSON_PLAYLIST_SERVICE_ID_KEY, playlistServiceId)
589589
.value(JSON_PLAYLIST_URL_KEY, playlistUrl)
590590
.value(JSON_PLAYLIST_NAME_KEY, playlistName)

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

+17-11
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
import org.schabi.newpipe.MainActivity;
3232
import org.schabi.newpipe.R;
33+
import org.schabi.newpipe.extractor.comments.CommentsInfoItem;
3334
import org.schabi.newpipe.util.external_communication.TextLinkifier;
3435
import org.schabi.newpipe.extractor.Info;
3536
import org.schabi.newpipe.extractor.InfoItem;
@@ -84,7 +85,7 @@ public static Single<SearchInfo> searchFor(final int serviceId, final String sea
8485
.fromQuery(searchString, contentFilter, sortFilter)));
8586
}
8687

87-
public static Single<InfoItemsPage> getMoreSearchItems(final int serviceId,
88+
public static Single<InfoItemsPage<?>> getMoreSearchItems(final int serviceId,
8889
final String searchString,
8990
final List<String> contentFilter,
9091
final String sortFilter,
@@ -124,8 +125,9 @@ public static Single<ChannelInfo> getChannelInfo(final int serviceId, final Stri
124125
ChannelInfo.getInfo(NewPipe.getService(serviceId), url)));
125126
}
126127

127-
public static Single<InfoItemsPage> getMoreChannelItems(final int serviceId, final String url,
128-
final Page nextPage) {
128+
public static Single<InfoItemsPage<StreamInfoItem>> getMoreChannelItems(final int serviceId,
129+
final String url,
130+
final Page nextPage) {
129131
checkServiceId(serviceId);
130132
return Single.fromCallable(() ->
131133
ChannelInfo.getMoreItems(NewPipe.getService(serviceId), url, nextPage));
@@ -155,24 +157,27 @@ public static Single<CommentsInfo> getCommentsInfo(final int serviceId, final St
155157
CommentsInfo.getInfo(NewPipe.getService(serviceId), url)));
156158
}
157159

158-
public static Single<InfoItemsPage> getMoreCommentItems(final int serviceId,
159-
final CommentsInfo info,
160-
final Page nextPage) {
160+
public static Single<InfoItemsPage<CommentsInfoItem>> getMoreCommentItems(
161+
final int serviceId,
162+
final CommentsInfo info,
163+
final Page nextPage) {
161164
checkServiceId(serviceId);
162165
return Single.fromCallable(() ->
163166
CommentsInfo.getMoreItems(NewPipe.getService(serviceId), info, nextPage));
164167
}
165168

166-
public static Single<PlaylistInfo> getPlaylistInfo(final int serviceId, final String url,
169+
public static Single<PlaylistInfo> getPlaylistInfo(final int serviceId,
170+
final String url,
167171
final boolean forceLoad) {
168172
checkServiceId(serviceId);
169173
return checkCache(forceLoad, serviceId, url, InfoItem.InfoType.PLAYLIST,
170174
Single.fromCallable(() ->
171175
PlaylistInfo.getInfo(NewPipe.getService(serviceId), url)));
172176
}
173177

174-
public static Single<InfoItemsPage> getMorePlaylistItems(final int serviceId, final String url,
175-
final Page nextPage) {
178+
public static Single<InfoItemsPage<StreamInfoItem>> getMorePlaylistItems(final int serviceId,
179+
final String url,
180+
final Page nextPage) {
176181
checkServiceId(serviceId);
177182
return Single.fromCallable(() ->
178183
PlaylistInfo.getMoreItems(NewPipe.getService(serviceId), url, nextPage));
@@ -184,8 +189,9 @@ public static Single<KioskInfo> getKioskInfo(final int serviceId, final String u
184189
Single.fromCallable(() -> KioskInfo.getInfo(NewPipe.getService(serviceId), url)));
185190
}
186191

187-
public static Single<InfoItemsPage> getMoreKioskItems(final int serviceId, final String url,
188-
final Page nextPage) {
192+
public static Single<InfoItemsPage<StreamInfoItem>> getMoreKioskItems(final int serviceId,
193+
final String url,
194+
final Page nextPage) {
189195
return Single.fromCallable(() ->
190196
KioskInfo.getMoreItems(NewPipe.getService(serviceId), url, nextPage));
191197
}

0 commit comments

Comments
 (0)