use of com.frostwire.search.KeywordFilter in project frostwire by frostwire.
the class KeywordFilterDrawerView method updateAppliedKeywordFilters.
public void updateAppliedKeywordFilters(List<KeywordFilter> keywordFiltersPipeline) {
boolean filtersHaveBeenApplied = keywordFiltersPipeline.size() > 0;
int clearAppliedFiltersVisibility = filtersHaveBeenApplied ? View.VISIBLE : View.GONE;
clearAppliedFiltersTextView.setVisibility(clearAppliedFiltersVisibility);
// touch tags include/exclude tip container visibility logic
boolean appliedTagsTipTextViewDismissedBefore = ConfigurationManager.instance().getBoolean(Constants.PREF_KEY_GUI_SEARCH_KEYWORDFILTERDRAWER_TIP_TOUCHTAGS_DISMISSED);
int appliedTagsTipTextViewVisibility = (filtersHaveBeenApplied && !appliedTagsTipTextViewDismissedBefore) ? View.VISIBLE : View.GONE;
appliedTagsTipTextViewContainer.setVisibility(appliedTagsTipTextViewVisibility);
pipelineLayout.removeAllViews();
if (filtersHaveBeenApplied) {
for (KeywordFilter filter : keywordFiltersPipeline) {
KeywordTagView keywordTagView = new KeywordTagView(getContext(), filter, -1, true, keywordTagListener);
pipelineLayout.addView(keywordTagView);
}
}
if (pipelineListener != null) {
pipelineListener.onPipelineUpdate(keywordFiltersPipeline);
}
}
use of com.frostwire.search.KeywordFilter in project frostwire by frostwire.
the class KeywordFilterDrawerView method onKeywordEntered.
private boolean onKeywordEntered(TextView v) {
String keyword = v.getText().toString().trim().toLowerCase();
if (keyword.length() == 0) {
return true;
}
KeywordFilter keywordFilter = new KeywordFilter(true, keyword, KeywordDetector.Feature.MANUAL_ENTRY);
v.setText("");
v.clearFocus();
if (pipelineListener != null) {
pipelineListener.onAddKeywordFilter(keywordFilter);
updateAppliedKeywordFilters(pipelineListener.getKeywordFiltersPipeline());
}
UIUtils.hideKeyboardFromActivity((Activity) getContext());
return true;
}
use of com.frostwire.search.KeywordFilter in project frostwire by frostwire.
the class KeywordFilterDrawerView method updateSuggestedKeywordFilters.
private void updateSuggestedKeywordFilters(KeywordDetector.Feature feature, List<Entry<String, Integer>> histogram) {
TagsController tagsController = featureContainer.get(feature);
tagsController.showProgressView(true);
ViewGroup container = tagsController.container;
container.removeAllViews();
requestLayout();
boolean keywordsApplied = false;
List<KeywordFilter> keywordFiltersPipeline = null;
if (pipelineListener != null) {
keywordFiltersPipeline = pipelineListener.getKeywordFiltersPipeline();
keywordsApplied = keywordFiltersPipeline.size() > 0;
}
int visibleTags = 0;
for (Entry<String, Integer> entry : histogram) {
int visibility = (keywordsApplied && keywordInPipeline(entry.getKey(), keywordFiltersPipeline)) ? View.GONE : View.VISIBLE;
KeywordTagView keywordTagView = new KeywordTagView(getContext(), new KeywordFilter(true, entry.getKey(), feature), entry.getValue(), false, keywordTagListener);
container.addView(keywordTagView);
keywordTagView.setVisibility(visibility);
if (visibility == View.VISIBLE) {
visibleTags++;
}
}
if (visibleTags > 0) {
tagsController.showHeader();
} else {
tagsController.hideHeader();
}
tagsController.showProgressView(visibleTags == 0);
}
use of com.frostwire.search.KeywordFilter in project frostwire by frostwire.
the class SearchResultListAdapter method filter.
public FilteredSearchResults filter(List<SearchResult> results) {
FilteredSearchResults fsr = new FilteredSearchResults();
ArrayList<SearchResult> mediaTypedFiltered = new ArrayList<>();
ArrayList<SearchResult> keywordFiltered = new ArrayList<>();
List<KeywordFilter> keywordFilters = getKeywordFiltersPipeline();
for (SearchResult sr : results) {
String extension = FilenameUtils.getExtension(((FileSearchResult) sr).getFilename());
MediaType mt = MediaType.getMediaTypeForExtension(extension);
if ("youtube".equals(extension)) {
mt = MediaType.getVideoMediaType();
} else if (mt != null && mt.equals(MediaType.getVideoMediaType()) && sr instanceof YouTubeCrawledSearchResult) {
// NOTE: this excludes all non .youtube youtube search results (e.g. 3gp, webm) from appearing on results
mt = null;
}
boolean passedKeywordFilter = KeywordFilter.passesFilterPipeline(sr, keywordFilters);
if (isFileSearchResultMediaTypeMatching(sr, mt)) {
if (keywordFilters.isEmpty() || passedKeywordFilter) {
mediaTypedFiltered.add(sr);
keywordFiltered.add(sr);
}
} else if (mt != null && passedKeywordFilter) {
keywordFiltered.add(sr);
}
fsr.increment(mt, passedKeywordFilter);
}
fsr.filtered = mediaTypedFiltered;
fsr.keywordFiltered = keywordFiltered;
return fsr;
}
Aggregations