Always show downloaded data in megabytes
We omit the unit for the downloaded data and assume it's MB, so we must always show megabytes.
This commit is contained in:
@@ -123,8 +123,8 @@ public class UpdatesListAdapter extends RecyclerView.Adapter<UpdatesListAdapter.
|
||||
|
||||
final String downloadId = update.getDownloadId();
|
||||
if (mUpdaterController.isDownloading(downloadId)) {
|
||||
String downloaded = Formatter.formatBytes(mContext.getResources(),
|
||||
update.getFile().length(), Formatter.FLAG_SHORTER).value;
|
||||
String downloaded = StringGenerator.bytesToMegabytes(mContext,
|
||||
update.getFile().length());
|
||||
String total = Formatter.formatShortFileSize(mContext, update.getFileSize());
|
||||
long eta = update.getEta();
|
||||
if (eta > 0) {
|
||||
@@ -153,8 +153,8 @@ public class UpdatesListAdapter extends RecyclerView.Adapter<UpdatesListAdapter.
|
||||
} else {
|
||||
canDelete = true;
|
||||
setButtonAction(viewHolder.mAction, Action.RESUME, downloadId, !busy);
|
||||
String downloaded = Formatter.formatBytes(mContext.getResources(),
|
||||
update.getFile().length(), Formatter.FLAG_SHORTER).value;
|
||||
String downloaded = StringGenerator.bytesToMegabytes(mContext,
|
||||
update.getFile().length());
|
||||
String total = Formatter.formatShortFileSize(mContext, update.getFileSize());
|
||||
viewHolder.mProgressText.setText(mContext.getString(R.string.list_download_progress,
|
||||
downloaded, total));
|
||||
|
@@ -60,9 +60,12 @@ public final class StringGenerator {
|
||||
return f.format(date);
|
||||
}
|
||||
|
||||
public static String bytesToMegabytes(Context context, long bytes) {
|
||||
return String.format(getCurrentLocale(context), "%.0f", bytes / 1024.f / 1024.f);
|
||||
}
|
||||
|
||||
public static Locale getCurrentLocale(Context context) {
|
||||
return context.getResources().getConfiguration().getLocales()
|
||||
.getFirstMatch(context.getResources().getAssets().getLocales());
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user