From 1f8e9184c7a1522f37e4910be44dfbee7c2d3e06 Mon Sep 17 00:00:00 2001 From: cyian-1756 Date: Wed, 27 Jun 2018 01:24:04 -0400 Subject: [PATCH] Added the helper func getByteStatusText to cut down on copy pasted code --- .../ripme/ripper/rippers/GfycatRipper.java | 6 +----- .../ripper/rippers/GfycatporntubeRipper.java | 6 +----- .../java/com/rarchives/ripme/utils/Utils.java | 16 ++++++++++++++++ 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/GfycatRipper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/GfycatRipper.java index 78a0af19..97afef94 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/GfycatRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/GfycatRipper.java @@ -112,11 +112,7 @@ public class GfycatRipper extends AbstractHTMLRipper { @Override public String getStatusText() { - return String.valueOf(getCompletionPercentage()) + - "% - " + - Utils.bytesToHumanReadable(bytesCompleted) + - " / " + - Utils.bytesToHumanReadable(bytesTotal); + return Utils.getByteStatusText(getCompletionPercentage(), bytesCompleted, bytesTotal); } @Override diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/GfycatporntubeRipper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/GfycatporntubeRipper.java index d8f629ae..9010eb0e 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/GfycatporntubeRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/GfycatporntubeRipper.java @@ -65,11 +65,7 @@ public class GfycatporntubeRipper extends AbstractHTMLRipper { @Override public String getStatusText() { - return String.valueOf(getCompletionPercentage()) + - "% - " + - Utils.bytesToHumanReadable(bytesCompleted) + - " / " + - Utils.bytesToHumanReadable(bytesTotal); + return Utils.getByteStatusText(getCompletionPercentage(), bytesCompleted, bytesTotal); } @Override diff --git a/src/main/java/com/rarchives/ripme/utils/Utils.java b/src/main/java/com/rarchives/ripme/utils/Utils.java index 5821e9f3..e57acf77 100644 --- a/src/main/java/com/rarchives/ripme/utils/Utils.java +++ b/src/main/java/com/rarchives/ripme/utils/Utils.java @@ -715,4 +715,20 @@ public class Utils { } } + /** + * Formats and reuturns the status text for rippers using the byte progress bar + * + * @param completionPercentage An int between 0 and 100 which repersents how close the download is to complete + * @param bytesCompleted How many bytes have been downloaded + * @param bytesTotal The total size of the file that is being downloaded + * @return Returns the formatted status text for rippers using the byte progress bar + */ + public static String getByteStatusText(int completionPercentage, int bytesCompleted, int bytesTotal) { + return String.valueOf(completionPercentage) + + "% - " + + Utils.bytesToHumanReadable(bytesCompleted) + + " / " + + Utils.bytesToHumanReadable(bytesTotal); + } + } \ No newline at end of file