diff options
Diffstat (limited to 'client/.metadata/.plugins/org.eclipse.core.resources/.history/5d/10ddd0bd550d00131719b896d543f08c')
-rw-r--r-- | client/.metadata/.plugins/org.eclipse.core.resources/.history/5d/10ddd0bd550d00131719b896d543f08c | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/5d/10ddd0bd550d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/5d/10ddd0bd550d00131719b896d543f08c new file mode 100644 index 0000000..5356063 --- /dev/null +++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/5d/10ddd0bd550d00131719b896d543f08c @@ -0,0 +1,68 @@ +package com.macaroon.piztor; + +import android.content.Context; +import java.util.Timer; +import java.util.TimerTask; + +import android.location.Location; +import android.content.Context; +import android.os.Handler; +import android.os.Message; +import android.util.Log; +import android.os.SystemClock; + + +public class Tracker implements Runnable { + + private static final long TIME_DELTA = 1000 * 3; // 3 second + public Timer timer; + private final Context mContext; + GPSTracker myTracker; + Handler mHandler; + Message message; + + public Tracker(Context context, Handler yHandler) { + timer = new Timer(); + mContext = context; + myTracker = new GPSTracker(mContext); + mHandler = yHandler; + } + + void setHandler(Handler hand) { + mHandler = hand; + } + + + public void run() { + GPSTask myTask = new GPSTask(); + timer.schedule(myTask, 0, TIME_DELTA); + } + + class GPSTask extends TimerTask { + @Override + public void run() { + message = new Message(); + message.what = 0; + Location location = myTracker.getLocation(); + Log.d("Location", "Fetching location....."); + if (myTracker.canGetLocation()) { + double latitude = myTracker.getLatitude(); + double longitude = myTracker.getLongitude(); + + Log.d("TTTTTTTTTTTTTTTTTTTTTTTime","TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTime"); + System.out.println("GPSTIME" + myTracker.location.getTime()); + System.out.println("SYSTIME" + SystemClock.elapsedRealtime()); + + if(myTracker.isGPSFix()) { + message.what = 1; + } else { + message.what = 2; + } + mHandler.sendMessage(message); + } else { + message.what = 0; + mHandler.sendMessage(message); + } + } + } +} |