Skip to content
This repository has been archived by the owner on Oct 26, 2024. It is now read-only.

refactor(Tumblr): Use a common filter patch #479

Merged
merged 5 commits into from
Oct 1, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package app.revanced.tumblr.patches;

import android.util.Log;

import com.tumblr.rumblr.model.TimelineObject;
import com.tumblr.rumblr.model.TimelineObjectType;
import com.tumblr.rumblr.model.Timelineable;

import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;

public class TimelineFilterPatch {
public static void filterTimeline(List<TimelineObject<? extends Timelineable>> timelineObjects) {
Iterator<TimelineObject<? extends Timelineable>> iterator = timelineObjects.iterator();
while (iterator.hasNext()) {
TimelineObject<? extends Timelineable> timelineElement = iterator.next();
if (timelineElement == null) continue;
String elementType = timelineElement.getData().getTimelineObjectType().toString();

// This dummy gets removed by the TimelineFilterPatch and in its place,
// equivalent instructions with a different constant string
// will be inserted for each Timeline object type filter.
if ("BLOCKED_OBJECT_DUMMY".equals(elementType)) iterator.remove();
leumasme marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.tumblr.rumblr.model;

public class TimelineObject<T extends Timelineable> {
public final T getData() {
throw new UnsupportedOperationException("Stub");
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.tumblr.rumblr.model;

public enum TimelineObjectType {
}
5 changes: 5 additions & 0 deletions dummy/src/main/java/com/tumblr/rumblr/model/Timelineable.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.tumblr.rumblr.model;

public interface Timelineable {
TimelineObjectType getTimelineObjectType();
}