Added the helper func getByteStatusText to cut down on copy pasted code

This commit is contained in:
cyian-1756 2018-06-27 01:24:04 -04:00
parent ed7df108e5
commit 1f8e9184c7
3 changed files with 18 additions and 10 deletions

View File

@ -112,11 +112,7 @@ public class GfycatRipper extends AbstractHTMLRipper {
@Override @Override
public String getStatusText() { public String getStatusText() {
return String.valueOf(getCompletionPercentage()) + return Utils.getByteStatusText(getCompletionPercentage(), bytesCompleted, bytesTotal);
"% - " +
Utils.bytesToHumanReadable(bytesCompleted) +
" / " +
Utils.bytesToHumanReadable(bytesTotal);
} }
@Override @Override

View File

@ -65,11 +65,7 @@ public class GfycatporntubeRipper extends AbstractHTMLRipper {
@Override @Override
public String getStatusText() { public String getStatusText() {
return String.valueOf(getCompletionPercentage()) + return Utils.getByteStatusText(getCompletionPercentage(), bytesCompleted, bytesTotal);
"% - " +
Utils.bytesToHumanReadable(bytesCompleted) +
" / " +
Utils.bytesToHumanReadable(bytesTotal);
} }
@Override @Override

View File

@ -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);
}
} }