Search in sources :

Example 1 with FileSearchResult

use of com.frostwire.search.FileSearchResult in project frostwire by frostwire.

the class PreviewPlayerActivity method onDownloadButtonClick.

private void onDownloadButtonClick() {
    if (Ref.alive(srRef)) {
        Engine.instance().getVibrator().hapticFeedback();
        final FileSearchResult fileSearchResult = srRef.get();
        if (fileSearchResult instanceof YouTubePackageSearchResult) {
            releaseMediaPlayer();
            YouTubeDownloadDialog ytDownloadDlg = YouTubeDownloadDialog.newInstance(this, (YouTubePackageSearchResult) fileSearchResult);
            ytDownloadDlg.show(getFragmentManager());
        } else {
            NewTransferDialog dlg = NewTransferDialog.newInstance(fileSearchResult, false);
            dlg.show(getFragmentManager());
        }
    } else {
        finish();
    }
}
Also used : FileSearchResult(com.frostwire.search.FileSearchResult) YouTubePackageSearchResult(com.frostwire.search.youtube.YouTubePackageSearchResult) YouTubeDownloadDialog(com.frostwire.android.gui.dialogs.YouTubeDownloadDialog) NewTransferDialog(com.frostwire.android.gui.dialogs.NewTransferDialog)

Example 2 with FileSearchResult

use of com.frostwire.search.FileSearchResult in project frostwire by frostwire.

the class SearchFragment method startTransfer.

private void startTransfer(final SearchResult sr, final String toastMessage) {
    Engine.instance().getVibrator().hapticFeedback();
    if (!(sr instanceof AbstractTorrentSearchResult || sr instanceof TorrentPromotionSearchResult) && ConfigurationManager.instance().getBoolean(Constants.PREF_KEY_GUI_SHOW_NEW_TRANSFER_DIALOG)) {
        if (sr instanceof FileSearchResult && !(sr instanceof YouTubeSearchResult)) {
            try {
                NewTransferDialog dlg = NewTransferDialog.newInstance((FileSearchResult) sr, false);
                dlg.show(getFragmentManager());
            } catch (IllegalStateException e) {
                // android.app.FragmentManagerImpl.checkStateLoss:1323 -> java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
                // just start the download then if the dialog crapped out.
                onDialogClick(NewTransferDialog.TAG, Dialog.BUTTON_POSITIVE);
            }
        } else if (sr instanceof YouTubeSearchResult) {
            startDownload(getActivity(), sr, toastMessage);
        }
    } else {
        if (isVisible()) {
            startDownload(getActivity(), sr, toastMessage);
        }
    }
    uxLogAction(sr);
}
Also used : FileSearchResult(com.frostwire.search.FileSearchResult) TorrentPromotionSearchResult(com.frostwire.frostclick.TorrentPromotionSearchResult) YouTubeSearchResult(com.frostwire.search.youtube.YouTubeSearchResult) AbstractTorrentSearchResult(com.frostwire.search.torrent.AbstractTorrentSearchResult) NewTransferDialog(com.frostwire.android.gui.dialogs.NewTransferDialog)

Example 3 with FileSearchResult

use of com.frostwire.search.FileSearchResult 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

FileSearchResult (com.frostwire.search.FileSearchResult)3 NewTransferDialog (com.frostwire.android.gui.dialogs.NewTransferDialog)2 YouTubePackageSearchResult (com.frostwire.search.youtube.YouTubePackageSearchResult)2 MediaType (com.frostwire.android.core.MediaType)1 YouTubeDownloadDialog (com.frostwire.android.gui.dialogs.YouTubeDownloadDialog)1 TorrentPromotionSearchResult (com.frostwire.frostclick.TorrentPromotionSearchResult)1 KeywordFilter (com.frostwire.search.KeywordFilter)1 SearchResult (com.frostwire.search.SearchResult)1 StreamableSearchResult (com.frostwire.search.StreamableSearchResult)1 SoundcloudSearchResult (com.frostwire.search.soundcloud.SoundcloudSearchResult)1 AbstractTorrentSearchResult (com.frostwire.search.torrent.AbstractTorrentSearchResult)1 TorrentSearchResult (com.frostwire.search.torrent.TorrentSearchResult)1 YouTubeCrawledSearchResult (com.frostwire.search.youtube.YouTubeCrawledSearchResult)1 YouTubeCrawledStreamableSearchResult (com.frostwire.search.youtube.YouTubeCrawledStreamableSearchResult)1 YouTubeSearchResult (com.frostwire.search.youtube.YouTubeSearchResult)1 ArrayList (java.util.ArrayList)1