mirror of
https://github.com/KokaKiwi/BarInsta
synced 2024-11-26 08:37:29 +00:00
Fixed warnings
This commit is contained in:
parent
10f5d91a42
commit
21950a4277
@ -30,7 +30,7 @@ public class KeywordsFilterAdapter extends RecyclerView.Adapter<KeywordsFilterDi
|
|||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public KeywordsFilterDialogViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
public KeywordsFilterDialogViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_keyword, parent, false);
|
final View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_keyword, parent, false);
|
||||||
return new KeywordsFilterDialogViewHolder(v);
|
return new KeywordsFilterDialogViewHolder(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,13 +42,12 @@ public class FeedPostFetchService implements PostFetcher.PostFetchService {
|
|||||||
nextCursor = result.getNextCursor();
|
nextCursor = result.getNextCursor();
|
||||||
hasNextPage = result.hasNextPage();
|
hasNextPage = result.hasNextPage();
|
||||||
|
|
||||||
//Check caption if it doesn't contain any specified keywords in filter_keywords.xml
|
|
||||||
final List<Media> mediaResults = result.getFeedModels();
|
final List<Media> mediaResults = result.getFeedModels();
|
||||||
if(!settingsHelper.getBoolean(Constants.TOGGLE_KEYWORD_FILTER)){
|
if(settingsHelper.getBoolean(Constants.TOGGLE_KEYWORD_FILTER)){
|
||||||
feedModels.addAll(mediaResults);
|
final ArrayList<String> items = new ArrayList<>(settingsHelper.getStringSet(Constants.KEYWORD_FILTERS));
|
||||||
}else{
|
|
||||||
ArrayList<String> items = new ArrayList<>(settingsHelper.getStringSet(Constants.KEYWORD_FILTERS));
|
|
||||||
feedModels.addAll(new KeywordsFilterUtils(items).filter(mediaResults));
|
feedModels.addAll(new KeywordsFilterUtils(items).filter(mediaResults));
|
||||||
|
}else{
|
||||||
|
feedModels.addAll(mediaResults);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fetchListener != null) {
|
if (fetchListener != null) {
|
||||||
|
@ -29,7 +29,14 @@ public final class KeywordsFilterDialog extends DialogFragment {
|
|||||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||||
final DialogKeywordsFilterBinding dialogKeywordsFilterBinding = DialogKeywordsFilterBinding.inflate(inflater, container, false);
|
final DialogKeywordsFilterBinding dialogKeywordsFilterBinding = DialogKeywordsFilterBinding.inflate(inflater, container, false);
|
||||||
|
|
||||||
final Context context = getContext();
|
init(dialogKeywordsFilterBinding, getContext());
|
||||||
|
|
||||||
|
dialogKeywordsFilterBinding.btnOK.setOnClickListener(view -> this.dismiss());
|
||||||
|
|
||||||
|
return dialogKeywordsFilterBinding.getRoot();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init(DialogKeywordsFilterBinding dialogKeywordsFilterBinding, Context context){
|
||||||
final LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context);
|
final LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context);
|
||||||
final RecyclerView recyclerView = dialogKeywordsFilterBinding.recyclerKeyword;
|
final RecyclerView recyclerView = dialogKeywordsFilterBinding.recyclerKeyword;
|
||||||
recyclerView.setLayoutManager(linearLayoutManager);
|
recyclerView.setLayoutManager(linearLayoutManager);
|
||||||
@ -55,11 +62,5 @@ public final class KeywordsFilterDialog extends DialogFragment {
|
|||||||
Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
|
Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
|
||||||
editText.setText("");
|
editText.setText("");
|
||||||
});
|
});
|
||||||
|
|
||||||
dialogKeywordsFilterBinding.btnOK.setOnClickListener(view ->{
|
|
||||||
this.dismiss();
|
|
||||||
});
|
|
||||||
|
|
||||||
return dialogKeywordsFilterBinding.getRoot();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ public final class KeywordsFilterUtils {
|
|||||||
|
|
||||||
public boolean filter(final String caption){
|
public boolean filter(final String caption){
|
||||||
if(caption == null) return false;
|
if(caption == null) return false;
|
||||||
|
if(keywords.isEmpty()) return false;
|
||||||
final String temp = caption.toLowerCase(Locale.getDefault());
|
final String temp = caption.toLowerCase(Locale.getDefault());
|
||||||
for(final String s:keywords){
|
for(final String s:keywords){
|
||||||
if(temp.contains(s)) return true;
|
if(temp.contains(s)) return true;
|
||||||
@ -28,6 +29,7 @@ public final class KeywordsFilterUtils {
|
|||||||
if(media == null) return false;
|
if(media == null) return false;
|
||||||
final Caption c = media.getCaption();
|
final Caption c = media.getCaption();
|
||||||
if(c == null) return false;
|
if(c == null) return false;
|
||||||
|
if(keywords.isEmpty()) return false;
|
||||||
final String temp = c.getText().toLowerCase(LocaleUtils.getCurrentLocale());
|
final String temp = c.getText().toLowerCase(LocaleUtils.getCurrentLocale());
|
||||||
for(final String s:keywords){
|
for(final String s:keywords){
|
||||||
if(temp.contains(s)) return true;
|
if(temp.contains(s)) return true;
|
||||||
@ -36,6 +38,7 @@ public final class KeywordsFilterUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<Media> filter(final List<Media> media){
|
public List<Media> filter(final List<Media> media){
|
||||||
|
if(keywords.isEmpty()) return media;
|
||||||
if(media == null) return new ArrayList<>();
|
if(media == null) return new ArrayList<>();
|
||||||
|
|
||||||
final List<Media> result= new ArrayList<>();
|
final List<Media> result= new ArrayList<>();
|
||||||
|
Loading…
Reference in New Issue
Block a user