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);
}
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);
});
}
}
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);
}
}
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;
}
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);
}
}
Aggregations