Merge pull request #1773 from andrewgaul/boxing

Avoid unneeded boxing
This commit is contained in:
Martin Fietz 2016-03-16 20:22:03 +01:00
commit 92efa25572
12 changed files with 37 additions and 37 deletions

View File

@ -184,7 +184,7 @@ public class MainActivity extends AppCompatActivity implements NavDrawerActivity
loadFragment(lastFragment, null);
} else {
try {
loadFeedFragmentById(Integer.valueOf(lastFragment), null);
loadFeedFragmentById(Integer.parseInt(lastFragment), null);
} catch (NumberFormatException e) {
// it's not a number, this happens if we removed
// a label from the NAV_DRAWER_TAGS

View File

@ -167,7 +167,7 @@ public class ItunesAdapter extends ArrayAdapter<ItunesAdapter.Podcast> {
for(int i=0; imageUrl == null && i < images.length(); i++) {
JSONObject image = images.getJSONObject(i);
String height = image.getJSONObject("attributes").getString("height");
if(Integer.valueOf(height) >= 100) {
if(Integer.parseInt(height) >= 100) {
imageUrl = image.getString("label");
}
}

View File

@ -138,7 +138,7 @@ public abstract class SleepTimerDialog {
private long readTimeMillis() {
TimeUnit selectedUnit = units[spTimeUnit.getSelectedItemPosition()];
long value = Long.valueOf(etxtTime.getText().toString());
long value = Long.parseLong(etxtTime.getText().toString());
return selectedUnit.toMillis(value);
}

View File

@ -241,7 +241,7 @@ public class PreferenceController implements SharedPreferences.OnSharedPreferenc
(preference, o) -> {
if (o instanceof String) {
try {
int value = Integer.valueOf((String) o);
int value = Integer.parseInt((String) o);
if (1 <= value && value <= 50) {
setParallelDownloadsText(value);
return true;
@ -268,7 +268,7 @@ public class PreferenceController implements SharedPreferences.OnSharedPreferenc
public void afterTextChanged(Editable s) {
if (s.length() > 0) {
try {
int value = Integer.valueOf(s.toString());
int value = Integer.parseInt(s.toString());
if (value <= 0) {
ev.setText("1");
} else if (value > 50) {
@ -343,7 +343,7 @@ public class PreferenceController implements SharedPreferences.OnSharedPreferenc
ui.findPreference(UserPreferences.PREF_IMAGE_CACHE_SIZE).setOnPreferenceChangeListener(
(preference, o) -> {
if (o instanceof String) {
int newValue = Integer.valueOf((String) o) * 1024 * 1024;
int newValue = Integer.parseInt((String) o) * 1024 * 1024;
if (newValue != UserPreferences.getImageCacheSize()) {
AlertDialog.Builder dialog = new AlertDialog.Builder(ui.getActivity());
dialog.setTitle(android.R.string.dialog_alert_title);
@ -781,7 +781,7 @@ public class PreferenceController implements SharedPreferences.OnSharedPreferenc
checkedItem = ArrayUtils.indexOf(values, currIntervalStr);
}
builder1.setSingleChoiceItems(entries, checkedItem, (dialog1, which1) -> {
int hours = Integer.valueOf(values[which1]);
int hours = Integer.parseInt(values[which1]);
UserPreferences.setUpdateInterval(hours);
dialog1.dismiss();
setUpdateIntervalText();

View File

@ -63,10 +63,10 @@ public class GpodnetEpisodeAction {
Action action = Action.valueOf(fields[3]);
GpodnetEpisodeAction result = new Builder(podcast, episode, action)
.deviceId(deviceId)
.timestamp(new Date(Long.valueOf(fields[4])))
.started(Integer.valueOf(fields[5]))
.position(Integer.valueOf(fields[6]))
.total(Integer.valueOf(fields[7]))
.timestamp(new Date(Long.parseLong(fields[4])))
.started(Integer.parseInt(fields[5]))
.position(Integer.parseInt(fields[6]))
.total(Integer.parseInt(fields[7]))
.build();
return result;
} catch(IllegalArgumentException e) {

View File

@ -158,12 +158,12 @@ public class UserPreferences {
public static int getFeedOrder() {
String value = prefs.getString(PREF_DRAWER_FEED_ORDER, "0");
return Integer.valueOf(value);
return Integer.parseInt(value);
}
public static int getFeedCounterSetting() {
String value = prefs.getString(PREF_DRAWER_FEED_COUNTER, "0");
return Integer.valueOf(value);
return Integer.parseInt(value);
}
/**
@ -243,7 +243,7 @@ public class UserPreferences {
}
public static int getSmartMarkAsPlayedSecs() {
return Integer.valueOf(prefs.getString(PREF_SMART_MARK_AS_PLAYED_SECS, "30"));
return Integer.parseInt(prefs.getString(PREF_SMART_MARK_AS_PLAYED_SECS, "30"));
}
public static boolean isAutoFlattr() {
@ -295,8 +295,8 @@ public class UserPreferences {
String datetime = prefs.getString(PREF_UPDATE_INTERVAL, "");
if(datetime.length() >= 3 && datetime.contains(":")) {
String[] parts = datetime.split(":");
int hourOfDay = Integer.valueOf(parts[0]);
int minute = Integer.valueOf(parts[1]);
int hourOfDay = Integer.parseInt(parts[0]);
int minute = Integer.parseInt(parts[1]);
return new int[] { hourOfDay, minute };
} else {
return new int[0];
@ -308,7 +308,7 @@ public class UserPreferences {
}
public static int getParallelDownloads() {
return Integer.valueOf(prefs.getString(PREF_PARALLEL_DOWNLOADS, "4"));
return Integer.parseInt(prefs.getString(PREF_PARALLEL_DOWNLOADS, "4"));
}
public static int getEpisodeCacheSizeUnlimited() {
@ -338,12 +338,12 @@ public class UserPreferences {
public static int getImageCacheSize() {
String cacheSizeString = prefs.getString(PREF_IMAGE_CACHE_SIZE, IMAGE_CACHE_DEFAULT_VALUE);
int cacheSizeInt = Integer.valueOf(cacheSizeString);
int cacheSizeInt = Integer.parseInt(cacheSizeString);
// if the cache size is too small the user won't get any images at all
// that's bad, force it back to the default.
if (cacheSizeInt < IMAGE_CACHE_SIZE_MINIMUM) {
prefs.edit().putString(PREF_IMAGE_CACHE_SIZE, IMAGE_CACHE_DEFAULT_VALUE).apply();
cacheSizeInt = Integer.valueOf(IMAGE_CACHE_DEFAULT_VALUE);
cacheSizeInt = Integer.parseInt(IMAGE_CACHE_DEFAULT_VALUE);
}
int cacheSizeMB = cacheSizeInt * 1024 * 1024;
return cacheSizeMB;
@ -494,7 +494,7 @@ public class UserPreferences {
if (valueFromPrefs.equals(context.getString(R.string.pref_episode_cache_unlimited))) {
return EPISODE_CACHE_SIZE_UNLIMITED;
} else {
return Integer.valueOf(valueFromPrefs);
return Integer.parseInt(valueFromPrefs);
}
}
@ -548,7 +548,7 @@ public class UserPreferences {
public static EpisodeCleanupAlgorithm getEpisodeCleanupAlgorithm() {
int cleanupValue = Integer.valueOf(prefs.getString(PREF_EPISODE_CLEANUP, "-1"));
int cleanupValue = Integer.parseInt(prefs.getString(PREF_EPISODE_CLEANUP, "-1"));
if (cleanupValue == EPISODE_CLEANUP_QUEUE) {
return new APQueueCleanupAlgorithm();
} else if (cleanupValue == EPISODE_CLEANUP_NULL) {

View File

@ -188,7 +188,7 @@ public class DownloadService extends Service {
if (status.getReason() == DownloadError.ERROR_UNAUTHORIZED) {
postAuthenticationNotification(downloader.getDownloadRequest());
} else if (status.getReason() == DownloadError.ERROR_HTTP_DATA_ERROR
&& Integer.valueOf(status.getReasonDetailed()) == 416) {
&& Integer.parseInt(status.getReasonDetailed()) == 416) {
Log.d(TAG, "Requested invalid range, restarting download from the beginning");
FileUtils.deleteQuietly(new File(downloader.getDownloadRequest().getDestination()));

View File

@ -180,7 +180,7 @@ public class HttpDownloader extends Downloader {
&& !TextUtils.isEmpty(contentRangeHeader)) {
String start = contentRangeHeader.substring("bytes ".length(),
contentRangeHeader.indexOf("-"));
request.setSoFar(Long.valueOf(start));
request.setSoFar(Long.parseLong(start));
Log.d(TAG, "Starting download at position " + request.getSoFar());
out = new RandomAccessFile(destination, "rw");

View File

@ -60,12 +60,12 @@ public class NSITunes extends Namespace {
try {
int duration = 0;
if (parts.length == 2) {
duration += TimeUnit.MINUTES.toMillis(Long.valueOf(parts[0])) +
TimeUnit.SECONDS.toMillis(Long.valueOf(parts[1]));
duration += TimeUnit.MINUTES.toMillis(Long.parseLong(parts[0])) +
TimeUnit.SECONDS.toMillis(Long.parseLong(parts[1]));
} else if (parts.length >= 3) {
duration += TimeUnit.HOURS.toMillis(Long.valueOf(parts[0])) +
TimeUnit.MINUTES.toMillis(Long.valueOf(parts[1])) +
TimeUnit.SECONDS.toMillis(Long.valueOf(parts[2]));
duration += TimeUnit.HOURS.toMillis(Long.parseLong(parts[0])) +
TimeUnit.MINUTES.toMillis(Long.parseLong(parts[1])) +
TimeUnit.SECONDS.toMillis(Long.parseLong(parts[2]));
} else {
return;
}

View File

@ -88,9 +88,9 @@ public final class Converter {
if (parts.length != 3) {
return 0;
}
return Integer.valueOf(parts[0]) * 3600 * 1000 +
Integer.valueOf(parts[1]) * 60 * 1000 +
Integer.valueOf(parts[2]) * 1000;
return Integer.parseInt(parts[0]) * 3600 * 1000 +
Integer.parseInt(parts[1]) * 60 * 1000 +
Integer.parseInt(parts[2]) * 1000;
}
/** Converts short duration string (HH:MM) to milliseconds. */
@ -99,8 +99,8 @@ public final class Converter {
if (parts.length != 2) {
return 0;
}
return Integer.valueOf(parts[0]) * 3600 * 1000 +
Integer.valueOf(parts[1]) * 1000 * 60;
return Integer.parseInt(parts[0]) * 3600 * 1000 +
Integer.parseInt(parts[1]) * 1000 * 60;
}
/** Converts milliseconds to a localized string containing hours and minutes */

View File

@ -115,13 +115,13 @@ public class DateUtils {
int idx = 0;
if (parts.length == 3) {
// string has hours
result += Integer.valueOf(parts[idx]) * 3600000L;
result += Integer.parseInt(parts[idx]) * 3600000L;
idx++;
}
if (parts.length >= 2) {
result += Integer.valueOf(parts[idx]) * 60000L;
result += Integer.parseInt(parts[idx]) * 60000L;
idx++;
result += (Float.valueOf(parts[idx])) * 1000L;
result += (Float.parseFloat(parts[idx])) * 1000L;
}
return result;
}

View File

@ -172,7 +172,7 @@ public class Timeline {
try {
if (m.find()) {
return Integer.valueOf(m.group(1));
return Integer.parseInt(m.group(1));
}
} catch (NumberFormatException e) {
e.printStackTrace();