diff options
Diffstat (limited to 'client/activity-demo/Piztor/src/com/example/piztor/Tracker.java')
-rw-r--r-- | client/activity-demo/Piztor/src/com/example/piztor/Tracker.java | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/client/activity-demo/Piztor/src/com/example/piztor/Tracker.java b/client/activity-demo/Piztor/src/com/example/piztor/Tracker.java index ceda506..0222325 100644 --- a/client/activity-demo/Piztor/src/com/example/piztor/Tracker.java +++ b/client/activity-demo/Piztor/src/com/example/piztor/Tracker.java @@ -1,34 +1,41 @@ package com.example.piztor; - import java.util.Timer; import java.util.TimerTask; +import android.content.Context; + public class Tracker implements Runnable { - private static final long TIME_DELTA = 1000 * 60 * 5; - public final Context mContext; - + private static final long TIME_DELTA = 1000 * 10; // 10 seconds + public Timer timer; + private final Context mContext; Controller controller; - public Tracker(Controller newController) { + public Tracker(Controller newController, Context context) { + timer = new Timer(); + mContext = context; controller = newController; } - public Timer timer; public void run() { - TimerTask task = new GPSTask(); - timer.schedule(new GPSTask(), 0, TIME_DELTA); + GPSTask t = new GPSTask(); + t.run(); + //timer.s +// timer.schedule(new GPSTask(), 0, TIME_DELTA); } class GPSTask extends TimerTask { + @Override public void run() { GPSTracker tracker; - tracker = new GPSTracker(Tracker.this); - - double latitude = tracker.getLatitude(); - double longitude = tracker.getLongitude(); - - controller.recieveLocation(latitude, longitude); + tracker = new GPSTracker(mContext); + System.out.println("can get location?"); + if(tracker.canGetLocation()) { + double latitude = tracker.getLatitude(); + double longitude = tracker.getLongitude(); + System.out.println("yes!"); + controller.recieveLocation(latitude, longitude); + } } } } |