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();
|
final String downloadId = update.getDownloadId();
|
||||||
if (mUpdaterController.isDownloading(downloadId)) {
|
if (mUpdaterController.isDownloading(downloadId)) {
|
||||||
String downloaded = Formatter.formatBytes(mContext.getResources(),
|
String downloaded = StringGenerator.bytesToMegabytes(mContext,
|
||||||
update.getFile().length(), Formatter.FLAG_SHORTER).value;
|
update.getFile().length());
|
||||||
String total = Formatter.formatShortFileSize(mContext, update.getFileSize());
|
String total = Formatter.formatShortFileSize(mContext, update.getFileSize());
|
||||||
long eta = update.getEta();
|
long eta = update.getEta();
|
||||||
if (eta > 0) {
|
if (eta > 0) {
|
||||||
@@ -153,8 +153,8 @@ public class UpdatesListAdapter extends RecyclerView.Adapter<UpdatesListAdapter.
|
|||||||
} else {
|
} else {
|
||||||
canDelete = true;
|
canDelete = true;
|
||||||
setButtonAction(viewHolder.mAction, Action.RESUME, downloadId, !busy);
|
setButtonAction(viewHolder.mAction, Action.RESUME, downloadId, !busy);
|
||||||
String downloaded = Formatter.formatBytes(mContext.getResources(),
|
String downloaded = StringGenerator.bytesToMegabytes(mContext,
|
||||||
update.getFile().length(), Formatter.FLAG_SHORTER).value;
|
update.getFile().length());
|
||||||
String total = Formatter.formatShortFileSize(mContext, update.getFileSize());
|
String total = Formatter.formatShortFileSize(mContext, update.getFileSize());
|
||||||
viewHolder.mProgressText.setText(mContext.getString(R.string.list_download_progress,
|
viewHolder.mProgressText.setText(mContext.getString(R.string.list_download_progress,
|
||||||
downloaded, total));
|
downloaded, total));
|
||||||
|
|||||||
@@ -60,9 +60,12 @@ public final class StringGenerator {
|
|||||||
return f.format(date);
|
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) {
|
public static Locale getCurrentLocale(Context context) {
|
||||||
return context.getResources().getConfiguration().getLocales()
|
return context.getResources().getConfiguration().getLocales()
|
||||||
.getFirstMatch(context.getResources().getAssets().getLocales());
|
.getFirstMatch(context.getResources().getAssets().getLocales());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user