forked from upstream-mirrors/OpenTracks
Fixing some nits from static analysis.
This commit is contained in:
@@ -593,7 +593,7 @@ public class ChartView extends View {
|
|||||||
|
|
||||||
final float x = getWaypointX(waypoint);
|
final float x = getWaypointX(waypoint);
|
||||||
c.drawLine(x, h - bottomBorder, x, topBorder, gridPaint);
|
c.drawLine(x, h - bottomBorder, x, topBorder, gridPaint);
|
||||||
c.translate(x - markerWidth / 2, markerHeight);
|
c.translate(x - (float) markerWidth / 2.0f, (float) markerHeight);
|
||||||
if (waypoints.get(i).getType() == Waypoint.TYPE_STATISTICS) {
|
if (waypoints.get(i).getType() == Waypoint.TYPE_STATISTICS) {
|
||||||
statsMarker.draw(c);
|
statsMarker.draw(c);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -15,6 +15,8 @@
|
|||||||
*/
|
*/
|
||||||
package com.google.android.apps.mytracks;
|
package com.google.android.apps.mytracks;
|
||||||
|
|
||||||
|
import static com.google.android.apps.mytracks.Constants.TAG;
|
||||||
|
|
||||||
import com.google.android.apps.mytracks.content.Waypoint;
|
import com.google.android.apps.mytracks.content.Waypoint;
|
||||||
import com.google.android.apps.mytracks.util.LocationUtils;
|
import com.google.android.apps.mytracks.util.LocationUtils;
|
||||||
import com.google.android.maps.GeoPoint;
|
import com.google.android.maps.GeoPoint;
|
||||||
@@ -33,6 +35,7 @@ import android.graphics.Point;
|
|||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.location.Location;
|
import android.location.Location;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -172,14 +175,18 @@ public class MapOverlay extends Overlay {
|
|||||||
*/
|
*/
|
||||||
public void addLocation(Location l) {
|
public void addLocation(Location l) {
|
||||||
// Queue up in the pending queue until it's merged with {@code #points}.
|
// Queue up in the pending queue until it's merged with {@code #points}.
|
||||||
pendingPoints.offer(new CachedLocation(l));
|
if (!pendingPoints.offer(new CachedLocation(l))) {
|
||||||
|
Log.e(TAG, "Unable to add pending points");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a segment split to the map overlay.
|
* Adds a segment split to the map overlay.
|
||||||
*/
|
*/
|
||||||
public void addSegmentSplit() {
|
public void addSegmentSplit() {
|
||||||
pendingPoints.offer(new CachedLocation());
|
if (!pendingPoints.offer(new CachedLocation())) {
|
||||||
|
Log.e(TAG, "Unable to add pending points");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addWaypoint(Waypoint wpt) {
|
public void addWaypoint(Waypoint wpt) {
|
||||||
|
|||||||
@@ -644,7 +644,7 @@ public class SendToFusionTables implements Runnable {
|
|||||||
// to fit the completion percentage range alloted to track data upload.
|
// to fit the completion percentage range alloted to track data upload.
|
||||||
double totalPercentage =
|
double totalPercentage =
|
||||||
(totalLocationsRead + totalLocationsPrepared + totalLocationsUploaded)
|
(totalLocationsRead + totalLocationsPrepared + totalLocationsUploaded)
|
||||||
/ (totalLocations * 3);
|
/ (totalLocations * 3.0);
|
||||||
|
|
||||||
double scaledPercentage = totalPercentage
|
double scaledPercentage = totalPercentage
|
||||||
* (PROGRESS_UPLOAD_DATA_MAX - PROGRESS_UPLOAD_DATA_MIN) + PROGRESS_UPLOAD_DATA_MIN;
|
* (PROGRESS_UPLOAD_DATA_MAX - PROGRESS_UPLOAD_DATA_MIN) + PROGRESS_UPLOAD_DATA_MIN;
|
||||||
|
|||||||
@@ -15,6 +15,8 @@
|
|||||||
*/
|
*/
|
||||||
package com.google.android.apps.mytracks.io.backup;
|
package com.google.android.apps.mytracks.io.backup;
|
||||||
|
|
||||||
|
import static com.google.android.apps.mytracks.Constants.TAG;
|
||||||
|
|
||||||
import com.google.android.apps.mytracks.Constants;
|
import com.google.android.apps.mytracks.Constants;
|
||||||
import com.google.android.apps.mytracks.content.TrackPointsColumns;
|
import com.google.android.apps.mytracks.content.TrackPointsColumns;
|
||||||
import com.google.android.apps.mytracks.content.TracksColumns;
|
import com.google.android.apps.mytracks.content.TracksColumns;
|
||||||
@@ -205,7 +207,9 @@ class ExternalFileBackup {
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
// We tried to delete the partially created file, but do nothing
|
// We tried to delete the partially created file, but do nothing
|
||||||
// if that also fails.
|
// if that also fails.
|
||||||
outputFile.delete();
|
if (!outputFile.delete()) {
|
||||||
|
Log.w(TAG, "Failed to delete file " + outputFile.getAbsolutePath());
|
||||||
|
}
|
||||||
|
|
||||||
throw e;
|
throw e;
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@@ -15,7 +15,10 @@
|
|||||||
*/
|
*/
|
||||||
package com.google.android.apps.mytracks.io.file;
|
package com.google.android.apps.mytracks.io.file;
|
||||||
|
|
||||||
|
import static com.google.android.apps.mytracks.Constants.TAG;
|
||||||
|
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
@@ -64,7 +67,9 @@ public class TempFileCleaner {
|
|||||||
long oldest = currentTimeMillis - 1000 * 3600;
|
long oldest = currentTimeMillis - 1000 * 3600;
|
||||||
for (File f : dir.listFiles()) {
|
for (File f : dir.listFiles()) {
|
||||||
if (f.lastModified() < oldest) {
|
if (f.lastModified() < oldest) {
|
||||||
f.delete();
|
if (!f.delete()) {
|
||||||
|
Log.w(TAG, "Failed to delete file " + f.getAbsolutePath());
|
||||||
|
}
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,8 @@
|
|||||||
*/
|
*/
|
||||||
package com.google.android.apps.mytracks.io.file;
|
package com.google.android.apps.mytracks.io.file;
|
||||||
|
|
||||||
|
import static com.google.android.apps.mytracks.Constants.TAG;
|
||||||
|
|
||||||
import com.google.android.apps.mytracks.Constants;
|
import com.google.android.apps.mytracks.Constants;
|
||||||
import com.google.android.apps.mytracks.content.MyTracksLocation;
|
import com.google.android.apps.mytracks.content.MyTracksLocation;
|
||||||
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
|
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
|
||||||
@@ -120,7 +122,9 @@ class TrackWriterImpl implements TrackWriter {
|
|||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
Log.i(Constants.TAG, "The track write was interrupted");
|
Log.i(Constants.TAG, "The track write was interrupted");
|
||||||
if (file != null) {
|
if (file != null) {
|
||||||
file.delete();
|
if (!file.delete()) {
|
||||||
|
Log.w(TAG, "Failed to delete file " + file.getAbsolutePath());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
success = false;
|
success = false;
|
||||||
errorMessage = R.string.error_operation_cancelled;
|
errorMessage = R.string.error_operation_cancelled;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.google.android.apps.mytracks.io.mymaps;
|
|||||||
|
|
||||||
import com.google.android.maps.GeoPoint;
|
import com.google.android.maps.GeoPoint;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -48,6 +49,8 @@ class MyMapsFeature {
|
|||||||
/** The metadata of this feature in a format efficient for transmission. */
|
/** The metadata of this feature in a format efficient for transmission. */
|
||||||
private MyMapsFeatureMetadata featureInfo = new MyMapsFeatureMetadata();
|
private MyMapsFeatureMetadata featureInfo = new MyMapsFeatureMetadata();
|
||||||
|
|
||||||
|
private final Random random = new Random();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes a valid but empty feature. It will default to a
|
* Initializes a valid but empty feature. It will default to a
|
||||||
* {@link #MARKER} with a blue placemark with a dot as an icon at the
|
* {@link #MARKER} with a blue placemark with a dot as an icon at the
|
||||||
@@ -61,7 +64,7 @@ class MyMapsFeature {
|
|||||||
*
|
*
|
||||||
* @param point The new point to add
|
* @param point The new point to add
|
||||||
*/
|
*/
|
||||||
public synchronized void addPoint(GeoPoint point) {
|
public void addPoint(GeoPoint point) {
|
||||||
latitudeE6.add(point.getLatitudeE6());
|
latitudeE6.add(point.getLatitudeE6());
|
||||||
longitudeE6.add(point.getLongitudeE6());
|
longitudeE6.add(point.getLongitudeE6());
|
||||||
}
|
}
|
||||||
@@ -70,10 +73,10 @@ class MyMapsFeature {
|
|||||||
* Generates a new local id for this feature based on the current time and
|
* Generates a new local id for this feature based on the current time and
|
||||||
* a random number.
|
* a random number.
|
||||||
*/
|
*/
|
||||||
public synchronized void generateAndroidId() {
|
void generateAndroidId() {
|
||||||
Long time = System.currentTimeMillis();
|
long time = System.currentTimeMillis();
|
||||||
Integer random = (int) (Math.random() * 10000);
|
int rand = random.nextInt(10000);
|
||||||
androidId = time.toString() + "." + random.toString();
|
androidId = time + "." + rand;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -81,7 +84,7 @@ class MyMapsFeature {
|
|||||||
*
|
*
|
||||||
* @return The local id for this feature
|
* @return The local id for this feature
|
||||||
*/
|
*/
|
||||||
public String getAndroidId() {
|
String getAndroidId() {
|
||||||
return androidId;
|
return androidId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
@@ -46,6 +46,8 @@ public class SensorManagerFactory {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
context = context.getApplicationContext();
|
||||||
|
|
||||||
String sensor = prefs.getString(context.getString(R.string.sensor_type_key), null);
|
String sensor = prefs.getString(context.getString(R.string.sensor_type_key), null);
|
||||||
Log.i(Constants.TAG, "Creating sensor of type: " + sensor);
|
Log.i(Constants.TAG, "Creating sensor of type: " + sensor);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user