diff --git a/app/src/main/java/app/revanced/reddit/patches/FilterPromotedLinksPatch.java b/app/src/main/java/app/revanced/reddit/patches/FilterPromotedLinksPatch.java new file mode 100644 index 00000000..5c9d3207 --- /dev/null +++ b/app/src/main/java/app/revanced/reddit/patches/FilterPromotedLinksPatch.java @@ -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 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; + } +} diff --git a/dummy/src/main/java/com/reddit/domain/model/ILink.java b/dummy/src/main/java/com/reddit/domain/model/ILink.java new file mode 100644 index 00000000..f9cbb955 --- /dev/null +++ b/dummy/src/main/java/com/reddit/domain/model/ILink.java @@ -0,0 +1,7 @@ +package com.reddit.domain.model; + +public class ILink { + public boolean getPromoted() { + throw new UnsupportedOperationException("Stub"); + } +}