use of com.frostwire.transfers.Transfer in project frostwire by frostwire.
the class TransferListAdapter method populateCloudDownloadMenuActions.
private String populateCloudDownloadMenuActions(Object tag, List<MenuAction> items) {
Transfer download = (Transfer) tag;
String title = download.getDisplayName();
boolean errored = download.getState().name().contains("ERROR");
boolean finishedSuccessfully = !errored && download.isComplete() && isCloudDownload(tag);
if (finishedSuccessfully && Ref.alive(contextRef)) {
final List<FileDescriptor> files = Librarian.instance().getFiles(contextRef.get(), download.getSavePath().getAbsolutePath(), true);
boolean singleFile = files != null && files.size() == 1;
if (singleFile && !AndroidPlatform.saf(new File(files.get(0).filePath))) {
items.add(new SeedAction(contextRef.get(), files.get(0), download));
}
if (singleFile && files.get(0).fileType == Constants.FILE_TYPE_PICTURES) {
items.add(new OpenMenuAction(contextRef.get(), download.getDisplayName(), files.get(0)));
} else {
items.add(new OpenMenuAction(contextRef.get(), download.getDisplayName(), download.getSavePath().getAbsolutePath(), extractMime(download)));
}
}
if (Ref.alive(contextRef)) {
items.add(new CancelMenuAction(contextRef.get(), download, !finishedSuccessfully));
}
return title;
}
use of com.frostwire.transfers.Transfer in project frostwire by frostwire.
the class TransfersFragment method updateMenuItemVisibility.
private void updateMenuItemVisibility(Menu menu) {
TransferManager tm = TransferManager.instance();
boolean bittorrentDisconnected = tm.isBittorrentDisconnected();
final List<Transfer> transfers = tm.getTransfers();
if (transfers != null && transfers.size() > 0) {
if (someTransfersComplete(transfers)) {
menu.findItem(R.id.fragment_transfers_menu_clear_all).setVisible(true);
}
if (!bittorrentDisconnected) {
if (someTransfersActive(transfers)) {
menu.findItem(R.id.fragment_transfers_menu_pause_stop_all).setVisible(true);
}
}
// Preferences > Connectivity is disconnected.
if (someTransfersInactive(transfers)) {
menu.findItem(R.id.fragment_transfers_menu_resume_all).setVisible(true);
}
if (!someTransfersSeeding(transfers) && someTransfersComplete(transfers)) {
menu.findItem(R.id.fragment_transfers_menu_seed_all).setVisible(true);
}
if (someTransfersSeeding(transfers) && someTransfersComplete(transfers)) {
menu.findItem(R.id.fragment_transfers_menu_seed_all).setVisible(true);
menu.findItem(R.id.fragment_transfers_menu_stop_seeding_all).setVisible(true);
}
if (someTransfersSeeding(transfers)) {
menu.findItem(R.id.fragment_transfers_menu_stop_seeding_all).setVisible(true);
}
}
}
use of com.frostwire.transfers.Transfer in project frostwire by frostwire.
the class TransferManager method stopHttpTransfers.
/**
* Stops all HttpDownloads (Cloud and Wi-Fi)
*/
public void stopHttpTransfers() {
List<Transfer> transfers = new ArrayList<>();
transfers.addAll(httpDownloads);
for (Transfer t : transfers) {
if (t != null && !t.isComplete() && t.isDownloading()) {
t.remove(false);
}
}
}
use of com.frostwire.transfers.Transfer in project frostwire by frostwire.
the class TransferManager method getDownloadsBandwidth.
public long getDownloadsBandwidth() {
if (BTEngine.ctx == null) {
// too early
return 0;
}
long torrentDownloadsBandwidth = BTEngine.getInstance().downloadRate();
long peerDownloadsBandwidth = 0;
for (Transfer d : httpDownloads) {
peerDownloadsBandwidth += d.getDownloadSpeed();
}
return torrentDownloadsBandwidth + peerDownloadsBandwidth;
}
use of com.frostwire.transfers.Transfer in project frostwire by frostwire.
the class TransfersFragment method setupAdapter.
private void setupAdapter(Context context) {
if (context == null) {
return;
}
List<Transfer> transfers = filter(TransferManager.instance().getTransfers(), selectedStatus);
Collections.sort(transfers, transferComparator);
adapter = new TransferListAdapter(context, transfers);
list.setLayoutManager(recyclerViewLayoutManager);
list.setAdapter(adapter);
}
Aggregations