use of com.frostwire.jlibtorrent.PieceIndexBitfield in project frostwire by frostwire.
the class TransferDetailPiecesFragment method updateComponents.
@Override
protected void updateComponents() {
if (uiBittorrentDownload == null) {
return;
}
ensureTorrentHandleAsync();
if (torrentHandle == null) {
return;
}
TorrentStatus status = torrentHandle.status(TorrentHandle.QUERY_PIECES);
TorrentInfo torrentInfo = torrentHandle.torrentFile();
if (pieceSizeString == null) {
pieceSizeString = UIUtils.getBytesInHuman(torrentInfo.pieceSize(0));
}
if (totalPieces == -1) {
totalPieces = torrentInfo.numPieces();
piecesNumberTextView.setText(String.valueOf(totalPieces));
// progressBar.setVisibility(View.VISIBLE);
hexHiveView.setVisibility(View.GONE);
}
PieceIndexBitfield pieces = status.pieces();
long piecesCount = pieces.count();
if (isAdded()) {
// I do this color look-up only once and pass it down to the view holder
// otherwise it has to be done thousands of times.
pieceSizeTextView.setText(pieceSizeString);
hexDataAdapter = new PieceAdapter(totalPieces, pieces);
hexHiveView.setVisibility(View.VISIBLE);
}
if (hexDataAdapter != null) {
if (piecesCount >= 0) {
hexDataAdapter.updateData(pieces);
}
// noinspection unchecked
hexHiveView.updateData(hexDataAdapter);
piecesNumberTextView.setText(piecesCount + "/" + totalPieces);
}
}
Aggregations