From d6ea1e86f203c5bf488d1f33e15fafbd7041927e Mon Sep 17 00:00:00 2001 From: Narayan Kamath Date: Tue, 19 Apr 2016 11:48:33 +0100 Subject: [PATCH] Tidy up uses of Integer.valueOf. Use parseInt when the result is assigned to an int. Allocates fewer objects. bug: 28078871 Change-Id: Icbb0507949b71bc0a729f2e65309dab939b3d853 --- .../com/example/android/livecubes/cube2/CubeWallpaper2.java | 4 ++-- .../com.example.android.autobackupsample/AddFileActivity.java | 2 +- .../com/example/training/deviceadmin/PolicySetupActivity.java | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/samples/CubeLiveWallpaper/src/com/example/android/livecubes/cube2/CubeWallpaper2.java b/samples/CubeLiveWallpaper/src/com/example/android/livecubes/cube2/CubeWallpaper2.java index 85f194004..8962399bc 100644 --- a/samples/CubeLiveWallpaper/src/com/example/android/livecubes/cube2/CubeWallpaper2.java +++ b/samples/CubeLiveWallpaper/src/com/example/android/livecubes/cube2/CubeWallpaper2.java @@ -138,8 +138,8 @@ public class CubeWallpaper2 extends WallpaperService { for (int i = 0; i < numlines; i++) { mLines[i] = new ThreeDLine(); String [] idx = l[i].split(" "); - mLines[i].startPoint = Integer.valueOf(idx[0]); - mLines[i].endPoint = Integer.valueOf(idx[1]); + mLines[i].startPoint = Integer.parseInt(idx[0]); + mLines[i].endPoint = Integer.parseInt(idx[1]); } } diff --git a/samples/browseable/AutoBackupForApps/src/com.example.android.autobackupsample/AddFileActivity.java b/samples/browseable/AutoBackupForApps/src/com.example.android.autobackupsample/AddFileActivity.java index 00cd1e35c..64f2912fb 100644 --- a/samples/browseable/AutoBackupForApps/src/com.example.android.autobackupsample/AddFileActivity.java +++ b/samples/browseable/AutoBackupForApps/src/com.example.android.autobackupsample/AddFileActivity.java @@ -161,7 +161,7 @@ public class AddFileActivity extends Activity { return; } - long fileSize = Integer.valueOf(fileSizeEditTextValue) * mSizeMultiplier; + long fileSize = Long.parseLong(fileSizeEditTextValue) * mSizeMultiplier; if (mFileStorage == FileStorage.EXTERNAL && !Utils.isExternalStorageAvailable()) { Toast toast = Toast.makeText(this, diff --git a/samples/training/device-management-policy/src/com/example/training/deviceadmin/PolicySetupActivity.java b/samples/training/device-management-policy/src/com/example/training/deviceadmin/PolicySetupActivity.java index 8c7381bf2..56ab79898 100644 --- a/samples/training/device-management-policy/src/com/example/training/deviceadmin/PolicySetupActivity.java +++ b/samples/training/device-management-policy/src/com/example/training/deviceadmin/PolicySetupActivity.java @@ -260,13 +260,13 @@ public class PolicySetupActivity extends Activity { int passwordLength = 0; try { - passwordLength = Integer.valueOf(mPasswordLengthInputField.getText().toString()); + passwordLength = Integer.parseInt(mPasswordLengthInputField.getText().toString()); } catch (NumberFormatException nfe) {} // Defaults to 0. int passwordMinUppercase = 0; try { passwordMinUppercase = - Integer.valueOf(mPasswordMinUppercaseInputField.getText().toString()); + Integer.parseInt(mPasswordMinUppercaseInputField.getText().toString()); } catch (NumberFormatException nfe) {} // Defaults to 0. mPolicy.saveToLocal(passwordQuality, passwordLength, passwordMinUppercase);