mirror of
https://github.com/revanced/revanced-integrations.git
synced 2025-01-05 17:45:49 +01:00
feat(reddit): add hide-promoted
patch (#419)
Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
This commit is contained in:
parent
aa72125317
commit
7eb209d853
@ -0,0 +1,26 @@
|
||||
package app.revanced.reddit.patches;
|
||||
|
||||
import com.reddit.domain.model.ILink;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public final class FilterPromotedLinksPatch {
|
||||
/**
|
||||
* Filters list from promoted links.
|
||||
**/
|
||||
public static List<?> filterChildren(final Iterable<?> links) {
|
||||
final List<Object> filteredList = new ArrayList<>();
|
||||
|
||||
for (Object item : links) {
|
||||
if (!(item instanceof ILink)) continue;
|
||||
|
||||
final var link = (ILink) item;
|
||||
final var isPromotedAd = link.getPromoted();
|
||||
|
||||
if (!isPromotedAd) filteredList.add(item);
|
||||
}
|
||||
|
||||
return filteredList;
|
||||
}
|
||||
}
|
7
dummy/src/main/java/com/reddit/domain/model/ILink.java
Normal file
7
dummy/src/main/java/com/reddit/domain/model/ILink.java
Normal file
@ -0,0 +1,7 @@
|
||||
package com.reddit.domain.model;
|
||||
|
||||
public class ILink {
|
||||
public boolean getPromoted() {
|
||||
throw new UnsupportedOperationException("Stub");
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user