@Override protected void progress(double pct, int blocksSoFar, Date date) { super.progress(pct, blocksSoFar, date); int percentage = (int) pct; view.displayPercentage(percentage); view.displayProgress(percentage); }
@Override public void onBlocksDownloaded(Peer peer, Block block, @Nullable FilteredBlock filteredBlock, int blocksLeft) { if (caughtUp) return; if (blocksLeft == 0) { caughtUp = true; doneDownload(); future.set(peer.getBestHeight()); } if (blocksLeft < 0 || originalBlocksLeft <= 0) return; double pct = 100.0 - (100.0 * (blocksLeft / (double) originalBlocksLeft)); if ((int) pct != lastPercent) { progress(pct, blocksLeft, new Date(block.getTimeSeconds() * 1000)); lastPercent = (int) pct; } }
@Override public void onBlocksDownloaded(Peer peer, Block block, @Nullable FilteredBlock filteredBlock, int blocksLeft) { if (caughtUp) return; if (blocksLeft == 0) { caughtUp = true; if (lastPercent != 100) { lastPercent = 100; progress(lastPercent, blocksLeft, new Date(block.getTimeSeconds() * 1000)); } doneDownload(); future.set(peer.getBestHeight()); return; } if (blocksLeft < 0 || originalBlocksLeft <= 0) return; double pct = 100.0 - (100.0 * (blocksLeft / (double) originalBlocksLeft)); if ((int) pct != lastPercent) { progress(pct, blocksLeft, new Date(block.getTimeSeconds() * 1000)); lastPercent = (int) pct; } }
@Override public void onBlocksDownloaded(Peer peer, Block block, @Nullable FilteredBlock filteredBlock, int blocksLeft) { if (caughtUp) return; if (blocksLeft == 0) { caughtUp = true; doneDownload(); future.set(peer.getBestHeight()); } if (blocksLeft < 0 || originalBlocksLeft <= 0) return; double pct = 100.0 - (100.0 * (blocksLeft / (double) originalBlocksLeft)); if ((int) pct != lastPercent) { progress(pct, blocksLeft, new Date(block.getTimeSeconds() * 1000)); lastPercent = (int) pct; } }
@Override public void onBlocksDownloaded(Peer peer, Block block, @Nullable FilteredBlock filteredBlock, int blocksLeft) { if (caughtUp) return; if (blocksLeft == 0) { caughtUp = true; doneDownload(); future.set(peer.getBestHeight()); } if (blocksLeft < 0 || originalBlocksLeft <= 0) return; double pct = 100.0 - (100.0 * (blocksLeft / (double) originalBlocksLeft)); if ((int) pct != lastPercent) { progress(pct, blocksLeft, new Date(block.getTimeSeconds() * 1000)); lastPercent = (int) pct; } }