diff options
| author | Seigo Nonaka <nona@google.com> | 2015-06-23 08:31:08 +0000 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-06-23 08:31:12 +0000 |
| commit | 02ebcdb91101020f1897d50ed6d2e7ad048a5cec (patch) | |
| tree | 0ca927ab83d4ba28913dfda8aad540999c1e6bb7 /core/java/android | |
| parent | 3ae5e8b25be58b221b25274950d724088a3c4200 (diff) | |
| parent | 2ac124b790a4f4b8c9a9ac96a4211218e5d7af85 (diff) | |
| download | frameworks_base-02ebcdb91101020f1897d50ed6d2e7ad048a5cec.zip frameworks_base-02ebcdb91101020f1897d50ed6d2e7ad048a5cec.tar.gz frameworks_base-02ebcdb91101020f1897d50ed6d2e7ad048a5cec.tar.bz2 | |
Merge "Revive Null check for backward compatibility." into mnc-dev
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/text/format/Formatter.java | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/core/java/android/text/format/Formatter.java b/core/java/android/text/format/Formatter.java index 13a959e..47d5c79 100644 --- a/core/java/android/text/format/Formatter.java +++ b/core/java/android/text/format/Formatter.java @@ -16,6 +16,7 @@ package android.text.format; +import android.annotation.Nullable; import android.content.Context; import android.content.res.Resources; import android.net.NetworkUtils; @@ -52,7 +53,10 @@ public final class Formatter { * @param sizeBytes size value to be formatted, in bytes * @return formatted string with the number */ - public static String formatFileSize(Context context, long sizeBytes) { + public static String formatFileSize(@Nullable Context context, long sizeBytes) { + if (context == null) { + return ""; + } final BytesResult res = formatBytes(context.getResources(), sizeBytes, 0); return context.getString(com.android.internal.R.string.fileSizeSuffix, res.value, res.units); @@ -62,7 +66,10 @@ public final class Formatter { * Like {@link #formatFileSize}, but trying to generate shorter numbers * (showing fewer digits of precision). */ - public static String formatShortFileSize(Context context, long sizeBytes) { + public static String formatShortFileSize(@Nullable Context context, long sizeBytes) { + if (context == null) { + return ""; + } final BytesResult res = formatBytes(context.getResources(), sizeBytes, FLAG_SHORTER); return context.getString(com.android.internal.R.string.fileSizeSuffix, res.value, res.units); |
