Search in sources :

Example 1 with SearchResult

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

the class SearchFragment method startPromotionDownload.

public void startPromotionDownload(Slide slide) {
    SearchResult sr;
    switch(slide.method) {
        case Slide.DOWNLOAD_METHOD_TORRENT:
            sr = new TorrentPromotionSearchResult(slide);
            break;
        case Slide.DOWNLOAD_METHOD_HTTP:
            sr = new HttpSlideSearchResult(slide);
            break;
        default:
            sr = null;
            break;
    }
    if (sr == null) {
        // check if there is a URL available to open a web browser.
        if (slide.clickURL != null) {
            Intent i = new Intent("android.intent.action.VIEW", Uri.parse(slide.clickURL));
            try {
                getActivity().startActivity(i);
            } catch (Throwable t) {
            // some devices incredibly may have no apps to handle this intent.
            }
        }
        return;
    }
    String stringDownloadingPromo;
    try {
        stringDownloadingPromo = getString(R.string.downloading_promotion, sr.getDisplayName());
    } catch (Throwable e) {
        stringDownloadingPromo = getString(R.string.azureus_manager_item_downloading);
    }
    startTransfer(sr, stringDownloadingPromo);
}
Also used : TorrentPromotionSearchResult(com.frostwire.frostclick.TorrentPromotionSearchResult) TorrentCrawledSearchResult(com.frostwire.search.torrent.TorrentCrawledSearchResult) HttpSearchResult(com.frostwire.search.HttpSearchResult) TorrentSearchResult(com.frostwire.search.torrent.TorrentSearchResult) FileSearchResult(com.frostwire.search.FileSearchResult) AbstractTorrentSearchResult(com.frostwire.search.torrent.AbstractTorrentSearchResult) TorrentPromotionSearchResult(com.frostwire.frostclick.TorrentPromotionSearchResult) HttpSlideSearchResult(com.frostwire.android.gui.transfers.HttpSlideSearchResult) SearchResult(com.frostwire.search.SearchResult) YouTubeSearchResult(com.frostwire.search.youtube.YouTubeSearchResult) Intent(android.content.Intent) HttpSlideSearchResult(com.frostwire.android.gui.transfers.HttpSlideSearchResult)

Example 2 with SearchResult

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

the class SearchFragment method onSearchResults.

private void onSearchResults(final List<SearchResult> results) {
    FilteredSearchResults fsr = adapter.filter(results);
    final List<SearchResult> mediaTypeFiltered = fsr.filtered;
    final List<SearchResult> keywordFiltered = fsr.keywordFiltered;
    fileTypeCounter.add(fsr);
    // if it's a fresh search, make sure to clear keyword detector
    if (adapter.getCount() == 0 && adapter.getKeywordFiltersPipeline().size() == 0) {
        resetKeywordDetector();
    }
    if (adapter.getKeywordFiltersPipeline().isEmpty()) {
        updateKeywordDetector(results);
    } else {
        updateKeywordDetector(keywordFiltered);
    }
    if (isAdded()) {
        getActivity().runOnUiThread(() -> {
            adapter.addResults(keywordFiltered, mediaTypeFiltered);
            showSearchView(getView());
            refreshFileTypeCounters(true);
        });
    }
}
Also used : FilteredSearchResults(com.frostwire.android.gui.adapters.SearchResultListAdapter.FilteredSearchResults) TorrentCrawledSearchResult(com.frostwire.search.torrent.TorrentCrawledSearchResult) HttpSearchResult(com.frostwire.search.HttpSearchResult) TorrentSearchResult(com.frostwire.search.torrent.TorrentSearchResult) FileSearchResult(com.frostwire.search.FileSearchResult) AbstractTorrentSearchResult(com.frostwire.search.torrent.AbstractTorrentSearchResult) TorrentPromotionSearchResult(com.frostwire.frostclick.TorrentPromotionSearchResult) HttpSlideSearchResult(com.frostwire.android.gui.transfers.HttpSlideSearchResult) SearchResult(com.frostwire.search.SearchResult) YouTubeSearchResult(com.frostwire.search.youtube.YouTubeSearchResult)

