use of com.frostwire.android.gui.adapters.menu.TransferDetailsMenuAction in project frostwire by frostwire.
the class TransferListAdapter method populateBittorrentDownloadMenuActions.
private String populateBittorrentDownloadMenuActions(BittorrentDownload bittorrentDownload, List<MenuAction> items) {
String title;
title = bittorrentDownload.getDisplayName();
// If it's a torrent download with a single file, we should be able to open it.
if (bittorrentDownload.isComplete() && bittorrentDownload.getItems().size() > 0) {
TransferItem transferItem = bittorrentDownload.getItems().get(0);
String path = transferItem.getFile().getAbsolutePath();
String mimeType = UIUtils.getMimeType(path);
items.add(new OpenMenuAction(contextRef.get(), path, mimeType));
}
if (!bittorrentDownload.isComplete() && !bittorrentDownload.isSeeding()) {
if (!bittorrentDownload.isPaused()) {
items.add(new PauseDownloadMenuAction(contextRef.get(), bittorrentDownload));
} else {
boolean wifiIsUp = NetworkManager.instance().isDataWIFIUp();
boolean bittorrentOnMobileData = !ConfigurationManager.instance().getBoolean(Constants.PREF_KEY_NETWORK_USE_WIFI_ONLY);
if (wifiIsUp || bittorrentOnMobileData) {
if (!bittorrentDownload.isComplete()) {
items.add(new ResumeDownloadMenuAction(contextRef.get(), bittorrentDownload, R.string.resume_torrent_menu_action));
}
}
}
}
if (bittorrentDownload.getState() == TransferState.FINISHED) {
items.add(new SeedAction(contextRef.get(), bittorrentDownload));
}
if (bittorrentDownload.getState() == TransferState.SEEDING) {
items.add(new StopSeedingAction(contextRef.get(), bittorrentDownload));
}
items.add(new CancelMenuAction(contextRef.get(), bittorrentDownload, !bittorrentDownload.isComplete()));
items.add(new CopyToClipboardMenuAction(contextRef.get(), R.drawable.contextmenu_icon_magnet, R.string.transfers_context_menu_copy_magnet, R.string.transfers_context_menu_copy_magnet_copied, bittorrentDownload.magnetUri() + BTEngine.getInstance().magnetPeers()));
items.add(new CopyToClipboardMenuAction(contextRef.get(), R.drawable.contextmenu_icon_copy, R.string.transfers_context_menu_copy_infohash, R.string.transfers_context_menu_copy_infohash_copied, bittorrentDownload.getInfoHash()));
if (bittorrentDownload.isComplete()) {
// Remove Torrent and Data action.
items.add(new CancelMenuAction(contextRef.get(), bittorrentDownload, true, true));
}
if (bittorrentDownload instanceof UIBittorrentDownload) {
UIBittorrentDownload uidl = (UIBittorrentDownload) bittorrentDownload;
if (uidl.hasPaymentOptions()) {
PaymentOptions po = uidl.getPaymentOptions();
if (po.bitcoin != null) {
items.add(new SendBitcoinTipAction(contextRef.get(), po.bitcoin));
}
if (po.paypalUrl != null) {
items.add(new SendFiatTipAction(contextRef.get(), po.paypalUrl));
}
if (po.bitcoin != null) {
items.add(new SendBitcoinTipAction(contextRef.get(), po.bitcoin));
}
}
if (bittorrentDownload.getInfoHash() != null && !"".equals(bittorrentDownload.getInfoHash())) {
items.add(new TransferDetailsMenuAction(contextRef.get(), R.string.show_torrent_details, bittorrentDownload.getInfoHash()));
}
}
return title;
}
Aggregations