mirror of
https://codeberg.org/OpenTracksApp/OpenTracks.git
synced 2026-10-02 09:33:06 +02:00
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 ResourceCallback resourceCallback;
|
||||
|
||||
@@ -120,6 +120,6 @@ public abstract class AbstractTrackDeleteActivity extends AbstractActivity imple
|
||||
if (service == null) {
|
||||
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() {
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
||||
if (PreferencesUtils.isKey(TrackListActivity.this, R.string.stats_units_key, key)) {
|
||||
metricUnits = PreferencesUtils.isMetricUnits(sharedPreferences, TrackListActivity.this);
|
||||
}
|
||||
if (key != null) {
|
||||
runOnUiThread(() -> {
|
||||
TrackListActivity.this.invalidateOptionsMenu();
|
||||
loaderCallbacks.restart();
|
||||
});
|
||||
}
|
||||
private final OnSharedPreferenceChangeListener sharedPreferenceChangeListener = (sharedPreferences, key) -> {
|
||||
if (PreferencesUtils.isKey(TrackListActivity.this, R.string.stats_units_key, key)) {
|
||||
metricUnits = PreferencesUtils.isMetricUnits(sharedPreferences, TrackListActivity.this);
|
||||
}
|
||||
if (key != null) {
|
||||
runOnUiThread(() -> {
|
||||
TrackListActivity.this.invalidateOptionsMenu();
|
||||
loaderCallbacks.restart();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -92,10 +92,10 @@ public class IntervalStatisticsAdapter extends RecyclerView.Adapter<RecyclerView
|
||||
}
|
||||
|
||||
private static class ViewHolder extends RecyclerView.ViewHolder {
|
||||
TextView distance;
|
||||
TextView rate;
|
||||
TextView gain;
|
||||
TextView loss;
|
||||
final TextView distance;
|
||||
final TextView rate;
|
||||
final TextView gain;
|
||||
final TextView loss;
|
||||
|
||||
public ViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
|
||||
@@ -37,7 +37,6 @@ import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
import de.dennisguse.opentracks.BuildConfig;
|
||||
import de.dennisguse.opentracks.content.data.Altitude;
|
||||
|
||||
@@ -130,7 +130,7 @@ public class GpxTrackImporter extends DefaultHandler implements XMLImporter.Trac
|
||||
trackImporter.newTrack();
|
||||
break;
|
||||
case TAG_TRACK_SEGMENT:
|
||||
onTrackSegmentStart();
|
||||
//Nothing to do here.
|
||||
break;
|
||||
case TAG_TRACK_POINT:
|
||||
onTrackPointStart(attributes);
|
||||
@@ -236,9 +236,6 @@ public class GpxTrackImporter extends DefaultHandler implements XMLImporter.Trac
|
||||
content = "";
|
||||
}
|
||||
|
||||
private void onTrackSegmentStart() {
|
||||
}
|
||||
|
||||
private void onTrackSegmentEnd() {
|
||||
if (currentSegment.isEmpty()) {
|
||||
Log.w(TAG, "No locations in current segment.");
|
||||
|
||||
@@ -4,10 +4,6 @@ import androidx.annotation.NonNull;
|
||||
|
||||
public class ParsingException extends RuntimeException {
|
||||
|
||||
private ParsingException(@NonNull String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
protected ParsingException(@NonNull String message, Exception cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
@@ -140,17 +139,14 @@ public class TrackImporter {
|
||||
track.setUuid(UUID.randomUUID());
|
||||
}
|
||||
|
||||
Collections.sort(trackPoints, new Comparator<TrackPoint>() {
|
||||
@Override
|
||||
public int compare(TrackPoint o1, TrackPoint o2) {
|
||||
if (o1.getTime().isBefore(o2.getTime())) {
|
||||
return -1;
|
||||
}
|
||||
if (o1.getTime().isAfter(o2.getTime())) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
Collections.sort(trackPoints, (o1, o2) -> {
|
||||
if (o1.getTime().isBefore(o2.getTime())) {
|
||||
return -1;
|
||||
}
|
||||
if (o1.getTime().isAfter(o2.getTime())) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
|
||||
TrackStatisticsUpdater updater = new TrackStatisticsUpdater();
|
||||
|
||||
@@ -137,9 +137,9 @@ public class TrackDeleteService extends Service {
|
||||
}
|
||||
|
||||
public static class DeleteStatus {
|
||||
private int progress;
|
||||
private int max;
|
||||
private Track.Id trackId;
|
||||
private final int progress;
|
||||
private final int max;
|
||||
private final Track.Id trackId;
|
||||
|
||||
/**
|
||||
* @param trackId Track.Id just deleted if any.
|
||||
|
||||
@@ -240,20 +240,6 @@ public class TrackRecordingService extends Service implements HandlerServer.Hand
|
||||
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) {
|
||||
if (!isRecording() || isPaused()) {
|
||||
return null;
|
||||
|
||||
@@ -10,8 +10,6 @@ import android.util.Log;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
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 Duration SAMPLING_RATE = Duration.ofSeconds(3);
|
||||
|
||||
private boolean isConnected = false;
|
||||
|
||||
private float lastAcceptedPressureValue_hPa;
|
||||
|
||||
@@ -14,7 +14,6 @@ import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.widget.AbsListView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.appcompat.app.AppCompatDelegate;
|
||||
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) {
|
||||
AppCompatDelegate.setDefaultNightMode(PreferencesUtils.getDefaultNightMode(sharedPreferences, context));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user