forked from upstream-mirrors/OpenTracks
Cleanup using AndroidStudio's code analyzer.
This commit is contained in:
@@ -239,7 +239,7 @@ public class EspressoDeleteTrackTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private class MyIdlingResource implements IdlingResource {
|
private static class MyIdlingResource implements IdlingResource {
|
||||||
|
|
||||||
private final Context context;
|
private final Context context;
|
||||||
private ResourceCallback resourceCallback;
|
private ResourceCallback resourceCallback;
|
||||||
|
|||||||
@@ -120,6 +120,6 @@ public abstract class AbstractTrackDeleteActivity extends AbstractActivity imple
|
|||||||
if (service == null) {
|
if (service == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
service.getDeletingStatusObservable().observe(AbstractTrackDeleteActivity.this, status -> onTrackDeleteStatus(status));
|
service.getDeletingStatusObservable().observe(AbstractTrackDeleteActivity.this, this::onTrackDeleteStatus);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -109,18 +109,15 @@ public class TrackListActivity extends AbstractTrackDeleteActivity implements Co
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private final OnSharedPreferenceChangeListener sharedPreferenceChangeListener = new OnSharedPreferenceChangeListener() {
|
private final OnSharedPreferenceChangeListener sharedPreferenceChangeListener = (sharedPreferences, key) -> {
|
||||||
@Override
|
if (PreferencesUtils.isKey(TrackListActivity.this, R.string.stats_units_key, key)) {
|
||||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
metricUnits = PreferencesUtils.isMetricUnits(sharedPreferences, TrackListActivity.this);
|
||||||
if (PreferencesUtils.isKey(TrackListActivity.this, R.string.stats_units_key, key)) {
|
}
|
||||||
metricUnits = PreferencesUtils.isMetricUnits(sharedPreferences, TrackListActivity.this);
|
if (key != null) {
|
||||||
}
|
runOnUiThread(() -> {
|
||||||
if (key != null) {
|
TrackListActivity.this.invalidateOptionsMenu();
|
||||||
runOnUiThread(() -> {
|
loaderCallbacks.restart();
|
||||||
TrackListActivity.this.invalidateOptionsMenu();
|
});
|
||||||
loaderCallbacks.restart();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -92,10 +92,10 @@ public class IntervalStatisticsAdapter extends RecyclerView.Adapter<RecyclerView
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static class ViewHolder extends RecyclerView.ViewHolder {
|
private static class ViewHolder extends RecyclerView.ViewHolder {
|
||||||
TextView distance;
|
final TextView distance;
|
||||||
TextView rate;
|
final TextView rate;
|
||||||
TextView gain;
|
final TextView gain;
|
||||||
TextView loss;
|
final TextView loss;
|
||||||
|
|
||||||
public ViewHolder(@NonNull View itemView) {
|
public ViewHolder(@NonNull View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ import java.util.Collections;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.stream.StreamSupport;
|
|
||||||
|
|
||||||
import de.dennisguse.opentracks.BuildConfig;
|
import de.dennisguse.opentracks.BuildConfig;
|
||||||
import de.dennisguse.opentracks.content.data.Altitude;
|
import de.dennisguse.opentracks.content.data.Altitude;
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ public class GpxTrackImporter extends DefaultHandler implements XMLImporter.Trac
|
|||||||
trackImporter.newTrack();
|
trackImporter.newTrack();
|
||||||
break;
|
break;
|
||||||
case TAG_TRACK_SEGMENT:
|
case TAG_TRACK_SEGMENT:
|
||||||
onTrackSegmentStart();
|
//Nothing to do here.
|
||||||
break;
|
break;
|
||||||
case TAG_TRACK_POINT:
|
case TAG_TRACK_POINT:
|
||||||
onTrackPointStart(attributes);
|
onTrackPointStart(attributes);
|
||||||
@@ -236,9 +236,6 @@ public class GpxTrackImporter extends DefaultHandler implements XMLImporter.Trac
|
|||||||
content = "";
|
content = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onTrackSegmentStart() {
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onTrackSegmentEnd() {
|
private void onTrackSegmentEnd() {
|
||||||
if (currentSegment.isEmpty()) {
|
if (currentSegment.isEmpty()) {
|
||||||
Log.w(TAG, "No locations in current segment.");
|
Log.w(TAG, "No locations in current segment.");
|
||||||
|
|||||||
@@ -4,10 +4,6 @@ import androidx.annotation.NonNull;
|
|||||||
|
|
||||||
public class ParsingException extends RuntimeException {
|
public class ParsingException extends RuntimeException {
|
||||||
|
|
||||||
private ParsingException(@NonNull String message) {
|
|
||||||
super(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected ParsingException(@NonNull String message, Exception cause) {
|
protected ParsingException(@NonNull String message, Exception cause) {
|
||||||
super(message, cause);
|
super(message, cause);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import java.time.Duration;
|
|||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@@ -140,17 +139,14 @@ public class TrackImporter {
|
|||||||
track.setUuid(UUID.randomUUID());
|
track.setUuid(UUID.randomUUID());
|
||||||
}
|
}
|
||||||
|
|
||||||
Collections.sort(trackPoints, new Comparator<TrackPoint>() {
|
Collections.sort(trackPoints, (o1, o2) -> {
|
||||||
@Override
|
if (o1.getTime().isBefore(o2.getTime())) {
|
||||||
public int compare(TrackPoint o1, TrackPoint o2) {
|
return -1;
|
||||||
if (o1.getTime().isBefore(o2.getTime())) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (o1.getTime().isAfter(o2.getTime())) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
if (o1.getTime().isAfter(o2.getTime())) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
TrackStatisticsUpdater updater = new TrackStatisticsUpdater();
|
TrackStatisticsUpdater updater = new TrackStatisticsUpdater();
|
||||||
|
|||||||
@@ -137,9 +137,9 @@ public class TrackDeleteService extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class DeleteStatus {
|
public static class DeleteStatus {
|
||||||
private int progress;
|
private final int progress;
|
||||||
private int max;
|
private final int max;
|
||||||
private Track.Id trackId;
|
private final Track.Id trackId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param trackId Track.Id just deleted if any.
|
* @param trackId Track.Id just deleted if any.
|
||||||
|
|||||||
@@ -240,20 +240,6 @@ public class TrackRecordingService extends Service implements HandlerServer.Hand
|
|||||||
return trackStatisticsUpdater.getTrackStatistics();
|
return trackStatisticsUpdater.getTrackStatistics();
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO Throw exception, when not recording.
|
|
||||||
public Duration getTotalTime() {
|
|
||||||
if (trackStatisticsUpdater == null) {
|
|
||||||
return Duration.ofSeconds(0);
|
|
||||||
}
|
|
||||||
if (isPaused()) {
|
|
||||||
return trackStatisticsUpdater.getTrackStatistics().getTotalTime();
|
|
||||||
}
|
|
||||||
|
|
||||||
TrackStatistics statistics = trackStatisticsUpdater.getTrackStatistics();
|
|
||||||
return Duration.between(statistics.getStopTime(), Instant.now())
|
|
||||||
.plus(statistics.getTotalTime());
|
|
||||||
}
|
|
||||||
|
|
||||||
public Marker.Id insertMarker(String name, String category, String description, String photoUrl) {
|
public Marker.Id insertMarker(String name, String category, String description, String photoUrl) {
|
||||||
if (!isRecording() || isPaused()) {
|
if (!isRecording() || isPaused()) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -10,8 +10,6 @@ import android.util.Log;
|
|||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
|
|
||||||
import java.time.Duration;
|
|
||||||
|
|
||||||
import de.dennisguse.opentracks.util.PressureSensorUtils;
|
import de.dennisguse.opentracks.util.PressureSensorUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -21,8 +19,6 @@ public class AltitudeSumManager implements SensorEventListener {
|
|||||||
|
|
||||||
private static final String TAG = AltitudeSumManager.class.getSimpleName();
|
private static final String TAG = AltitudeSumManager.class.getSimpleName();
|
||||||
|
|
||||||
private static final Duration SAMPLING_RATE = Duration.ofSeconds(3);
|
|
||||||
|
|
||||||
private boolean isConnected = false;
|
private boolean isConnected = false;
|
||||||
|
|
||||||
private float lastAcceptedPressureValue_hPa;
|
private float lastAcceptedPressureValue_hPa;
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import android.view.Menu;
|
|||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.widget.AbsListView;
|
import android.widget.AbsListView;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatDelegate;
|
import androidx.appcompat.app.AppCompatDelegate;
|
||||||
import androidx.appcompat.widget.SearchView;
|
import androidx.appcompat.widget.SearchView;
|
||||||
@@ -109,12 +108,6 @@ public class ActivityUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void toast(final Activity activity, final int resId, final int duration, final int gravity) {
|
|
||||||
final Toast toast = Toast.makeText(activity, resId, duration);
|
|
||||||
toast.setGravity(gravity, 0, 0);
|
|
||||||
toast.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void applyNightMode(SharedPreferences sharedPreferences, Context context) {
|
public static void applyNightMode(SharedPreferences sharedPreferences, Context context) {
|
||||||
AppCompatDelegate.setDefaultNightMode(PreferencesUtils.getDefaultNightMode(sharedPreferences, context));
|
AppCompatDelegate.setDefaultNightMode(PreferencesUtils.getDefaultNightMode(sharedPreferences, context));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user