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