diff --git a/GPSTest/src/google/java/com/android/gpstest/GpsMapFragment.java b/GPSTest/src/google/java/com/android/gpstest/GpsMapFragment.java index 4805f46f0..7d0dfbf16 100644 --- a/GPSTest/src/google/java/com/android/gpstest/GpsMapFragment.java +++ b/GPSTest/src/google/java/com/android/gpstest/GpsMapFragment.java @@ -445,11 +445,11 @@ public void setOnMapClickListener(OnMapClickListener listener) { private void checkMapPreferences() { SharedPreferences settings = Application.getPrefs(); if (mMap != null && mMapController.getMode().equals(MODE_MAP)) { - if (mMap.getMapType() != Integer.valueOf( + if (mMap.getMapType() != Integer.parseInt( settings.getString(getString(R.string.pref_key_map_type), String.valueOf(GoogleMap.MAP_TYPE_NORMAL)) )) { - mMap.setMapType(Integer.valueOf( + mMap.setMapType(Integer.parseInt( settings.getString(getString(R.string.pref_key_map_type), String.valueOf(GoogleMap.MAP_TYPE_NORMAL)) )); diff --git a/GPSTest/src/main/java/com/android/gpstest/GpsTestActivity.java b/GPSTest/src/main/java/com/android/gpstest/GpsTestActivity.java index 3c9580927..093005dad 100644 --- a/GPSTest/src/main/java/com/android/gpstest/GpsTestActivity.java +++ b/GPSTest/src/main/java/com/android/gpstest/GpsTestActivity.java @@ -238,7 +238,7 @@ public class GpsTestActivity extends AppCompatActivity private GnssAntennaInfo.Listener gnssAntennaInfoListener; // Listeners for Fragments - private List mGpsTestListeners = new ArrayList(); + private List mGpsTestListeners = new ArrayList<>(); private Location mLastLocation; @@ -619,12 +619,12 @@ private void setupStartState(Bundle savedInstanceState) { // Apply start state settings from preferences SharedPreferences settings = Application.getPrefs(); - double tempMinTime = Double.valueOf( + double tempMinTime = Double.parseDouble( settings.getString(getString(R.string.pref_key_gps_min_time), getString(R.string.pref_gps_min_time_default_sec)) ); minTime = (long) (tempMinTime * SECONDS_TO_MILLISECONDS); - minDistance = Float.valueOf( + minDistance = Float.parseFloat( settings.getString(getString(R.string.pref_key_gps_min_distance), getString(R.string.pref_gps_min_distance_default_meters)) ); @@ -980,10 +980,10 @@ private synchronized void gpsStart() { showProgressBar(); // Show Toast only if the user has set minTime or minDistance to something other than default values - if (minTime != (long) (Double.valueOf(getString(R.string.pref_gps_min_time_default_sec)) + if (minTime != (long) (Double.parseDouble(getString(R.string.pref_gps_min_time_default_sec)) * SECONDS_TO_MILLISECONDS) || minDistance != Float - .valueOf(getString(R.string.pref_gps_min_distance_default_meters))) { + .parseFloat(getString(R.string.pref_gps_min_distance_default_meters))) { Toast.makeText(this, String.format(getString(R.string.gps_set_location_listener), String.valueOf((double) minTime / SECONDS_TO_MILLISECONDS), String.valueOf(minDistance)), Toast.LENGTH_SHORT).show(); @@ -1232,9 +1232,7 @@ public void onStatusChanged(int status) { if (UIUtils.canManageDialog(GpsTestActivity.this) && (mWriteRawMeasurementToAndroidMonitor || mWriteRawMeasurementsToFile)) { new Handler(Looper.getMainLooper()).postDelayed( - () -> runOnUiThread(() -> { - Toast.makeText(GpsTestActivity.this, statusMessage, Toast.LENGTH_SHORT).show(); - }), 3000); + () -> runOnUiThread(() -> Toast.makeText(GpsTestActivity.this, statusMessage, Toast.LENGTH_SHORT).show()), 3000); } } }; @@ -1455,15 +1453,15 @@ private void promptEnableGps() { @SuppressLint("MissingPermission") private void checkTimeAndDistance(SharedPreferences settings) { double tempMinTimeDouble = Double - .valueOf(settings.getString(getString(R.string.pref_key_gps_min_time), "1")); + .parseDouble(settings.getString(getString(R.string.pref_key_gps_min_time), "1")); long minTimeLong = (long) (tempMinTimeDouble * SECONDS_TO_MILLISECONDS); if (minTime != minTimeLong || - minDistance != Float.valueOf( + minDistance != Float.parseFloat( settings.getString(getString(R.string.pref_key_gps_min_distance), "0"))) { // User changed preference values, get the new ones minTime = minTimeLong; - minDistance = Float.valueOf( + minDistance = Float.parseFloat( settings.getString(getString(R.string.pref_key_gps_min_distance), "0")); // If the GPS is started, reset the location listener with the new values if (mStarted && mProvider != null) { diff --git a/GPSTest/src/main/java/com/android/gpstest/NavigationDrawerFragment.java b/GPSTest/src/main/java/com/android/gpstest/NavigationDrawerFragment.java index 477b7bd54..e2abd36bb 100644 --- a/GPSTest/src/main/java/com/android/gpstest/NavigationDrawerFragment.java +++ b/GPSTest/src/main/java/com/android/gpstest/NavigationDrawerFragment.java @@ -143,7 +143,7 @@ public class NavigationDrawerFragment extends Fragment { }; // list of navdrawer items that were actually added to the navdrawer, in order - private List mNavDrawerItems = new ArrayList(); + private List mNavDrawerItems = new ArrayList<>(); // views that correspond to each navdrawer item, null if not yet created private View[] mNavDrawerItemViews = null; diff --git a/GPSTest/src/main/java/com/android/gpstest/util/IOUtils.java b/GPSTest/src/main/java/com/android/gpstest/util/IOUtils.java index 3a6de3de2..fc829b284 100644 --- a/GPSTest/src/main/java/com/android/gpstest/util/IOUtils.java +++ b/GPSTest/src/main/java/com/android/gpstest/util/IOUtils.java @@ -175,12 +175,12 @@ public static Location getLocationFromGeoUri(String geoUri) { String[] noPrefix = geoUri.split(":"); String[] coords = noPrefix[1].split(","); - if (isValidLatitude(Double.valueOf(coords[0])) && isValidLongitude(Double.valueOf(coords[1]))) { + if (isValidLatitude(Double.parseDouble(coords[0])) && isValidLongitude(Double.parseDouble(coords[1]))) { l = new Location("Geo URI"); - l.setLatitude(Double.valueOf(coords[0])); - l.setLongitude(Double.valueOf(coords[1])); + l.setLatitude(Double.parseDouble(coords[0])); + l.setLongitude(Double.parseDouble(coords[1])); if (coords.length == 3) { - l.setAltitude(Double.valueOf(coords[2])); + l.setAltitude(Double.parseDouble(coords[2])); } } diff --git a/GPSTest/src/main/java/com/android/gpstest/util/NmeaUtils.java b/GPSTest/src/main/java/com/android/gpstest/util/NmeaUtils.java index 62d91856f..a56532be7 100644 --- a/GPSTest/src/main/java/com/android/gpstest/util/NmeaUtils.java +++ b/GPSTest/src/main/java/com/android/gpstest/util/NmeaUtils.java @@ -112,8 +112,8 @@ public static DilutionOfPrecision getDop(String nmeaSentence) { if (!TextUtils.isEmpty(pdop) && !TextUtils.isEmpty(hdop) && !TextUtils.isEmpty(vdop)) { DilutionOfPrecision dop = null; try { - dop = new DilutionOfPrecision(Double.valueOf(pdop), Double.valueOf(hdop), - Double.valueOf(vdop)); + dop = new DilutionOfPrecision(Double.parseDouble(pdop), Double.parseDouble(hdop), + Double.parseDouble(vdop)); } catch (NumberFormatException e) { // See https://github.com/barbeau/gpstest/issues/71#issuecomment-263169174 Log.e(TAG, "Invalid DOP values in NMEA: " + nmeaSentence); diff --git a/GPSTest/src/main/java/com/android/gpstest/util/UIUtils.java b/GPSTest/src/main/java/com/android/gpstest/util/UIUtils.java index d30f9237e..9bf4c468b 100644 --- a/GPSTest/src/main/java/com/android/gpstest/util/UIUtils.java +++ b/GPSTest/src/main/java/com/android/gpstest/util/UIUtils.java @@ -533,9 +533,7 @@ public static Dialog createQrCodeDialog(AppCompatActivity activity) { .setCancelable(false) .setView(view) .setPositiveButton(R.string.ok, - (dialog, which) -> { - IOUtils.openQrCodeReader(activity); - } + (dialog, which) -> IOUtils.openQrCodeReader(activity) ).setNegativeButton(R.string.not_now, (dialog, which) -> { // No op