Search in sources :

Example 1 with KeywordFilter

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);
    }
}
Also used : KeywordFilter(com.frostwire.search.KeywordFilter)

Example 2 with KeywordFilter

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;
}
Also used : KeywordFilter(com.frostwire.search.KeywordFilter)

Example 3 with KeywordFilter

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);
}
Also used : KeywordFilter(com.frostwire.search.KeywordFilter) ViewGroup(android.view.ViewGroup)

Example 4 with KeywordFilter

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;
}
Also used : YouTubeCrawledSearchResult(com.frostwire.search.youtube.YouTubeCrawledSearchResult) KeywordFilter(com.frostwire.search.KeywordFilter) ArrayList(java.util.ArrayList) MediaType(com.frostwire.android.core.MediaType) SoundcloudSearchResult(com.frostwire.search.soundcloud.SoundcloudSearchResult) YouTubePackageSearchResult(com.frostwire.search.youtube.YouTubePackageSearchResult) SearchResult(com.frostwire.search.SearchResult) TorrentSearchResult(com.frostwire.search.torrent.TorrentSearchResult) FileSearchResult(com.frostwire.search.FileSearchResult) StreamableSearchResult(com.frostwire.search.StreamableSearchResult) YouTubeCrawledStreamableSearchResult(com.frostwire.search.youtube.YouTubeCrawledStreamableSearchResult) YouTubeCrawledSearchResult(com.frostwire.search.youtube.YouTubeCrawledSearchResult)

Aggregations

KeywordFilter (com.frostwire.search.KeywordFilter)4 ViewGroup (android.view.ViewGroup)1 MediaType (com.frostwire.android.core.MediaType)1 FileSearchResult (com.frostwire.search.FileSearchResult)1 SearchResult (com.frostwire.search.SearchResult)1 StreamableSearchResult (com.frostwire.search.StreamableSearchResult)1 SoundcloudSearchResult (com.frostwire.search.soundcloud.SoundcloudSearchResult)1 TorrentSearchResult (com.frostwire.search.torrent.TorrentSearchResult)1 YouTubeCrawledSearchResult (com.frostwire.search.youtube.YouTubeCrawledSearchResult)1 YouTubeCrawledStreamableSearchResult (com.frostwire.search.youtube.YouTubeCrawledStreamableSearchResult)1 YouTubePackageSearchResult (com.frostwire.search.youtube.YouTubePackageSearchResult)1 ArrayList (java.util.ArrayList)1