forked from upstream-mirrors/OpenTracks
Fix comment on b786fecb39b0
This commit is contained in:
@@ -14,6 +14,11 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:text="@string/stop_recording"
|
||||
/>
|
||||
<Button android:id="@+id/add_waypoints_button"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:text="@string/add_waypoints"
|
||||
/>
|
||||
<TextView android:id="@+id/output"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="add_waypoints">Add a waypoint to all the tracks</string>
|
||||
<string name="app_name">MyTracksApiSample</string>
|
||||
<string name="start_recording">Start Recording</string>
|
||||
<string name="stop_recording">Stop Recording</string>
|
||||
<string name="start_recording">Start recording</string>
|
||||
<string name="stop_recording">Stop recording</string>
|
||||
</resources>
|
||||
|
||||
+20
-13
@@ -43,7 +43,7 @@ import java.util.List;
|
||||
* You also need to enable third party application access inside MyTracks
|
||||
* MyTracks -> menu -> Settings -> Sharing -> Allow access
|
||||
*
|
||||
* Jimmy Shih
|
||||
* @author Jimmy Shih
|
||||
*/
|
||||
public class MainActivity extends Activity {
|
||||
|
||||
@@ -83,10 +83,27 @@ public class MainActivity extends Activity {
|
||||
myTracksProviderUtils = MyTracksProviderUtils.Factory.get(this);
|
||||
outputTextView = (TextView) findViewById(R.id.output);
|
||||
|
||||
Button addWaypointsButton = (Button) findViewById(R.id.add_waypoints_button);
|
||||
addWaypointsButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
List<Track> tracks = myTracksProviderUtils.getAllTracks();
|
||||
Calendar now = Calendar.getInstance();
|
||||
for (Track track : tracks) {
|
||||
Waypoint waypoint = new Waypoint();
|
||||
waypoint.setTrackId(track.getId());
|
||||
waypoint.setName(now.getTime().toLocaleString());
|
||||
waypoint.setDescription(now.getTime().toLocaleString());
|
||||
myTracksProviderUtils.insertWaypoint(waypoint);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// for the MyTracks service
|
||||
intent = new Intent();
|
||||
intent.setComponent(new ComponentName(
|
||||
getString(R.string.mytracks_service_package), getString(R.string.mytracks_service_class)));
|
||||
ComponentName componentName = new ComponentName(
|
||||
getString(R.string.mytracks_service_package), getString(R.string.mytracks_service_class));
|
||||
intent.setComponent(componentName);
|
||||
|
||||
Button startRecordingButton = (Button) findViewById(R.id.start_recording_button);
|
||||
startRecordingButton.setOnClickListener(new View.OnClickListener() {
|
||||
@@ -127,16 +144,6 @@ public class MainActivity extends Activity {
|
||||
outputTextView.append(track.getId() + " ");
|
||||
}
|
||||
|
||||
// use the MyTracks content provider to add a waypoint to all the tracks
|
||||
Calendar now = Calendar.getInstance();
|
||||
for (Track track : tracks) {
|
||||
Waypoint waypoint = new Waypoint();
|
||||
waypoint.setTrackId(track.getId());
|
||||
waypoint.setName(now.getTime().toLocaleString());
|
||||
waypoint.setDescription(now.getTime().toLocaleString());
|
||||
myTracksProviderUtils.insertWaypoint(waypoint);
|
||||
}
|
||||
|
||||
// start and bind the MyTracks service
|
||||
startService(intent);
|
||||
bindService(intent, serviceConnection, 0);
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ import android.widget.Toast;
|
||||
/**
|
||||
* A receiver to receive MyTracks notifications.
|
||||
*
|
||||
* Jimmy Shih
|
||||
* @author Jimmy Shih
|
||||
*/
|
||||
public class MyTracksReceiver extends BroadcastReceiver {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user