Cleanup using AndroidStudio analyze.

This commit is contained in:
Dennis Guse
2023-06-21 23:14:38 +02:00
parent 7e9b99ae1c
commit 1a5acc8f2d
24 changed files with 34 additions and 87 deletions
@@ -1,7 +1,5 @@
package de.dennisguse.opentracks.data.models;
import java.util.Objects;
public record AtmosphericPressure(float value) {
public static AtmosphericPressure ofPA(float value_Pa) {
@@ -1,9 +1,6 @@
package de.dennisguse.opentracks.data.models;
import androidx.annotation.NonNull;
import java.time.Duration;
import java.util.Objects;
public record Cadence(float value_rpm) {
@@ -1,9 +1,5 @@
package de.dennisguse.opentracks.data.models;
import androidx.annotation.NonNull;
import java.util.Objects;
public record HeartRate(float value) {
public static HeartRate of(float value) {
@@ -1,9 +1,5 @@
package de.dennisguse.opentracks.data.models;
import androidx.annotation.NonNull;
import java.util.Objects;
public record Power(float value) {
public static Power of(float value) {
@@ -45,7 +45,7 @@ import de.dennisguse.opentracks.util.StringUtils;
/**
* Convert {@link Track} incl. {@link Marker} and {@link TrackPoint} to KML version 2.3.
* https://docs.opengeospatial.org/is/12-007r2/12-007r2.html
* <a href="https://docs.opengeospatial.org/is/12-007r2/12-007r2.html">...</a>
*
* @author Sandor Dornbush
* @author Rodrigo Damazio
@@ -41,8 +41,8 @@ import de.dennisguse.opentracks.util.StringUtils;
/**
* Imports a GPX file.
* Uses:
* * https://www8.garmin.com/xmlschemas/TrackPointExtensionv2.xsd
* * https://www8.garmin.com/xmlschemas/PowerExtensionv1.xsd
* * <a href="https://www8.garmin.com/xmlschemas/TrackPointExtensionv2.xsd">...</a>
* * <a href="https://www8.garmin.com/xmlschemas/PowerExtensionv1.xsd">...</a>
* <p>
* {@link de.dennisguse.opentracks.io.file.exporter.GPXTrackExporter} does not export information if a segment was started automatic or manually.
* Therefore, all segments starts are marked as SEGMENT_START_AUTOMATIC.
@@ -135,7 +135,7 @@ public class TrackImporter {
track.setUuid(UUID.randomUUID());
}
Collections.sort(trackPoints, (o1, o2) -> {
trackPoints.sort((o1, o2) -> {
if (o1.getTime().isBefore(o2.getTime())) {
return -1;
}
@@ -65,39 +65,36 @@ public class BluetoothRemoteSensorManager implements SensorConnector, AbstractBl
private final BluetoothConnectionManagerCyclingPower cyclingPower = new BluetoothConnectionManagerCyclingPower(this);
private final BluetoothConnectionRunningSpeedAndCadence runningSpeedAndCadence = new BluetoothConnectionRunningSpeedAndCadence(this);
private final SharedPreferences.OnSharedPreferenceChangeListener sharedPreferenceChangeListener = new SharedPreferences.OnSharedPreferenceChangeListener() {
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
if (!started) return;
private final SharedPreferences.OnSharedPreferenceChangeListener sharedPreferenceChangeListener = (sharedPreferences, key) -> {
if (!started) return;
if (PreferencesUtils.isKey(R.string.settings_sensor_bluetooth_heart_rate_key, key)) {
String address = PreferencesUtils.getBluetoothHeartRateSensorAddress();
connect(heartRate, address);
}
if (PreferencesUtils.isKey(R.string.settings_sensor_bluetooth_heart_rate_key, key)) {
String address = PreferencesUtils.getBluetoothHeartRateSensorAddress();
connect(heartRate, address);
}
if (PreferencesUtils.isKey(R.string.settings_sensor_bluetooth_cycling_cadence_key, key)) {
String address = PreferencesUtils.getBluetoothCyclingCadenceSensorAddress();
connect(cyclingCadence, address);
}
if (PreferencesUtils.isKey(R.string.settings_sensor_bluetooth_cycling_cadence_key, key)) {
String address = PreferencesUtils.getBluetoothCyclingCadenceSensorAddress();
connect(cyclingCadence, address);
}
if (PreferencesUtils.isKey(R.string.settings_sensor_bluetooth_cycling_speed_key, key)) {
String address = PreferencesUtils.getBluetoothCyclingSpeedSensorAddress();
if (PreferencesUtils.isKey(R.string.settings_sensor_bluetooth_cycling_speed_key, key)) {
String address = PreferencesUtils.getBluetoothCyclingSpeedSensorAddress();
connect(cyclingSpeed, address);
}
connect(cyclingSpeed, address);
}
if (PreferencesUtils.isKey(R.string.settings_sensor_bluetooth_cycling_power_key, key)) {
String address = PreferencesUtils.getBluetoothCyclingPowerSensorAddress();
if (PreferencesUtils.isKey(R.string.settings_sensor_bluetooth_cycling_power_key, key)) {
String address = PreferencesUtils.getBluetoothCyclingPowerSensorAddress();
connect(cyclingPower, address);
}
connect(cyclingPower, address);
}
if (PreferencesUtils.isKey(R.string.settings_sensor_bluetooth_running_speed_and_cadence_key, key)) {
String address = PreferencesUtils.getBluetoothRunningSpeedAndCadenceAddress();
if (PreferencesUtils.isKey(R.string.settings_sensor_bluetooth_running_speed_and_cadence_key, key)) {
String address = PreferencesUtils.getBluetoothRunningSpeedAndCadenceAddress();
connect(runningSpeedAndCadence, address);
}
connect(runningSpeedAndCadence, address);
}
};
@@ -23,8 +23,6 @@ import android.util.Log;
import androidx.annotation.NonNull;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.UUID;
@@ -1,8 +1,5 @@
package de.dennisguse.opentracks.sensors;
import androidx.annotation.NonNull;
import java.util.Objects;
import java.util.UUID;
public record ServiceMeasurementUUID(UUID serviceUUID, UUID measurementUUID) {
@@ -1,9 +1,6 @@
package de.dennisguse.opentracks.services;
import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting;
import java.util.Objects;
import de.dennisguse.opentracks.data.models.Track;
@@ -4,7 +4,6 @@ import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -24,7 +23,7 @@ public class AggregatedStatistics {
}
dataList.addAll(dataMap.values());
Collections.sort(dataList, (o1, o2) -> {
dataList.sort((o1, o2) -> {
if (o1.getCountTracks() == o2.getCountTracks()) {
return o1.getActivityType().compareTo(o2.getActivityType());
}
@@ -35,7 +35,6 @@ public final class CsvLayoutUtils {
/**
* @param csvField Layout's field in a CSV format.
* @return List of field parts or null if it's malformed.
*/
@Nullable
public static String[] getCsvFieldParts(@Nullable String csvField) {
@@ -16,7 +16,7 @@ import de.dennisguse.opentracks.data.models.Altitude;
* Converts WGS84 altitude to EGM2008 (should be close to height above sea level).
* <p>
* Uses <a href="https://geographiclib.sourceforge.io/">GeographicLib</a>] EGM2008 5minute undulation data.
* https://geographiclib.sourceforge.io/html/geoid.html
* <a href="https://geographiclib.sourceforge.io/html/geoid.html">...</a>
* <p>
* File starts at 90N, 0E (North pole) and is encoded in parallel bands as unsigned shorts.
*/
@@ -47,7 +47,7 @@ public class FileUtils {
/**
* The maximum FAT32 path length. See the FAT32 spec at
* http://msdn.microsoft.com/en-us/windows/hardware/gg463080
* <a href="http://msdn.microsoft.com/en-us/windows/hardware/gg463080">...</a>
*/
static final int MAX_FAT32_PATH_LENGTH = 260;
@@ -232,7 +232,7 @@ public class StringUtils {
}
/**
* Gets the time, in milliseconds, from an XML date time string (ISO8601) as defined at http://www.w3.org/TR/xmlschema-2/#dateTime
* Gets the time, in milliseconds, from an XML date time string (ISO8601) as defined at <a href="http://www.w3.org/TR/xmlschema-2/#dateTime">...</a>
* Let's be lenient: if timezone information is not provided, UTC will be used.
*
* @param xmlDateTime the XML date time string