mirror of
https://codeberg.org/OpenTracksApp/OpenTracks.git
synced 2026-10-02 17:43:06 +02:00
Cleanup using AndroidStudio code analyzer.
Moved to iterator for loops for ChartView and ChartFragment.
This commit is contained in:
-1
@@ -311,7 +311,6 @@ public class CustomContentProviderUtilsTest {
|
||||
// Bottom
|
||||
long startTime = 1000L;
|
||||
// AverageSpeed
|
||||
double minGrade = -20.11;
|
||||
TrackStatistics statistics = new TrackStatistics();
|
||||
statistics.setStartTime_ms(startTime);
|
||||
statistics.setStopTime_ms(2500L);
|
||||
|
||||
@@ -26,7 +26,7 @@ import de.dennisguse.opentracks.content.provider.ContentProviderUtils;
|
||||
*
|
||||
* @author Jimmy Shih
|
||||
*/
|
||||
public class DeleteAsyncTask extends AsyncTask<Void, Integer, Boolean> {
|
||||
class DeleteAsyncTask extends AsyncTask<Void, Integer, Boolean> {
|
||||
|
||||
private final long[] trackIds;
|
||||
private final Context context;
|
||||
|
||||
@@ -443,7 +443,7 @@ public class TrackListActivity extends AbstractListActivity implements ConfirmDe
|
||||
/**
|
||||
* Shows start up dialogs.
|
||||
*/
|
||||
public void showStartupDialogs() {
|
||||
private void showStartupDialogs() {
|
||||
// If stats_units_key is undefined, set it
|
||||
if (PreferencesUtils.getString(this, R.string.stats_units_key, "").equals("")) {
|
||||
String statsUnits = getString(Locale.US.equals(Locale.getDefault()) ? R.string.stats_units_imperial : R.string.stats_units_metric);
|
||||
@@ -466,7 +466,6 @@ public class TrackListActivity extends AbstractListActivity implements ConfirmDe
|
||||
* @param isRecording true if recording
|
||||
*/
|
||||
private void updateMenuItems(boolean isGpsStarted, boolean isRecording) {
|
||||
boolean hasTrack = listView != null && listView.getCount() != 0;
|
||||
if (startGpsMenuItem != null) {
|
||||
startGpsMenuItem.setVisible(!isRecording);
|
||||
if (!isRecording) {
|
||||
|
||||
@@ -86,7 +86,7 @@ public class ChartView extends View {
|
||||
private final ChartValueSeries speedSeries;
|
||||
private final ChartValueSeries paceSeries;
|
||||
|
||||
private final List<ChartPoint> chartData = new ArrayList<>();
|
||||
private final List<ChartPoint> chartPoints = new ArrayList<>();
|
||||
private final List<Waypoint> waypoints = new ArrayList<>();
|
||||
private final ExtremityMonitor xExtremityMonitor = new ExtremityMonitor();
|
||||
private final Paint axisPaint;
|
||||
@@ -396,23 +396,13 @@ public class ChartView extends View {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets show pointer.
|
||||
*
|
||||
* @param value true to show pointer
|
||||
*/
|
||||
public void setShowPointer(boolean value) {
|
||||
showPointer = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds data points.
|
||||
*
|
||||
* @param dataPoints an array of data points to be added
|
||||
*/
|
||||
public void addChartPoints(List<ChartPoint> dataPoints) {
|
||||
synchronized (chartData) {
|
||||
chartData.addAll(dataPoints);
|
||||
synchronized (chartPoints) {
|
||||
chartPoints.addAll(dataPoints);
|
||||
for (ChartPoint dataPoint : dataPoints) {
|
||||
xExtremityMonitor.update(dataPoint.getTimeOrDistance());
|
||||
for (ChartValueSeries i : seriesList) {
|
||||
@@ -428,8 +418,8 @@ public class ChartView extends View {
|
||||
* Clears all data.
|
||||
*/
|
||||
public void reset() {
|
||||
synchronized (chartData) {
|
||||
chartData.clear();
|
||||
synchronized (chartPoints) {
|
||||
chartPoints.clear();
|
||||
xExtremityMonitor.reset();
|
||||
zoomLevel = 1;
|
||||
updateDimensions();
|
||||
@@ -437,50 +427,34 @@ public class ChartView extends View {
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets scroll. To be called on the UI thread.
|
||||
* Resets scroll.
|
||||
* To be called on the UI thread.
|
||||
*/
|
||||
public void resetScroll() {
|
||||
scrollTo(0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a waypoint.
|
||||
*
|
||||
* @param waypoint the waypoint
|
||||
*/
|
||||
public void addWaypoint(Waypoint waypoint) {
|
||||
synchronized (waypoints) {
|
||||
waypoints.add(waypoint);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the waypoints.
|
||||
*/
|
||||
public void clearWaypoints() {
|
||||
synchronized (waypoints) {
|
||||
waypoints.clear();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if can zoom in.
|
||||
*/
|
||||
public boolean canZoomIn() {
|
||||
private boolean canZoomIn() {
|
||||
return zoomLevel < MAX_ZOOM_LEVEL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if can zoom out.
|
||||
*/
|
||||
public boolean canZoomOut() {
|
||||
private boolean canZoomOut() {
|
||||
return zoomLevel > MIN_ZOOM_LEVEL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Zooms in one level.
|
||||
*/
|
||||
public void zoomIn() {
|
||||
private void zoomIn() {
|
||||
if (canZoomIn()) {
|
||||
zoomLevel++;
|
||||
updatePaths();
|
||||
@@ -488,10 +462,7 @@ public class ChartView extends View {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Zooms out one level.
|
||||
*/
|
||||
public void zoomOut() {
|
||||
private void zoomOut() {
|
||||
if (canZoomOut()) {
|
||||
zoomLevel--;
|
||||
scroller.abortAnimation();
|
||||
@@ -511,7 +482,7 @@ public class ChartView extends View {
|
||||
*
|
||||
* @param velocityX velocity of fling in pixels per second
|
||||
*/
|
||||
public void fling(int velocityX) {
|
||||
private void fling(int velocityX) {
|
||||
int maxWidth = effectiveWidth * (zoomLevel - 1);
|
||||
scroller.fling(getScrollX(), 0, velocityX, 0, 0, maxWidth, 0, 0);
|
||||
invalidate();
|
||||
@@ -522,7 +493,7 @@ public class ChartView extends View {
|
||||
*
|
||||
* @param deltaX the number of pixels to scroll
|
||||
*/
|
||||
public void scrollBy(int deltaX) {
|
||||
private void scrollBy(int deltaX) {
|
||||
int scrollX = getScrollX() + deltaX;
|
||||
if (scrollX < 0) {
|
||||
scrollX = 0;
|
||||
@@ -566,7 +537,7 @@ public class ChartView extends View {
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
synchronized (chartData) {
|
||||
synchronized (chartPoints) {
|
||||
canvas.save();
|
||||
|
||||
canvas.drawColor(Color.WHITE);
|
||||
@@ -623,11 +594,7 @@ public class ChartView extends View {
|
||||
*/
|
||||
private void drawWaypoints(Canvas canvas) {
|
||||
synchronized (waypoints) {
|
||||
for (int i = 0; i < waypoints.size(); i++) {
|
||||
final Waypoint waypoint = waypoints.get(i);
|
||||
if (waypoint.getLocation() == null) {
|
||||
continue;
|
||||
}
|
||||
for (Waypoint waypoint : waypoints) {
|
||||
double xValue = getWaypointXValue(waypoint);
|
||||
if (xValue > maxX) {
|
||||
continue;
|
||||
@@ -729,9 +696,6 @@ public class ChartView extends View {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the x axis label.
|
||||
*/
|
||||
private String getXAxisLabel() {
|
||||
Context context = getContext();
|
||||
if (chartByDistance) {
|
||||
@@ -755,9 +719,6 @@ public class ChartView extends View {
|
||||
canvas.drawText(marker, getX(value), topBorder + effectiveHeight + spacing + rect.height(), xAxisMarkerPaint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the x axis interval.
|
||||
*/
|
||||
private double getXAxisInterval() {
|
||||
double interval = maxX / zoomLevel / TARGET_X_AXIS_INTERVALS;
|
||||
if (interval < 1) {
|
||||
@@ -772,16 +733,13 @@ public class ChartView extends View {
|
||||
return interval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the x axis marker positions.
|
||||
*/
|
||||
private List<Double> getXAxisMarkerPositions(double interval) {
|
||||
List<Double> markers = new ArrayList<>();
|
||||
markers.add(0d);
|
||||
for (int i = 1; i * interval < maxX; i++) {
|
||||
markers.add(i * interval);
|
||||
}
|
||||
// At least 2 markers
|
||||
|
||||
if (markers.size() < 2) {
|
||||
markers.add(maxX);
|
||||
}
|
||||
@@ -798,6 +756,7 @@ public class ChartView extends View {
|
||||
int y = topBorder;
|
||||
canvas.drawLine(x, y, x, y + effectiveHeight, axisPaint);
|
||||
|
||||
//TODO
|
||||
int markerXPosition = x - spacer;
|
||||
for (int i = 0; i < seriesList.size(); i++) {
|
||||
int index = seriesList.size() - 1 - i;
|
||||
@@ -850,23 +809,6 @@ public class ChartView extends View {
|
||||
* @param canvas the canvas
|
||||
*/
|
||||
private void drawPointer(Canvas canvas) {
|
||||
//TODO pass chartValueSeries to 2nd if
|
||||
// int index = -1;
|
||||
// for (int i = 0; i < seriesList.size(); i++) {
|
||||
// ChartValueSeries chartValueSeries = seriesList.get(i);
|
||||
// if (chartValueSeries.isEnabled() && chartValueSeries.hasData()) {
|
||||
// index = i;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// if (index != -1 && chartData.size() > 0) {
|
||||
// int dx = getX(maxX) - pointer.getIntrinsicWidth() / 2;
|
||||
// int dy = getY(seriesList.get(index), chartData.get(chartData.size() - 1)[index + 1])
|
||||
// - pointer.getIntrinsicHeight();
|
||||
// canvas.translate(dx, dy);
|
||||
// pointer.draw(canvas);
|
||||
// }
|
||||
|
||||
ChartValueSeries firstChartValueSeries = null;
|
||||
for (ChartValueSeries chartValueSeries : seriesList) {
|
||||
if (chartValueSeries.isEnabled() && chartValueSeries.hasData()) {
|
||||
@@ -874,9 +816,9 @@ public class ChartView extends View {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (firstChartValueSeries != null && chartData.size() > 0) {
|
||||
if (firstChartValueSeries != null && chartPoints.size() > 0) {
|
||||
int dx = getX(maxX) - pointer.getIntrinsicWidth() / 2;
|
||||
double value = firstChartValueSeries.extractDataFromChartPoint(chartData.get(chartData.size() - 1));
|
||||
double value = firstChartValueSeries.extractDataFromChartPoint(chartPoints.get(chartPoints.size() - 1));
|
||||
int dy = getY(firstChartValueSeries, value) - pointer.getIntrinsicHeight();
|
||||
canvas.translate(dx, dy);
|
||||
pointer.draw(canvas);
|
||||
@@ -884,10 +826,11 @@ public class ChartView extends View {
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates paths. The path needs to be updated any time after the data or the dimensions change.
|
||||
* Updates paths.
|
||||
* The path needs to be updated any time after the data or the dimensions change.
|
||||
*/
|
||||
private void updatePaths() {
|
||||
synchronized (chartData) {
|
||||
synchronized (chartPoints) {
|
||||
for (ChartValueSeries chartValueSeries : seriesList) {
|
||||
chartValueSeries.getPath().reset();
|
||||
}
|
||||
@@ -896,26 +839,23 @@ public class ChartView extends View {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws all paths.
|
||||
*/
|
||||
private void drawPaths() {
|
||||
boolean[] hasMoved = new boolean[seriesList.size()];
|
||||
|
||||
for (ChartPoint dataPoint : chartData) {
|
||||
for (int j = 0; j < seriesList.size(); j++) {
|
||||
ChartValueSeries chartValueSeries = seriesList.get(j);
|
||||
for (ChartPoint dataPoint : chartPoints) {
|
||||
for (int i = 0; i < seriesList.size(); i++) {
|
||||
ChartValueSeries chartValueSeries = seriesList.get(i);
|
||||
|
||||
|
||||
double value = chartValueSeries.extractDataFromChartPoint(dataPoint);
|
||||
if (Double.isNaN(value)) {
|
||||
if (chartValueSeries.isChartPointValid(dataPoint)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
double value = chartValueSeries.extractDataFromChartPoint(dataPoint);
|
||||
Path path = chartValueSeries.getPath();
|
||||
int x = getX(dataPoint.getTimeOrDistance());
|
||||
int y = getY(chartValueSeries, value);
|
||||
if (!hasMoved[j]) {
|
||||
hasMoved[j] = true;
|
||||
if (!hasMoved[i]) {
|
||||
hasMoved[i] = true;
|
||||
path.moveTo(x, y);
|
||||
} else {
|
||||
path.lineTo(x, y);
|
||||
@@ -924,24 +864,20 @@ public class ChartView extends View {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes all paths.
|
||||
*/
|
||||
private void closePaths() {
|
||||
for (int i = 0; i < seriesList.size(); i++) {
|
||||
ChartValueSeries chartValueSeries = seriesList.get(i);
|
||||
for (ChartValueSeries chartValueSeries : seriesList) {
|
||||
int first = getFirstPopulatedChartDataIndex(chartValueSeries);
|
||||
|
||||
if (first != -1) {
|
||||
int xCorner = getX(chartData.get(first).getTimeOrDistance());
|
||||
int xCorner = getX(chartPoints.get(first).getTimeOrDistance());
|
||||
int yCorner = topBorder + effectiveHeight;
|
||||
Path path = chartValueSeries.getPath();
|
||||
// Bottom right corner
|
||||
path.lineTo(getX(chartData.get(chartData.size() - 1).getTimeOrDistance()), yCorner);
|
||||
path.lineTo(getX(chartPoints.get(chartPoints.size() - 1).getTimeOrDistance()), yCorner);
|
||||
// Bottom left corner
|
||||
path.lineTo(xCorner, yCorner);
|
||||
// Top right corner
|
||||
double value = chartValueSeries.extractDataFromChartPoint(chartData.get(first));
|
||||
double value = chartValueSeries.extractDataFromChartPoint(chartPoints.get(first));
|
||||
path.lineTo(xCorner, getY(chartValueSeries, value));
|
||||
}
|
||||
}
|
||||
@@ -949,11 +885,11 @@ public class ChartView extends View {
|
||||
|
||||
/**
|
||||
* Finds the index of the first data point containing data for a series.
|
||||
* Returns -1 if no data point contains data for the series.
|
||||
* @return -1 if no data point contains data for the series.
|
||||
*/
|
||||
private int getFirstPopulatedChartDataIndex(ChartValueSeries chartValueSeries) {
|
||||
for (int i = 0; i < chartData.size(); i++) {
|
||||
if (chartValueSeries.isChartPointValid(chartData.get(i))) {
|
||||
for (int i = 0; i < chartPoints.size(); i++) {
|
||||
if (chartValueSeries.isChartPointValid(chartPoints.get(i))) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
@@ -973,8 +909,7 @@ public class ChartView extends View {
|
||||
yAxisOffset = (int) (density * Y_AXIS_OFFSET);
|
||||
|
||||
int markerLength = 0;
|
||||
for (int i = 0; i < seriesList.size(); i++) {
|
||||
ChartValueSeries chartValueSeries = seriesList.get(i);
|
||||
for (ChartValueSeries chartValueSeries : seriesList) {
|
||||
if (chartValueSeries.isEnabled() && chartValueSeries.hasData() || allowIfEmpty(chartValueSeries)) {
|
||||
Rect rect = getRect(chartValueSeries.getMarkerPaint(), chartValueSeries.getLargestMarker());
|
||||
markerLength += rect.width() + spacer;
|
||||
@@ -1070,7 +1005,7 @@ public class ChartView extends View {
|
||||
* Returns true if the index is allowed when the chartData is empty.
|
||||
*/
|
||||
private boolean allowIfEmpty(ChartValueSeries chartValueSeries) {
|
||||
if (!chartData.isEmpty()) {
|
||||
if (!chartPoints.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -222,18 +222,6 @@ public class TrackDataHub implements SharedPreferences.OnSharedPreferenceChangeL
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reloads data for a {@link TrackDataListener}.
|
||||
*/
|
||||
public void reloadDataForListener(final TrackDataListener trackDataListener) {
|
||||
runInHandlerThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
loadDataForListener(trackDataListener);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the selected track is recording.
|
||||
*/
|
||||
|
||||
@@ -69,7 +69,7 @@ public class ContentProviderUtils {
|
||||
* Maximum number of waypoints that will be loaded at one time.
|
||||
*/
|
||||
public static final int MAX_LOADED_WAYPOINTS_POINTS = 10000;
|
||||
public static final String ID_SEPARATOR = ",";
|
||||
private static final String ID_SEPARATOR = ",";
|
||||
|
||||
private final IContentResolver contentResolver;
|
||||
private int defaultCursorBatchSize = 2000;
|
||||
|
||||
@@ -15,14 +15,14 @@ import de.dennisguse.opentracks.content.data.WaypointsColumns;
|
||||
* Database helper for creating and upgrading the database.
|
||||
*/
|
||||
@VisibleForTesting
|
||||
public class CustomSQLiteOpenHelper extends SQLiteOpenHelper {
|
||||
class CustomSQLiteOpenHelper extends SQLiteOpenHelper {
|
||||
|
||||
@VisibleForTesting
|
||||
static final int DATABASE_VERSION = 25;
|
||||
private static final int DATABASE_VERSION = 25;
|
||||
private static final String TAG = CustomSQLiteOpenHelper.class.getSimpleName();
|
||||
|
||||
@VisibleForTesting
|
||||
static final String DATABASE_NAME = "database.db";
|
||||
private static final String DATABASE_NAME = "database.db";
|
||||
|
||||
|
||||
public CustomSQLiteOpenHelper(Context context) {
|
||||
|
||||
@@ -43,7 +43,7 @@ public class ShareContentProvider extends CustomContentProvider implements ICont
|
||||
|
||||
private static final String[] COLUMNS = {OpenableColumns.DISPLAY_NAME, OpenableColumns.SIZE};
|
||||
|
||||
public static final String TAG = ShareContentProvider.class.getSimpleName();
|
||||
private static final String TAG = ShareContentProvider.class.getSimpleName();
|
||||
|
||||
private static final int URI_GPX = 0;
|
||||
private static final int URI_KML_ONLY = 1;
|
||||
@@ -90,7 +90,7 @@ public class ShareContentProvider extends CustomContentProvider implements ICont
|
||||
return new Pair<>(uri, mime);
|
||||
}
|
||||
|
||||
protected static long[] parseURI(Uri uri) {
|
||||
static long[] parseURI(Uri uri) {
|
||||
List<String> uriPaths = uri.getPathSegments();
|
||||
if (uriPaths == null || uriPaths.size() < 2) {
|
||||
Log.d(TAG, "URI does not contain any trackIds.");
|
||||
@@ -151,7 +151,7 @@ public class ShareContentProvider extends CustomContentProvider implements ICont
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static String getTypeMime(@NonNull Uri uri) {
|
||||
private static String getTypeMime(@NonNull Uri uri) {
|
||||
return getTrackFileFormat(uri).getMimeType();
|
||||
}
|
||||
|
||||
|
||||
@@ -298,16 +298,6 @@ public class ChartFragment extends Fragment implements TrackDataListener {
|
||||
return trackDataHub != null && trackDataHub.isSelectedTrackRecording();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reloads the trackDataHub.
|
||||
* Needs to be synchronized because trackDataHub can be accessed by multiple threads.
|
||||
*/
|
||||
private synchronized void reloadTrackDataHub() {
|
||||
if (trackDataHub != null) {
|
||||
trackDataHub.reloadDataForListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs a runnable on the UI thread if possible.
|
||||
*
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ import de.dennisguse.opentracks.util.ResourceUtils;
|
||||
*
|
||||
* @author apoorvn
|
||||
*/
|
||||
public class ChooseActivityTypeImageAdapter extends BaseAdapter {
|
||||
class ChooseActivityTypeImageAdapter extends BaseAdapter {
|
||||
|
||||
private final List<Integer> imageIds;
|
||||
private int selected = -1;
|
||||
|
||||
@@ -40,7 +40,7 @@ import de.dennisguse.opentracks.util.SystemUtils;
|
||||
* @author Jimmy Shih
|
||||
*/
|
||||
//TODO Make independent from ExportActivity?
|
||||
public class ExportAsyncTask extends AsyncTask<Void, Integer, Boolean> {
|
||||
class ExportAsyncTask extends AsyncTask<Void, Integer, Boolean> {
|
||||
|
||||
private static final String TAG = ExportAsyncTask.class.getSimpleName();
|
||||
private final TrackFileFormat trackFileFormat;
|
||||
@@ -70,18 +70,6 @@ public class ExportAsyncTask extends AsyncTask<Void, Integer, Boolean> {
|
||||
contentProviderUtils = new ContentProviderUtils(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the current activity associated with this AsyncTask.
|
||||
*
|
||||
* @param exportActivity the current activity, can be null
|
||||
*/
|
||||
public void setActivity(ExportActivity exportActivity) {
|
||||
this.exportActivity = exportActivity;
|
||||
if (completed && exportActivity != null) {
|
||||
exportActivity.onAsyncTaskCompleted(processedTrackCount, totalTrackCount);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
if (exportActivity != null) {
|
||||
|
||||
@@ -41,7 +41,7 @@ import de.dennisguse.opentracks.util.SystemUtils;
|
||||
*
|
||||
* @author Jimmy Shih
|
||||
*/
|
||||
public class ImportAsyncTask extends AsyncTask<Void, Integer, Boolean> {
|
||||
class ImportAsyncTask extends AsyncTask<Void, Integer, Boolean> {
|
||||
|
||||
private static final String TAG = ImportAsyncTask.class.getSimpleName();
|
||||
private final TrackFileFormat trackFileFormat;
|
||||
@@ -81,18 +81,6 @@ public class ImportAsyncTask extends AsyncTask<Void, Integer, Boolean> {
|
||||
trackId = -1L;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the current {@link ImportActivity} associated with this AyncTask.
|
||||
*
|
||||
* @param importActivity the current {@link ImportActivity}, can be null
|
||||
*/
|
||||
public void setActivity(ImportActivity importActivity) {
|
||||
this.importActivity = importActivity;
|
||||
if (completed && importActivity != null) {
|
||||
importActivity.onAsyncTaskCompleted(importTrackCount, totalTrackCount);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
if (importActivity != null) {
|
||||
|
||||
@@ -22,7 +22,7 @@ import java.io.InputStream;
|
||||
*
|
||||
* @author Jimmy Shih
|
||||
*/
|
||||
public interface TrackImporter {
|
||||
interface TrackImporter {
|
||||
|
||||
/**
|
||||
* Import a file.
|
||||
|
||||
@@ -21,7 +21,7 @@ package de.dennisguse.opentracks.services;
|
||||
*
|
||||
* @author Sandor Dornbush
|
||||
*/
|
||||
public interface LocationListenerPolicy {
|
||||
interface LocationListenerPolicy {
|
||||
|
||||
/**
|
||||
* Returns the polling interval this policy would like at this moment.
|
||||
|
||||
+1
-1
@@ -70,7 +70,7 @@ public class TrackRecordingServiceConnection implements ServiceConnection, Death
|
||||
/**
|
||||
* Binds the service if it is started.
|
||||
*/
|
||||
public void bindIfStarted(Context context) {
|
||||
private void bindIfStarted(Context context) {
|
||||
bindService(context, false);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,6 @@ import de.dennisguse.opentracks.util.UnitConversions;
|
||||
public class PeriodicTaskExecutor {
|
||||
|
||||
private static final String TAG = PeriodicTaskExecutor.class.getSimpleName();
|
||||
private static final long MINUTE_TO_MILLISECONDS = 60000L;
|
||||
|
||||
private final TrackRecordingService trackRecordingService;
|
||||
private final PeriodicTaskFactory periodicTaskFactory;
|
||||
@@ -93,7 +92,7 @@ public class PeriodicTaskExecutor {
|
||||
if (timerTaskExecutor == null) {
|
||||
timerTaskExecutor = new TimerTaskExecutor(periodicTask, trackRecordingService);
|
||||
}
|
||||
timerTaskExecutor.scheduleTask(taskFrequency * MINUTE_TO_MILLISECONDS);
|
||||
timerTaskExecutor.scheduleTask(taskFrequency * UnitConversions.ONE_MINUTE_MS);
|
||||
} else {
|
||||
// For distance periodic task
|
||||
calculateNextTaskDistance();
|
||||
|
||||
@@ -23,7 +23,7 @@ import android.content.Context;
|
||||
*
|
||||
* @author Sandor Dornbush
|
||||
*/
|
||||
public interface PeriodicTaskFactory {
|
||||
interface PeriodicTaskFactory {
|
||||
|
||||
/**
|
||||
* Creates a {@link PeriodicTask}.
|
||||
|
||||
@@ -48,7 +48,7 @@ public class SettingsActivity extends AppCompatActivity implements ChooseActivit
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.settings_fragment, prefsFragment).commit();
|
||||
}
|
||||
|
||||
public static class PrefsFragment extends PreferenceFragmentCompat {
|
||||
private static class PrefsFragment extends PreferenceFragmentCompat {
|
||||
|
||||
private final SharedPreferences.OnSharedPreferenceChangeListener sharedPreferenceChangeListener = new SharedPreferences.OnSharedPreferenceChangeListener() {
|
||||
@Override
|
||||
|
||||
@@ -25,7 +25,7 @@ import androidx.annotation.NonNull;
|
||||
*
|
||||
* @author Sandor Dornbush
|
||||
*/
|
||||
public class DoubleBuffer {
|
||||
class DoubleBuffer {
|
||||
|
||||
// The sliding buffer of doubles.
|
||||
private final double[] buffer;
|
||||
|
||||
@@ -41,7 +41,7 @@ public class AnnouncementUtils {
|
||||
return context.getString(R.string.voice_template, totalDistance, getAnnounceTime(context, trackStatistics.getMovingTime()), rate);
|
||||
}
|
||||
|
||||
public static String getAnnounceTime(Context context, long time) {
|
||||
private static String getAnnounceTime(Context context, long time) {
|
||||
int[] parts = StringUtils.getTimeParts(time);
|
||||
String seconds = context.getResources()
|
||||
.getQuantityString(R.plurals.voiceSeconds, parts[0], parts[0]);
|
||||
@@ -71,7 +71,7 @@ public class AnnouncementUtils {
|
||||
*
|
||||
* @param d the double value
|
||||
*/
|
||||
public static int getQuantityCount(double d) {
|
||||
private static int getQuantityCount(double d) {
|
||||
if (d == 0) {
|
||||
return 0;
|
||||
} else if (d == 1) {
|
||||
|
||||
@@ -93,7 +93,7 @@ public class PreferencesUtils {
|
||||
* @param keyId the key id
|
||||
* @param defaultValue the default value
|
||||
*/
|
||||
public static boolean getBoolean(Context context, int keyId, boolean defaultValue) {
|
||||
private static boolean getBoolean(Context context, int keyId, boolean defaultValue) {
|
||||
SharedPreferences sharedPreferences = getSharedPreferences(context);
|
||||
return sharedPreferences.getBoolean(getKey(context, keyId), defaultValue);
|
||||
}
|
||||
@@ -119,7 +119,7 @@ public class PreferencesUtils {
|
||||
* @param keyId the key id
|
||||
* @param defaultValue the default value
|
||||
*/
|
||||
public static int getInt(Context context, int keyId, int defaultValue) {
|
||||
private static int getInt(Context context, int keyId, int defaultValue) {
|
||||
SharedPreferences sharedPreferences = getSharedPreferences(context);
|
||||
|
||||
try {
|
||||
@@ -215,7 +215,7 @@ public class PreferencesUtils {
|
||||
setBoolean(context, R.string.recording_track_paused_key, RECORDING_TRACK_PAUSED);
|
||||
}
|
||||
|
||||
public static String getBluetoothHeartRateSensorAddressNone(Context context) {
|
||||
private static String getBluetoothHeartRateSensorAddressNone(Context context) {
|
||||
return context.getString(R.string.sensor_type_value_none);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user