public void stopCapture() { stopGps(); hideNotificationTray(); currentCapture.stopTime = new Date().getTime(); if (currentCapture.points.size() > 0) { Upload.Route routePb = currentCapture.seralize(); File file = new File(getFilesDir(), "route_" + currentCapture.id + ".pb"); FileOutputStream os; try { os = new FileOutputStream(file); routePb.writeDelimitedTo(os); os.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } capturing = false; currentCapture = null; }
public void onLocationChanged(Location location) { Log.i("", "onLocationChanged: " + location); if (atStop() && lastLocation != null && distanceFromLocation(currentStop.location, lastLocation) > MIN_DISTANCE * 2) { captureActivity.triggerTransitStopDepature(); } if (currentCapture != null && location.getAccuracy() < MIN_ACCURACY * 2) { RoutePoint rp = new RoutePoint(); rp.location = location; rp.time = SystemClock.elapsedRealtime(); currentCapture.points.add(rp); if (lastLocation != null) { currentCapture.distance += distanceFromLocation(lastLocation, location); if (captureActivity != null) captureActivity.updateDistance(); } lastLocation = location; if (captureActivity != null) captureActivity.updateGpsStatus(); } }
public void startCapture() throws NoCurrentCaptureException { startGps(); showNotificationTray(); if (currentCapture != null) { currentCapture.startTime = SystemClock.elapsedRealtime(); capturing = true; } else { throw new NoCurrentCaptureException(); } }
public void newCapture(String name, String description, String notes) { startGps(); showNotificationTray(); synchronized (this) { if (currentCapture != null && capturing) stopCapture(); lastLocation = null; Integer id = prefsManager.getInt("routeId", 10000); id++; prefsManager.edit().putInt("routeId", id).commit(); currentCapture = new RouteCapture(); currentCapture.id = id; currentCapture.setRouteName(name); currentCapture.description = description; currentCapture.notes = notes; } }