aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/net/cbaines/suma/BusSpecificStopView.java27
-rw-r--r--src/net/cbaines/suma/BusStopSpecificStopView.java26
2 files changed, 43 insertions, 10 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);
}
diff --git a/src/net/cbaines/suma/BusStopSpecificStopView.java b/src/net/cbaines/suma/BusStopSpecificStopView.java
index c7f9bd8..eade3fe 100644
--- a/src/net/cbaines/suma/BusStopSpecificStopView.java
+++ b/src/net/cbaines/suma/BusStopSpecificStopView.java
@@ -31,7 +31,6 @@ import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnLongClickListener;
import android.widget.LinearLayout;
-import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
@@ -42,7 +41,7 @@ public class BusStopSpecificStopView extends LinearLayout implements OnClickList
// private final ImageView icon;
- // private static final String TAG = "StopView";
+ private static final String TAG = "StopView";
private final TextView name;
private final TextView time;
@@ -71,7 +70,8 @@ public class BusStopSpecificStopView extends LinearLayout implements OnClickList
Resources resources = context.getResources();
onClickHelpMessage = resources.getString(R.string.bus_stop_stop_view_on_click_toast_help_message);
- onClickUnidentifiedMessage = resources.getString(R.string.bus_stop_stop_view_on_click_toast_unidentified_message);
+ onClickUnidentifiedMessage = resources
+ .getString(R.string.bus_stop_stop_view_on_click_toast_unidentified_message);
setStop(stop);
@@ -121,7 +121,22 @@ public class BusStopSpecificStopView extends LinearLayout implements OnClickList
}
public void onClick(View v) {
- context.makeToast(onClickMessage, onClickHelpMessage, Toast.LENGTH_SHORT);
+ Log.v(TAG, "onClick");
+ 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) {
+ Log.v(TAG, "stop.bus != null");
+ context.makeToast(onClickMessage, onClickHelpMessage, Toast.LENGTH_SHORT);
+ } else {
+ Log.v(TAG, "stop.bus == null");
+ context.makeToast(onClickMessage, Toast.LENGTH_SHORT);
+ }
}
public boolean onLongClick(View v) {
@@ -134,7 +149,8 @@ public class BusStopSpecificStopView extends LinearLayout implements OnClickList
busDao.refresh(stop.bus);
busRouteDao.refresh(stop.bus.route);
- Log.i("StopView", "Bus route " + stop.bus.route + " Uni-Link " + stop.bus.route.uniLink + " Bus ID " + stop.bus.id);
+ Log.i("StopView", "Bus route " + stop.bus.route + " Uni-Link " + stop.bus.route.uniLink + " Bus ID "
+ + stop.bus.id);
if (stop.bus.id != null && stop.bus.route.uniLink) {
Uri uri = Uri.parse("http://id.southampton.ac.uk/bus/" + stop.bus.id);