From 8a835d4bd72eeb947843be69652c4beb30a6ee4f Mon Sep 17 00:00:00 2001 From: zerrium Date: Thu, 18 Mar 2021 14:03:38 +0700 Subject: [PATCH] Modified FeedPostFetchService to skip adding junk post to FeedModels --- .../asyncs/FeedPostFetchService.java | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/awais/instagrabber/asyncs/FeedPostFetchService.java b/app/src/main/java/awais/instagrabber/asyncs/FeedPostFetchService.java index b07b7b45..4ce0db13 100644 --- a/app/src/main/java/awais/instagrabber/asyncs/FeedPostFetchService.java +++ b/app/src/main/java/awais/instagrabber/asyncs/FeedPostFetchService.java @@ -1,16 +1,21 @@ package awais.instagrabber.asyncs; +import android.os.Build; +import android.util.Log; + import java.util.ArrayList; import java.util.List; import awais.instagrabber.customviews.helpers.PostFetcher; import awais.instagrabber.interfaces.FetchListener; +import awais.instagrabber.repositories.responses.Caption; import awais.instagrabber.repositories.responses.Media; import awais.instagrabber.repositories.responses.PostsFetchResponse; import awais.instagrabber.utils.Constants; import awais.instagrabber.utils.CookieUtils; import awais.instagrabber.webservices.FeedService; import awais.instagrabber.webservices.ServiceCallback; +import zerrium.FilterKeywords; import static awais.instagrabber.utils.Utils.settingsHelper; @@ -40,7 +45,20 @@ public class FeedPostFetchService implements PostFetcher.PostFetchService { } else if (result == null) return; nextCursor = result.getNextCursor(); hasNextPage = result.hasNextPage(); - feedModels.addAll(result.getFeedModels()); + + //Skip adding (junk) post to Feed models + for(Media m:result.getFeedModels()){ + Caption c = m.getCaption(); + if(c == null){ + feedModels.add(m); //No caption + continue; + } + if(!FilterKeywords.filter(c.getText())){ //Check caption if it doesn't contain any specified keywords in filter_keywords.xml + feedModels.add(m); + } + } + //Zerrium 18 March 2021 + //feedModels.addAll(result.getFeedModels()); if (fetchListener != null) { // if (feedModels.size() < 15 && hasNextPage) { // feedService.fetch(csrfToken, nextCursor, this);