Search in sources :

Example 6 with TransferItem

use of com.frostwire.transfers.TransferItem in project frostwire by frostwire.

the class BTDownload method getItems.

@Override
public List<TransferItem> getItems() {
    ArrayList<TransferItem> items = new ArrayList<>();
    if (th.isValid()) {
        TorrentInfo ti = th.torrentFile();
        if (ti != null && ti.isValid()) {
            FileStorage fs = ti.files();
            int numFiles = ti.numFiles();
            for (int i = 0; i < numFiles; i++) {
                BTDownloadItem item = new BTDownloadItem(th, i, fs.filePath(i), fs.fileSize(i), piecesTracker);
                items.add(item);
            }
            if (piecesTracker != null) {
                int numPieces = ti.numPieces();
                // perform piece complete check
                for (int i = 0; i < numPieces; i++) {
                    if (th.havePiece(i)) {
                        piecesTracker.setComplete(i, true);
                    }
                }
            }
        }
    }
    return items;
}
Also used : ArrayList(java.util.ArrayList) FileStorage(com.frostwire.jlibtorrent.FileStorage) TorrentInfo(com.frostwire.jlibtorrent.TorrentInfo) TransferItem(com.frostwire.transfers.TransferItem)

Example 7 with TransferItem

use of com.frostwire.transfers.TransferItem in project frostwire by frostwire.

the class TransferDetailDetailsFragment method updateComponents.

@Override
protected void updateComponents() {
    if (uiBittorrentDownload != null) {
        // ensureComponentsReferenced();
        BTDownload btDL = uiBittorrentDownload.getDl();
        if (onCopyToClipboardListener == null) {
            onCopyToClipboardListener = new CopyToClipboardOnClickListener(uiBittorrentDownload);
        }
        // static data for this download is done only once
        if ("".equals(storagePath.getText())) {
            storagePath.setText(uiBittorrentDownload.getSavePath().getAbsolutePath());
        }
        if ("".equals(totalSize.getText())) {
            totalSize.setText(UIUtils.getBytesInHuman(uiBittorrentDownload.getSize()));
        }
        if ("".equals(numberOfFiles.getText())) {
            List<TransferItem> items = uiBittorrentDownload.getItems();
            int fileCount = items == null ? 0 : items.size();
            numberOfFiles.setText(fileCount + "");
        }
        if ("".equals(hash.getText())) {
            hash.setText(uiBittorrentDownload.getInfoHash());
            hash.setOnClickListener(onCopyToClipboardListener);
            hashCopyButton.setOnClickListener(onCopyToClipboardListener);
        }
        if ("".equals(magnet.getText())) {
            magnet.setText(uiBittorrentDownload.magnetUri());
            magnet.setOnClickListener(onCopyToClipboardListener);
            magnetCopyButton.setOnClickListener(onCopyToClipboardListener);
        }
        if ("".equals(createdOn.getText())) {
            createdOn.setText(DateUtils.formatDateTime(getActivity(), uiBittorrentDownload.getCreated().getTime(), DateUtils.FORMAT_ABBREV_MONTH | DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_YEAR));
        }
        if ("".equals(comment.getText())) {
            TorrentInfo torrentInfo = uiBittorrentDownload.getDl().getTorrentHandle().torrentFile();
            String torrentComment = torrentInfo.comment();
            if (torrentComment != null && !"".equals(torrentComment)) {
                comment.setText(torrentComment);
            } else {
                comment.setText(" ");
                View view = findView(comment.getRootView(), R.id.fragment_transfer_detail_details_comment_container);
                view.setVisibility(View.GONE);
            }
        }
        if (onSequentialDownloadCheckboxCheckedListener == null) {
            onSequentialDownloadCheckboxCheckedListener = new SequentialDownloadCheckboxCheckedListener(uiBittorrentDownload);
        }
        sequentialDownloadCheckBox.setOnCheckedChangeListener(null);
        sequentialDownloadCheckBox.setChecked(btDL.isSequentialDownload());
        sequentialDownloadCheckBox.setOnCheckedChangeListener(onSequentialDownloadCheckboxCheckedListener);
        if (onRateLimitClickListener == null) {
            onRateLimitClickListener = new OnSpeedLimitClickListener(uiBittorrentDownload, this, getFragmentManager());
            downloadSpeedLimit.setOnClickListener(onRateLimitClickListener);
            downloadSpeedLimitArrow.setOnClickListener(onRateLimitClickListener);
            uploadSpeedLimit.setOnClickListener(onRateLimitClickListener);
            uploadSpeedLimitArrow.setOnClickListener(onRateLimitClickListener);
        }
        int downloadRateLimit = btDL.getDownloadRateLimit();
        int uploadRateLimit = btDL.getUploadRateLimit();
        if (downloadRateLimit > 0) {
            downloadSpeedLimit.setText(UIUtils.getBytesInHuman(downloadRateLimit) + "/s");
        } else if (downloadRateLimit == DOWNLOAD_UNLIMITED_VALUE || downloadRateLimit == -1) {
            downloadSpeedLimit.setText(R.string.unlimited);
        }
        if (uploadRateLimit > 0) {
            uploadSpeedLimit.setText(UIUtils.getBytesInHuman(uploadRateLimit) + "/s");
        } else if (uploadRateLimit == UPLOAD_UNLIMITED_VALUE || uploadRateLimit == -1) {
            uploadSpeedLimit.setText(R.string.unlimited);
        }
    }
}
Also used : BTDownload(com.frostwire.bittorrent.BTDownload) TorrentInfo(com.frostwire.jlibtorrent.TorrentInfo) TransferItem(com.frostwire.transfers.TransferItem) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView)

Aggregations

TransferItem (com.frostwire.transfers.TransferItem)7 TorrentInfo (com.frostwire.jlibtorrent.TorrentInfo)2 File (java.io.File)2 ContentResolver (android.content.ContentResolver)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 FileDescriptor (com.frostwire.android.core.FileDescriptor)1 TableFetcher (com.frostwire.android.core.providers.TableFetcher)1 Librarian (com.frostwire.android.gui.Librarian)1 CancelMenuAction (com.frostwire.android.gui.adapters.menu.CancelMenuAction)1 CopyToClipboardMenuAction (com.frostwire.android.gui.adapters.menu.CopyToClipboardMenuAction)1 OpenMenuAction (com.frostwire.android.gui.adapters.menu.OpenMenuAction)1 PauseDownloadMenuAction (com.frostwire.android.gui.adapters.menu.PauseDownloadMenuAction)1 ResumeDownloadMenuAction (com.frostwire.android.gui.adapters.menu.ResumeDownloadMenuAction)1 SeedAction (com.frostwire.android.gui.adapters.menu.SeedAction)1 SendBitcoinTipAction (com.frostwire.android.gui.adapters.menu.SendBitcoinTipAction)1 SendFiatTipAction (com.frostwire.android.gui.adapters.menu.SendFiatTipAction)1 StopSeedingAction (com.frostwire.android.gui.adapters.menu.StopSeedingAction)1 TransferDetailsMenuAction (com.frostwire.android.gui.adapters.menu.TransferDetailsMenuAction)1