mirror of
https://github.com/KokaKiwi/BarInsta
synced 2024-11-08 07:57:28 +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.Utils;
|
||||||
import awais.instagrabber.utils.emoji.EmojiParser;
|
import awais.instagrabber.utils.emoji.EmojiParser;
|
||||||
import awais.instagrabber.viewmodels.AppStateViewModel;
|
import awais.instagrabber.viewmodels.AppStateViewModel;
|
||||||
import zerrium.FilterKeywordsUtility;
|
|
||||||
|
|
||||||
import static awais.instagrabber.utils.NavigationExtensions.setupWithNavController;
|
import static awais.instagrabber.utils.NavigationExtensions.setupWithNavController;
|
||||||
import static awais.instagrabber.utils.Utils.settingsHelper;
|
import static awais.instagrabber.utils.Utils.settingsHelper;
|
||||||
@ -178,15 +177,6 @@ public class MainActivity extends BaseLanguageActivity implements FragmentManage
|
|||||||
});
|
});
|
||||||
initEmojiCompat();
|
initEmojiCompat();
|
||||||
// initDmService();
|
// 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() {
|
private void initDmService() {
|
||||||
|
@ -5,14 +5,13 @@ import java.util.List;
|
|||||||
|
|
||||||
import awais.instagrabber.customviews.helpers.PostFetcher;
|
import awais.instagrabber.customviews.helpers.PostFetcher;
|
||||||
import awais.instagrabber.interfaces.FetchListener;
|
import awais.instagrabber.interfaces.FetchListener;
|
||||||
import awais.instagrabber.repositories.responses.Caption;
|
|
||||||
import awais.instagrabber.repositories.responses.Media;
|
import awais.instagrabber.repositories.responses.Media;
|
||||||
import awais.instagrabber.repositories.responses.PostsFetchResponse;
|
import awais.instagrabber.repositories.responses.PostsFetchResponse;
|
||||||
import awais.instagrabber.utils.Constants;
|
import awais.instagrabber.utils.Constants;
|
||||||
import awais.instagrabber.utils.CookieUtils;
|
import awais.instagrabber.utils.CookieUtils;
|
||||||
import awais.instagrabber.webservices.FeedService;
|
import awais.instagrabber.webservices.FeedService;
|
||||||
import awais.instagrabber.webservices.ServiceCallback;
|
import awais.instagrabber.webservices.ServiceCallback;
|
||||||
import zerrium.FilterKeywordsUtility;
|
import awais.instagrabber.utils.KeywordsFilterUtils;
|
||||||
|
|
||||||
import static awais.instagrabber.utils.Utils.settingsHelper;
|
import static awais.instagrabber.utils.Utils.settingsHelper;
|
||||||
|
|
||||||
@ -43,18 +42,15 @@ public class FeedPostFetchService implements PostFetcher.PostFetchService {
|
|||||||
nextCursor = result.getNextCursor();
|
nextCursor = result.getNextCursor();
|
||||||
hasNextPage = result.hasNextPage();
|
hasNextPage = result.hasNextPage();
|
||||||
|
|
||||||
//Skip adding (junk) post to Feed models
|
//Check caption if it doesn't contain any specified keywords in filter_keywords.xml
|
||||||
for(final Media m:result.getFeedModels()){
|
List<Media> mediaResults = result.getFeedModels();
|
||||||
final Caption c = m.getCaption();
|
if(!settingsHelper.getBoolean(Constants.TOGGLE_KEYWORD_FILTER)){
|
||||||
if(c == null){
|
feedModels.addAll(mediaResults);
|
||||||
feedModels.add(m); //No caption
|
}else{
|
||||||
continue;
|
ArrayList<String> items = new ArrayList<>(settingsHelper.getStringSet(Constants.KEYWORD_FILTERS));
|
||||||
}
|
feedModels.addAll(new KeywordsFilterUtils(items).filter(mediaResults));
|
||||||
if(!FilterKeywordsUtility.filter(c.getText())){ //Check caption if it doesn't contain any specified keywords in filter_keywords.xml
|
|
||||||
feedModels.add(m);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
//feedModels.addAll(result.getFeedModels());
|
|
||||||
if (fetchListener != null) {
|
if (fetchListener != null) {
|
||||||
// if (feedModels.size() < 15 && hasNextPage) {
|
// if (feedModels.size() < 15 && hasNextPage) {
|
||||||
// feedService.fetch(csrfToken, nextCursor, this);
|
// feedService.fetch(csrfToken, nextCursor, this);
|
||||||
|
Loading…
Reference in New Issue
Block a user