diff options
Diffstat (limited to 'src/net/cbaines/suma/BusSpecificStopView.java')
-rw-r--r-- | src/net/cbaines/suma/BusSpecificStopView.java | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/src/net/cbaines/suma/BusSpecificStopView.java b/src/net/cbaines/suma/BusSpecificStopView.java index 5ab7cd5..6d7e6af 100644 --- a/src/net/cbaines/suma/BusSpecificStopView.java +++ b/src/net/cbaines/suma/BusSpecificStopView.java @@ -25,6 +25,8 @@ import java.text.DateFormat; import android.app.Activity; import android.content.Intent; import android.content.res.Resources; +import android.net.Uri; +import android.util.Log; import android.view.Gravity; import android.view.View; import android.view.View.OnClickListener; @@ -144,7 +146,19 @@ public class BusSpecificStopView extends LinearLayout implements OnClickListener } public void onClick(View v) { - context.makeToast(onClickMessage, onClickHelpMessage, Toast.LENGTH_SHORT); + DatabaseHelper helper = OpenHelperManager.getHelper(context, DatabaseHelper.class); + try { + Dao<Bus, Integer> busDao = helper.getBusDao(); + busDao.refresh(stop.bus); + } catch (SQLException e) { + e.printStackTrace(); + } + + if (stop.bus.id != null) { + context.makeToast(onClickMessage, onClickHelpMessage, Toast.LENGTH_SHORT); + } else { + context.makeToast(onClickMessage, Toast.LENGTH_SHORT); + } } public boolean onLongClick(View v) { // TODO @@ -156,10 +170,13 @@ public class BusSpecificStopView extends LinearLayout implements OnClickListener busDao.refresh(stop.bus); if (stop.bus.id != null) { - // TODO Change to URI - Intent i = new Intent(context, MapActivity.class); - i.putExtra("poiPoint", stop.busStop.point.toDoubleString()); - ((Activity) context).startActivityForResult(i, 0); + Uri uri = Uri.parse("geo:" + Util.E6IntToDouble(stop.busStop.point.getLatitudeE6()) + "," + + Util.E6IntToDouble(stop.busStop.point.getLongitudeE6()) + "?z=18"); + + Log.i(TAG, "Starting a activity for " + uri); + + Intent mapIntent = new Intent(Intent.ACTION_VIEW, uri); + ((Activity) context).startActivity(mapIntent); } else { context.makeToast(onClickUnidentifiedMessage, Toast.LENGTH_SHORT); } |