aboutsummaryrefslogtreecommitdiff
path: root/src/net/cbaines/suma/BusStopActivity.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/cbaines/suma/BusStopActivity.java')
-rw-r--r--src/net/cbaines/suma/BusStopActivity.java58
1 files changed, 48 insertions, 10 deletions
diff --git a/src/net/cbaines/suma/BusStopActivity.java b/src/net/cbaines/suma/BusStopActivity.java
index dbed3ee..62a0f54 100644
--- a/src/net/cbaines/suma/BusStopActivity.java
+++ b/src/net/cbaines/suma/BusStopActivity.java
@@ -33,6 +33,7 @@ import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
+import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
@@ -43,6 +44,7 @@ import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
+import android.view.View.OnLongClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.CheckBox;
@@ -59,8 +61,8 @@ import com.j256.ormlite.dao.Dao;
import com.j256.ormlite.stmt.PreparedQuery;
import com.j256.ormlite.stmt.QueryBuilder;
-public class BusStopActivity extends OrmLiteBaseActivity<DatabaseHelper> implements OnCheckedChangeListener, Preferences,
- OnItemClickListener {
+public class BusStopActivity extends OrmLiteBaseActivity<DatabaseHelper> implements OnCheckedChangeListener,
+ Preferences, OnItemClickListener, OnLongClickListener {
final static String TAG = "BusTimeActivity";
@@ -133,10 +135,19 @@ public class BusStopActivity extends OrmLiteBaseActivity<DatabaseHelper> impleme
U9RouteRadioButton = (CheckBox) findViewById(R.id.radio_u9);
U1RouteRadioButton.setOnCheckedChangeListener(this);
+ U1RouteRadioButton.setOnLongClickListener(this);
+
U1NRouteRadioButton.setOnCheckedChangeListener(this);
+ U1NRouteRadioButton.setOnLongClickListener(this);
+
U2RouteRadioButton.setOnCheckedChangeListener(this);
+ U2RouteRadioButton.setOnLongClickListener(this);
+
U6RouteRadioButton.setOnCheckedChangeListener(this);
+ U6RouteRadioButton.setOnLongClickListener(this);
+
U9RouteRadioButton.setOnCheckedChangeListener(this);
+ U9RouteRadioButton.setOnLongClickListener(this);
try {
Dao<BusStop, String> busStopDao = helper.getBusStopDao();
@@ -310,10 +321,10 @@ public class BusStopActivity extends OrmLiteBaseActivity<DatabaseHelper> impleme
try {
final SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(instance);
- newTimetable = DataManager
- .getTimetable(instance, busStop.id, sharedPrefs.getBoolean(MapActivity.UNI_LINK_BUS_TIMES,
- MapActivity.UNI_LINK_BUS_TIMES_ENABLED_BY_DEFAULT), sharedPrefs.getBoolean(
- MapActivity.NON_UNI_LINK_BUS_TIMES, MapActivity.NON_UNI_LINK_BUS_TIMES_ENABLED_BY_DEFAULT));
+ newTimetable = DataManager.getTimetable(instance, busStop.id, sharedPrefs.getBoolean(
+ MapActivity.UNI_LINK_BUS_TIMES, MapActivity.UNI_LINK_BUS_TIMES_ENABLED_BY_DEFAULT), sharedPrefs
+ .getBoolean(MapActivity.NON_UNI_LINK_BUS_TIMES,
+ MapActivity.NON_UNI_LINK_BUS_TIMES_ENABLED_BY_DEFAULT));
} catch (SQLException e) {
errorMessage = "Error message regarding SQL?";
e.printStackTrace();
@@ -387,7 +398,7 @@ public class BusStopActivity extends OrmLiteBaseActivity<DatabaseHelper> impleme
Log.i(TAG, "stops " + busStops);
if (busStops.size() == 1) {
- Intent i = new Intent(this, BusStopActivity.class);
+
BusStop stop = (BusStop) busStops.iterator().next();
if (stop == null) {
Log.e(TAG, "stop == null");
@@ -395,9 +406,14 @@ public class BusStopActivity extends OrmLiteBaseActivity<DatabaseHelper> impleme
if (stop.id == null) {
Log.e(TAG, "stop.id == null");
}
- i.putExtra("busStopID", stop.id);
- i.putExtra("busStopName", stop.description);
- startActivity(i);
+
+ Uri uri = Uri.parse("http://id.southampton.ac.uk/bus-stop/" + busStop.id);
+
+ Log.i(TAG, "Starting a activity for " + uri + " path " + uri.getPath());
+
+ Intent busStopIntent = new Intent(Intent.ACTION_VIEW, uri);
+ startActivity(busStopIntent);
+
} else {
showDialog(POI_DIALOG_ID);
if (busDialog == null) {
@@ -522,4 +538,26 @@ public class BusStopActivity extends OrmLiteBaseActivity<DatabaseHelper> impleme
}
}
+
+ public boolean onLongClick(View v) {
+ Uri uri = null;
+ if (v.equals(U1RouteRadioButton)) {
+ uri = Uri.parse("http://id.southampton.ac.uk/bus-route/326");
+ } else if (v.equals(U1NRouteRadioButton)) {
+ uri = Uri.parse("http://id.southampton.ac.uk/bus-route/468");
+ } else if (v.equals(U2RouteRadioButton)) {
+ uri = Uri.parse("http://id.southampton.ac.uk/bus-route/329");
+ } else if (v.equals(U6RouteRadioButton)) {
+ uri = Uri.parse("http://id.southampton.ac.uk/bus-route/327");
+ } else if (v.equals(U9RouteRadioButton)) {
+ uri = Uri.parse("http://id.southampton.ac.uk/bus-route/354");
+ }
+ if (uri != null) {
+ Log.i(TAG, "Starting a activity for " + uri + " path " + uri.getPath());
+
+ Intent busStopIntent = new Intent(Intent.ACTION_VIEW, uri);
+ startActivity(busStopIntent);
+ }
+ return false;
+ }
}