Search in sources :

Example 1 with MapActivity

use of com.junjunguo.pocketmaps.activities.MapActivity in project PocketMaps by junjunguo.

the class NaviDebugSimulator method runDelayed.

private void runDelayed(final Activity activity, final Location pLoc, final Location lastLoc, final int index) {
    final Handler handler = new Handler();
    handler.postDelayed(new Runnable() {

        @Override
        public void run() {
            if (debug_simulator_from_tracking && !Tracking.getTracking().isTracking()) {
                debug_simulator_run = false;
            }
            if (!debug_simulator_run) {
                return;
            }
            GeoPoint p = debug_simulator_points.get(index);
            int newIndex = checkDistance(index, p);
            p = checkP;
            final MapActivity cur = ((MapActivity) activity);
            pLoc.setLatitude(p.getLatitude());
            pLoc.setLongitude(p.getLongitude());
            float bearing = lastLoc.bearingTo(pLoc);
            lastLoc.set(pLoc);
            pLoc.setBearing(bearing);
            pLoc.setSpeed(5.55f);
            cur.onLocationChanged(pLoc);
            log("Update position for Debug purpose! Lat=" + pLoc.getLatitude() + " Lon=" + pLoc.getLongitude());
            if (debug_simulator_points.size() > newIndex) {
                runDelayed(activity, pLoc, lastLoc, newIndex);
            }
        }
    }, 2000);
}
Also used : GeoPoint(org.oscim.core.GeoPoint) Handler(android.os.Handler) MapActivity(com.junjunguo.pocketmaps.activities.MapActivity)

Aggregations

Handler (android.os.Handler)1 MapActivity (com.junjunguo.pocketmaps.activities.MapActivity)1 GeoPoint (org.oscim.core.GeoPoint)1