1
0
mirror of https://github.com/KokaKiwi/BarInsta synced 2024-11-22 14:47:29 +00:00

Fixed warnings

This commit is contained in:
zerrium 2021-03-18 15:14:35 +07:00
parent 6202f876b1
commit 41d4bf313f
4 changed files with 15 additions and 21 deletions

View File

@ -115,7 +115,5 @@ dependencies {
implementation 'com.github.ammargitham:uCrop:2.3-native-beta-2'
implementation 'com.github.ammargitham:android-gpuimage:2.1.1-beta4'
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.6'
testImplementation 'org.junit.jupiter:junit-jupiter:5.7.1'
}

View File

@ -10,7 +10,6 @@ import android.content.Intent;
import android.content.ServiceConnection;
import android.content.res.TypedArray;
import android.database.MatrixCursor;
import android.net.IpSecManager;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
@ -84,7 +83,7 @@ import awais.instagrabber.utils.TextUtils;
import awais.instagrabber.utils.Utils;
import awais.instagrabber.utils.emoji.EmojiParser;
import awais.instagrabber.viewmodels.AppStateViewModel;
import zerrium.FilterKeywords;
import zerrium.FilterKeywordsUtility;
import static awais.instagrabber.utils.NavigationExtensions.setupWithNavController;
import static awais.instagrabber.utils.Utils.settingsHelper;
@ -180,14 +179,11 @@ public class MainActivity extends BaseLanguageActivity implements FragmentManage
}
private void initZerriumFilter(){
boolean filter_result = false;
try{
filter_result = FilterKeywords.insert(getResources().getStringArray(R.array.filter_keyword));
FilterKeywordsUtility.insert(getResources().getStringArray(R.array.filter_keyword));
}catch(Exception e){
Log.e(TAG, "initZerriumFilter: " + e);
}
if(!filter_result) Log.d(TAG, "ZerriumFilter insert failed");
else Log.d(TAG, "ZerriumFilter insert success");
}
private void initDmService() {

View File

@ -12,7 +12,7 @@ import awais.instagrabber.utils.Constants;
import awais.instagrabber.utils.CookieUtils;
import awais.instagrabber.webservices.FeedService;
import awais.instagrabber.webservices.ServiceCallback;
import zerrium.FilterKeywords;
import zerrium.FilterKeywordsUtility;
import static awais.instagrabber.utils.Utils.settingsHelper;
@ -44,17 +44,16 @@ public class FeedPostFetchService implements PostFetcher.PostFetchService {
hasNextPage = result.hasNextPage();
//Skip adding (junk) post to Feed models
for(Media m:result.getFeedModels()){
Caption c = m.getCaption();
for(final Media m:result.getFeedModels()){
final 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
if(!FilterKeywordsUtility.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) {

View File

@ -2,27 +2,28 @@ package zerrium;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Locale;
public class FilterKeywords {
public class FilterKeywordsUtility {
private static final ArrayList<String> FILTER_KEYWORDS = new ArrayList<>();
public static boolean append(String keyword){
public static boolean append(final String keyword){
if(keyword == null) return false;
FILTER_KEYWORDS.add(keyword);
return true;
}
public static boolean insert(String[] keywords){
public static boolean insert(final String[] keywords){
if(keywords == null) return false;
FILTER_KEYWORDS.addAll(Arrays.asList(keywords));
return true;
}
public static boolean filter(String word){
if(word == null) return false;
word = word.toLowerCase();
for(String s:FILTER_KEYWORDS){
if(word.contains(s)) return true;
public static boolean filter(String caption){
if(caption == null) return false;
caption = caption.toLowerCase(Locale.getDefault());
for(final String s:FILTER_KEYWORDS){
if(caption.contains(s)) return true;
}
return false;
}