forked from upstream-mirrors/OpenTracks
Minor fixes and respond to comments.
This commit is contained in:
@@ -427,7 +427,11 @@ public class MyTracks extends TabActivity implements OnTouchListener,
|
|||||||
public boolean onTrackballEvent(MotionEvent event) {
|
public boolean onTrackballEvent(MotionEvent event) {
|
||||||
if (isRecording()) {
|
if (isRecording()) {
|
||||||
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
||||||
insertWaypoint(WaypointType.STATISTICS);
|
try {
|
||||||
|
insertWaypoint(WaypointType.STATISTICS);
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.e(MyTracksConstants.TAG, "Cannot insert statistics marker.", e);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -883,32 +887,30 @@ public class MyTracks extends TabActivity implements OnTouchListener,
|
|||||||
/**
|
/**
|
||||||
* Inserts a waypoint marker.
|
* Inserts a waypoint marker.
|
||||||
*
|
*
|
||||||
* @return the id of the inserted statistics marker, or
|
* @return Id of the inserted statistics marker.
|
||||||
* -1 on error
|
* @throws Exception If the insertion failed.
|
||||||
*/
|
*/
|
||||||
public long insertWaypoint(WaypointType type) {
|
public long insertWaypoint(WaypointType type) throws Exception {
|
||||||
if (trackRecordingService != null) {
|
if (trackRecordingService == null) {
|
||||||
try {
|
throw new IllegalStateException("The recording service is not bound.");
|
||||||
long waypointId =
|
}
|
||||||
trackRecordingService.insertWaypoint(type);
|
try {
|
||||||
if (waypointId >= 0) {
|
long waypointId =
|
||||||
Toast.makeText(this, R.string.status_statistics_inserted,
|
trackRecordingService.insertWaypoint(type);
|
||||||
Toast.LENGTH_LONG).show();
|
if (waypointId >= 0) {
|
||||||
return waypointId;
|
Toast.makeText(this, R.string.status_statistics_inserted,
|
||||||
} else {
|
Toast.LENGTH_LONG).show();
|
||||||
Toast.makeText(this, R.string.error_unable_to_insert_marker,
|
return waypointId;
|
||||||
Toast.LENGTH_LONG).show();
|
} else {
|
||||||
Log.e(MyTracksConstants.TAG, "Cannot insert statistics marker?");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
Toast.makeText(this, R.string.error_unable_to_insert_marker,
|
Toast.makeText(this, R.string.error_unable_to_insert_marker,
|
||||||
Toast.LENGTH_LONG).show();
|
Toast.LENGTH_LONG).show();
|
||||||
Log.e(MyTracksConstants.TAG, "Cannot insert statistics marker?", e);
|
throw new Exception("Insertion failed.");
|
||||||
}
|
}
|
||||||
return -1;
|
} catch (Exception e) {
|
||||||
|
Toast.makeText(this, R.string.error_unable_to_insert_marker,
|
||||||
|
Toast.LENGTH_LONG).show();
|
||||||
|
throw e;
|
||||||
}
|
}
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import android.content.Intent;
|
|||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.ContextMenu;
|
import android.view.ContextMenu;
|
||||||
import android.view.ContextMenu.ContextMenuInfo;
|
import android.view.ContextMenu.ContextMenuInfo;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
@@ -166,26 +167,29 @@ public class MyTracksWaypointsList extends ListActivity
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
WaypointType type;
|
||||||
switch (v.getId()) {
|
switch (v.getId()) {
|
||||||
case R.id.waypointslist_btn_insert_waypoint: {
|
case R.id.waypointslist_btn_insert_waypoint:
|
||||||
long id = MyTracks.getInstance().insertWaypoint(WaypointType.MARKER);
|
type = WaypointType.MARKER;
|
||||||
if (id >= 0) {
|
|
||||||
Intent intent = new Intent(this, MyTracksWaypointDetails.class);
|
|
||||||
intent.putExtra("waypointid", id);
|
|
||||||
startActivity(intent);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
case R.id.waypointslist_btn_insert_statistics:
|
||||||
case R.id.waypointslist_btn_insert_statistics: {
|
type = WaypointType.MARKER;
|
||||||
long id = MyTracks.getInstance().insertWaypoint(WaypointType.STATISTICS);
|
|
||||||
if (id >= 0) {
|
|
||||||
Intent intent = new Intent(this, MyTracksWaypointDetails.class);
|
|
||||||
intent.putExtra("waypointid", id);
|
|
||||||
startActivity(intent);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
long id;
|
||||||
|
try {
|
||||||
|
id = MyTracks.getInstance().insertWaypoint(type);
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.e(MyTracksConstants.TAG, "Cannot insert statistics marker.", e);
|
||||||
|
e.printStackTrace();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (id >= 0) {
|
||||||
|
Intent intent = new Intent(this, MyTracksWaypointDetails.class);
|
||||||
|
intent.putExtra("waypointid", id);
|
||||||
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
-4
@@ -23,12 +23,9 @@ import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
|
|||||||
import com.google.android.apps.mytracks.content.Track;
|
import com.google.android.apps.mytracks.content.Track;
|
||||||
import com.google.android.apps.mytracks.content.Waypoint;
|
import com.google.android.apps.mytracks.content.Waypoint;
|
||||||
import com.google.android.apps.mytracks.content.WaypointType;
|
import com.google.android.apps.mytracks.content.WaypointType;
|
||||||
import com.google.android.apps.mytracks.content.MyTracksProviderUtils.Factory;
|
|
||||||
import com.google.android.apps.mytracks.stats.TripStatistics;
|
import com.google.android.apps.mytracks.stats.TripStatistics;
|
||||||
import com.google.android.apps.mytracks.testing.TestingProviderUtilsFactory;
|
|
||||||
import com.google.android.apps.mytracks.util.ApiFeatures;
|
import com.google.android.apps.mytracks.util.ApiFeatures;
|
||||||
import com.google.android.maps.mytracks.R;
|
import com.google.android.maps.mytracks.R;
|
||||||
import com.google.android.testing.mocking.AndroidMock;
|
|
||||||
|
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
@@ -40,7 +37,6 @@ import android.content.SharedPreferences;
|
|||||||
import android.content.SharedPreferences.Editor;
|
import android.content.SharedPreferences.Editor;
|
||||||
import android.location.Location;
|
import android.location.Location;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.RemoteException;
|
|
||||||
import android.test.RenamingDelegatingContext;
|
import android.test.RenamingDelegatingContext;
|
||||||
import android.test.ServiceTestCase;
|
import android.test.ServiceTestCase;
|
||||||
import android.test.mock.MockContentResolver;
|
import android.test.mock.MockContentResolver;
|
||||||
|
|||||||
Reference in New Issue
Block a user