forked from upstream-mirrors/OpenTracks
merge heads
This commit is contained in:
@@ -51,7 +51,6 @@ import android.os.Bundle;
|
||||
import android.os.Parcelable;
|
||||
import android.support.v4.app.TaskStackBuilder;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.MotionEvent;
|
||||
@@ -74,7 +73,6 @@ public class TrackDetailActivity extends AbstractSendToGoogleActivity
|
||||
public static final String EXTRA_TRACK_ID = "track_id";
|
||||
public static final String EXTRA_MARKER_ID = "marker_id";
|
||||
|
||||
private static final String TAG = TrackDetailActivity.class.getSimpleName();
|
||||
private static final String CURRENT_TAB_TAG_KEY = "current_tab_tag_key";
|
||||
|
||||
// The following are set in onCreate
|
||||
@@ -218,7 +216,6 @@ public class TrackDetailActivity extends AbstractSendToGoogleActivity
|
||||
}
|
||||
trackController = new TrackController(
|
||||
this, trackRecordingServiceConnection, false, recordListener, stopListener);
|
||||
showMarker();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -292,7 +289,6 @@ public class TrackDetailActivity extends AbstractSendToGoogleActivity
|
||||
public void onNewIntent(Intent intent) {
|
||||
setIntent(intent);
|
||||
handleIntent(intent);
|
||||
showMarker();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -474,6 +470,13 @@ public class TrackDetailActivity extends AbstractSendToGoogleActivity
|
||||
return trackDataHub;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the marker id.
|
||||
*/
|
||||
public long getMarkerId() {
|
||||
return markerId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the data in the intent.
|
||||
*/
|
||||
@@ -508,22 +511,6 @@ public class TrackDetailActivity extends AbstractSendToGoogleActivity
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows marker.
|
||||
*/
|
||||
private void showMarker() {
|
||||
if (markerId != -1L) {
|
||||
MyTracksMapFragment mapFragmet = (MyTracksMapFragment) getSupportFragmentManager()
|
||||
.findFragmentByTag(MyTracksMapFragment.MAP_FRAGMENT_TAG);
|
||||
if (mapFragmet != null) {
|
||||
tabHost.setCurrentTabByTag(MyTracksMapFragment.MAP_FRAGMENT_TAG);
|
||||
mapFragmet.showMarker(trackId, markerId);
|
||||
} else {
|
||||
Log.e(TAG, "MapFragment is null");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the menu items.
|
||||
*
|
||||
|
||||
@@ -93,8 +93,10 @@ public class MyTracksMapFragment extends SupportMapFragment implements TrackData
|
||||
|
||||
private static final int MAP_VIEW_PADDING = 32;
|
||||
|
||||
// States from TrackDetailActivity, set in onResume
|
||||
private TrackDataHub trackDataHub;
|
||||
|
||||
private long markerId;
|
||||
|
||||
// Current location
|
||||
private Location currentLocation;
|
||||
private Location lastTrackPoint;
|
||||
@@ -130,10 +132,6 @@ public class MyTracksMapFragment extends SupportMapFragment implements TrackData
|
||||
|
||||
private OnLocationChangedListener onLocationChangedListener;
|
||||
|
||||
// For showing a marker
|
||||
private long markerTrackId = -1L;
|
||||
private long markerId = -1L;
|
||||
|
||||
// Current track
|
||||
private Track currentTrack;
|
||||
|
||||
@@ -274,6 +272,9 @@ public class MyTracksMapFragment extends SupportMapFragment implements TrackData
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
// First obtain the states from TrackDetailActivity
|
||||
markerId = ((TrackDetailActivity) getActivity()).getMarkerId();
|
||||
resumeTrackDataHub();
|
||||
|
||||
MyTracksLocationManager myTracksLocationManager = new MyTracksLocationManager(
|
||||
@@ -319,29 +320,6 @@ public class MyTracksMapFragment extends SupportMapFragment implements TrackData
|
||||
pauseTrackDataHub();
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the marker on the map.
|
||||
*
|
||||
* @param trackId the track id
|
||||
* @param id the marker id
|
||||
*/
|
||||
public void showMarker(long trackId, long id) {
|
||||
/*
|
||||
* Synchronize to prevent race condition in changing markerTrackId and
|
||||
* markerId variables.
|
||||
*/
|
||||
synchronized (this) {
|
||||
if (currentTrack != null && currentTrack.getId() == trackId) {
|
||||
showMarker(id);
|
||||
markerTrackId = -1L;
|
||||
markerId = -1L;
|
||||
return;
|
||||
}
|
||||
markerTrackId = trackId;
|
||||
markerId = id;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater menuInflator) {
|
||||
menuInflator.inflate(R.menu.map, menu);
|
||||
@@ -409,21 +387,12 @@ public class MyTracksMapFragment extends SupportMapFragment implements TrackData
|
||||
boolean hasTrack = track != null;
|
||||
if (hasTrack) {
|
||||
mapOverlay.setShowEndMarker(!isSelectedTrackRecording());
|
||||
synchronized (this) {
|
||||
/*
|
||||
* Synchronize to prevent race condition in changing markerTrackId and
|
||||
* markerId variables.
|
||||
*/
|
||||
if (track.getId() == markerTrackId) {
|
||||
// Show the marker
|
||||
showMarker(markerId);
|
||||
|
||||
markerTrackId = -1L;
|
||||
markerId = -1L;
|
||||
} else {
|
||||
// Show the track
|
||||
showTrack();
|
||||
}
|
||||
if (markerId != -1L) {
|
||||
// Show the marker
|
||||
showMarker(markerId);
|
||||
} else {
|
||||
// Show the track
|
||||
showTrack();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -648,9 +617,9 @@ public class MyTracksMapFragment extends SupportMapFragment implements TrackData
|
||||
.include(southWest).include(northEast).build();
|
||||
|
||||
/**
|
||||
* Note cannot call CameraUpdate.newLatLngBounds(LatLngBounds bounds,
|
||||
* Note cannot call CameraUpdateFactory.newLatLngBounds(LatLngBounds bounds,
|
||||
* int padding) if the map view has not undergone layout. Thus calling
|
||||
* CameraUpdate.newLatLngBounds(LatLngBounds bounds, int width, int
|
||||
* CameraUpdateFactory.newLatLngBounds(LatLngBounds bounds, int width, int
|
||||
* height, int padding) after making sure that mapView is valid in the
|
||||
* above code.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user