mirror of
https://github.com/KokaKiwi/BarInsta
synced 2024-11-22 14:47:29 +00:00
Finishing touch for KeywordsFilter
This commit is contained in:
parent
a4c99568ef
commit
44358bbd31
@ -84,7 +84,6 @@ import awais.instagrabber.utils.TextUtils;
|
||||
import awais.instagrabber.utils.Utils;
|
||||
import awais.instagrabber.utils.emoji.EmojiParser;
|
||||
import awais.instagrabber.viewmodels.AppStateViewModel;
|
||||
import zerrium.FilterKeywordsUtility;
|
||||
|
||||
import static awais.instagrabber.utils.NavigationExtensions.setupWithNavController;
|
||||
import static awais.instagrabber.utils.Utils.settingsHelper;
|
||||
@ -178,15 +177,6 @@ public class MainActivity extends BaseLanguageActivity implements FragmentManage
|
||||
});
|
||||
initEmojiCompat();
|
||||
// initDmService();
|
||||
initZerriumFilter(); //to filter out junk instagram post
|
||||
}
|
||||
|
||||
private void initZerriumFilter(){
|
||||
try{
|
||||
FilterKeywordsUtility.insert(getResources().getStringArray(R.array.filter_keyword));
|
||||
}catch(Exception e){
|
||||
Log.e(TAG, "initZerriumFilter: " + e);
|
||||
}
|
||||
}
|
||||
|
||||
private void initDmService() {
|
||||
|
@ -5,14 +5,13 @@ 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.FilterKeywordsUtility;
|
||||
import awais.instagrabber.utils.KeywordsFilterUtils;
|
||||
|
||||
import static awais.instagrabber.utils.Utils.settingsHelper;
|
||||
|
||||
@ -43,18 +42,15 @@ public class FeedPostFetchService implements PostFetcher.PostFetchService {
|
||||
nextCursor = result.getNextCursor();
|
||||
hasNextPage = result.hasNextPage();
|
||||
|
||||
//Skip adding (junk) post to Feed models
|
||||
for(final Media m:result.getFeedModels()){
|
||||
final Caption c = m.getCaption();
|
||||
if(c == null){
|
||||
feedModels.add(m); //No caption
|
||||
continue;
|
||||
}
|
||||
if(!FilterKeywordsUtility.filter(c.getText())){ //Check caption if it doesn't contain any specified keywords in filter_keywords.xml
|
||||
feedModels.add(m);
|
||||
}
|
||||
//Check caption if it doesn't contain any specified keywords in filter_keywords.xml
|
||||
List<Media> mediaResults = result.getFeedModels();
|
||||
if(!settingsHelper.getBoolean(Constants.TOGGLE_KEYWORD_FILTER)){
|
||||
feedModels.addAll(mediaResults);
|
||||
}else{
|
||||
ArrayList<String> items = new ArrayList<>(settingsHelper.getStringSet(Constants.KEYWORD_FILTERS));
|
||||
feedModels.addAll(new KeywordsFilterUtils(items).filter(mediaResults));
|
||||
}
|
||||
//feedModels.addAll(result.getFeedModels());
|
||||
|
||||
if (fetchListener != null) {
|
||||
// if (feedModels.size() < 15 && hasNextPage) {
|
||||
// feedService.fetch(csrfToken, nextCursor, this);
|
||||
|
Loading…
Reference in New Issue
Block a user