Example 3 with SearchResult

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

the class ConfirmSoundcloudDownloadDialog method startDownloads.

private static void startDownloads(Context ctx, List<? extends SearchResult> srs) {
    if (srs != null && !srs.isEmpty()) {
        for (SearchResult sr : srs) {
            StartDownloadTask task = new StartDownloadTask(ctx, sr);
            Tasks.executeParallel(task);
        }
        UIUtils.showTransfersOnDownloadStart(ctx);
    }
}
Also used : StartDownloadTask(com.frostwire.android.gui.tasks.StartDownloadTask) SoundcloudSearchResult(com.frostwire.search.soundcloud.SoundcloudSearchResult) SearchResult(com.frostwire.search.SearchResult)

Example 4 with SearchResult

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

the class TorrentJsonSearchPerformer method searchPage.

@Override
protected final List<? extends SearchResult> searchPage(String page) {
    List<SearchResult> result = new LinkedList<>();
    List<T> items = parseJson(page);
    if (items != null) {
        Collections.sort(items, itemComparator);
        for (T item : items) {
            if (!isStopped()) {
                SearchResult sr = fromItem(item);
                result.add(sr);
            }
        }
    }
    return result;
}
Also used : SearchResult(com.frostwire.search.SearchResult) LinkedList(java.util.LinkedList)

Example 5 with SearchResult

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

the class SearchView method add.

public void add(List<? extends SearchResult> results) {
    LinkedList<SearchResult> added = new LinkedList<>();
    for (SearchResult sr : results) {
        if (filter.accept(sr)) {
            FilterKey key = filter.key(sr);
            SearchGroup group = groups.get(key);
            if (group == null) {
                group = new SearchGroup(filter);
                groups.put(key, group);
            }
            group.add(sr);
            added.add(sr);
        }
    }
    if (listener != null && added.size() > 0) {
        listener.viewAdded(this, added);
    }
}
Also used : SearchResult(com.frostwire.search.SearchResult)

Aggregations

SearchResult (com.frostwire.search.SearchResult)14 TorrentSearchResult (com.frostwire.search.torrent.TorrentSearchResult)6 FileSearchResult (com.frostwire.search.FileSearchResult)5 StreamableSearchResult (com.frostwire.search.StreamableSearchResult)4 HttpSlideSearchResult (com.frostwire.android.gui.transfers.HttpSlideSearchResult)3 TorrentPromotionSearchResult (com.frostwire.frostclick.TorrentPromotionSearchResult)3 HttpSearchResult (com.frostwire.search.HttpSearchResult)3 SoundcloudSearchResult (com.frostwire.search.soundcloud.SoundcloudSearchResult)3 AbstractTorrentSearchResult (com.frostwire.search.torrent.AbstractTorrentSearchResult)3 TorrentCrawledSearchResult (com.frostwire.search.torrent.TorrentCrawledSearchResult)3 YouTubeCrawledSearchResult (com.frostwire.search.youtube.YouTubeCrawledSearchResult)3 YouTubeCrawledStreamableSearchResult (com.frostwire.search.youtube.YouTubeCrawledStreamableSearchResult)3 YouTubePackageSearchResult (com.frostwire.search.youtube.YouTubePackageSearchResult)3 YouTubeSearchResult (com.frostwire.search.youtube.YouTubeSearchResult)3 CrawlableSearchResult (com.frostwire.search.CrawlableSearchResult)2 ArchiveorgTorrentSearchResult (com.frostwire.search.archiveorg.ArchiveorgTorrentSearchResult)2 ArrayList (java.util.ArrayList)2 LinkedList (java.util.LinkedList)2 Intent (android.content.Intent)1 MediaType (com.frostwire.android.core.MediaType)1