Advertisement
Guest User

Untitled

a guest
Apr 24th, 2014
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. Thread restartLocation = new Thread(new Runnable() {
  2. @Override
  3. public void run() {
  4. while (true) {
  5. try {
  6. Thread mThis = Thread.currentThread();
  7. while(restartLocation == mThis) {
  8. for(int i = 0; i < 10; i++) {
  9. Log.d("Delay", i+" seconds");
  10. Thread.sleep(1000);
  11. }
  12.  
  13. runOnUiThread(new Runnable() {
  14. @Override
  15. public void run() {
  16. map.setMyLocationEnabled(true);
  17. }
  18. });
  19. }
  20. } catch (Exception e) {
  21. e.printStackTrace();
  22. }
  23. }
  24.  
  25. }
  26. });
  27.  
  28. //When the map is drag stop it update with the users location
  29. //If the user drags the map to look around they dont want it moving back
  30. mf.setOnDragListener(new TouchableWrapper.OnDragListener() {
  31. @Override
  32. public void onDrag(MotionEvent motionEvent) {
  33. map.setMyLocationEnabled(false);
  34. Log.d("Map", "Stopped location and remove drag listener");
  35. if (motionEvent.getActionMasked() == MotionEvent.ACTION_UP) {
  36.  
  37. //Stop restartLocation if it's running
  38. restartLocation.start();
  39. }
  40. }
  41. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement