Search in sources :

Example 1 with TorrentPromotionSearchResult

use of com.frostwire.frostclick.TorrentPromotionSearchResult 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 2 with TorrentPromotionSearchResult

use of com.frostwire.frostclick.TorrentPromotionSearchResult 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)

Aggregations

TorrentPromotionSearchResult (com.frostwire.frostclick.TorrentPromotionSearchResult)2 FileSearchResult (com.frostwire.search.FileSearchResult)2 AbstractTorrentSearchResult (com.frostwire.search.torrent.AbstractTorrentSearchResult)2 YouTubeSearchResult (com.frostwire.search.youtube.YouTubeSearchResult)2 Intent (android.content.Intent)1 NewTransferDialog (com.frostwire.android.gui.dialogs.NewTransferDialog)1 HttpSlideSearchResult (com.frostwire.android.gui.transfers.HttpSlideSearchResult)1 HttpSearchResult (com.frostwire.search.HttpSearchResult)1 SearchResult (com.frostwire.search.SearchResult)1 TorrentCrawledSearchResult (com.frostwire.search.torrent.TorrentCrawledSearchResult)1 TorrentSearchResult (com.frostwire.search.torrent.TorrentSearchResult)1