aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <cbaines8@gmail.com>2012-01-27 13:35:13 +0000
committerChristopher Baines <cbaines8@gmail.com>2012-01-27 13:35:13 +0000
commit75207a422e195ad26584d6a5d186dfd3e20f38f9 (patch)
tree6eba414bee018a68c5cd7d4f35d0ca14ce11504c
parentda433913ec08182e9f14292021025d271e3c5dd6 (diff)
downloadsouthamptonuniversitymap-75207a422e195ad26584d6a5d186dfd3e20f38f9.tar
southamptonuniversitymap-75207a422e195ad26584d6a5d186dfd3e20f38f9.tar.gz
More stuff.
-rw-r--r--res/drawable/u1_back.xml4
-rw-r--r--res/drawable/u1_back_selected.xml4
-rw-r--r--res/drawable/u1n_back.xml4
-rw-r--r--res/drawable/u1n_back_selected.xml4
-rw-r--r--res/drawable/u2_back.xml4
-rw-r--r--res/drawable/u2_back_selected.xml4
-rw-r--r--res/drawable/u6_back.xml4
-rw-r--r--res/drawable/u6_back_selected.xml4
-rw-r--r--res/drawable/u9_back.xml4
-rw-r--r--res/drawable/u9_back_selected.xml4
-rw-r--r--res/raw/ormlite_config.txt2
-rw-r--r--src/net/cbaines/suma/BusRoute.java2
-rw-r--r--src/net/cbaines/suma/BusStopActivity.java71
-rw-r--r--src/net/cbaines/suma/Direction.java31
-rw-r--r--src/net/cbaines/suma/StopView.java4
15 files changed, 142 insertions, 8 deletions
diff --git a/res/drawable/u1_back.xml b/res/drawable/u1_back.xml
index 069eb8e..4fd73bc 100644
--- a/res/drawable/u1_back.xml
+++ b/res/drawable/u1_back.xml
@@ -11,4 +11,8 @@
android:topLeftRadius="7dp"
android:topRightRadius="7dp" />
+ <stroke
+ android:width="2dp"
+ android:color="#008BD0" />
+
</android:shape> \ No newline at end of file
diff --git a/res/drawable/u1_back_selected.xml b/res/drawable/u1_back_selected.xml
index 4040762..8ff898f 100644
--- a/res/drawable/u1_back_selected.xml
+++ b/res/drawable/u1_back_selected.xml
@@ -11,4 +11,8 @@
android:topLeftRadius="7dp"
android:topRightRadius="7dp" />
+ <stroke
+ android:width="2dp"
+ android:color="#008BD0" />
+
</android:shape> \ No newline at end of file
diff --git a/res/drawable/u1n_back.xml b/res/drawable/u1n_back.xml
index 069eb8e..476e338 100644
--- a/res/drawable/u1n_back.xml
+++ b/res/drawable/u1n_back.xml
@@ -11,4 +11,8 @@
android:topLeftRadius="7dp"
android:topRightRadius="7dp" />
+ <stroke
+ android:width="2dp"
+ android:color="#002F6B" />
+
</android:shape> \ No newline at end of file
diff --git a/res/drawable/u1n_back_selected.xml b/res/drawable/u1n_back_selected.xml
index 3898629..c238192 100644
--- a/res/drawable/u1n_back_selected.xml
+++ b/res/drawable/u1n_back_selected.xml
@@ -11,4 +11,8 @@
android:topLeftRadius="7dp"
android:topRightRadius="7dp" />
+ <stroke
+ android:width="2dp"
+ android:color="#002F6B" />
+
</shape> \ No newline at end of file
diff --git a/res/drawable/u2_back.xml b/res/drawable/u2_back.xml
index 9feb0ef..9342065 100644
--- a/res/drawable/u2_back.xml
+++ b/res/drawable/u2_back.xml
@@ -11,4 +11,8 @@
android:topLeftRadius="7dp"
android:topRightRadius="7dp" />
+ <stroke
+ android:width="2dp"
+ android:color="#E2001A" />
+
</shape> \ No newline at end of file
diff --git a/res/drawable/u2_back_selected.xml b/res/drawable/u2_back_selected.xml
index e1fa567..ee7a281 100644
--- a/res/drawable/u2_back_selected.xml
+++ b/res/drawable/u2_back_selected.xml
@@ -11,4 +11,8 @@
android:topLeftRadius="7dp"
android:topRightRadius="7dp" />
+ <stroke
+ android:width="2dp"
+ android:color="#E2001A" />
+
</shape> \ No newline at end of file
diff --git a/res/drawable/u6_back.xml b/res/drawable/u6_back.xml
index 9feb0ef..fa50f19 100644
--- a/res/drawable/u6_back.xml
+++ b/res/drawable/u6_back.xml
@@ -11,4 +11,8 @@
android:topLeftRadius="7dp"
android:topRightRadius="7dp" />
+ <stroke
+ android:width="2dp"
+ android:color="#F7A800" />
+
</shape> \ No newline at end of file
diff --git a/res/drawable/u6_back_selected.xml b/res/drawable/u6_back_selected.xml
index cd60db7..a08a7ae 100644
--- a/res/drawable/u6_back_selected.xml
+++ b/res/drawable/u6_back_selected.xml
@@ -11,4 +11,8 @@
android:topLeftRadius="7dp"
android:topRightRadius="7dp" />
+ <stroke
+ android:width="2dp"
+ android:color="#F7A800" />
+
</shape> \ No newline at end of file
diff --git a/res/drawable/u9_back.xml b/res/drawable/u9_back.xml
index 9feb0ef..3b64882 100644
--- a/res/drawable/u9_back.xml
+++ b/res/drawable/u9_back.xml
@@ -11,4 +11,8 @@
android:topLeftRadius="7dp"
android:topRightRadius="7dp" />
+ <stroke
+ android:width="2dp"
+ android:color="#E75294" />
+
</shape> \ No newline at end of file
diff --git a/res/drawable/u9_back_selected.xml b/res/drawable/u9_back_selected.xml
index 6216ebc..2ce0e9f 100644
--- a/res/drawable/u9_back_selected.xml
+++ b/res/drawable/u9_back_selected.xml
@@ -11,4 +11,8 @@
android:topLeftRadius="7dp"
android:topRightRadius="7dp" />
+ <stroke
+ android:width="2dp"
+ android:color="#E75294" />
+
</shape> \ No newline at end of file
diff --git a/res/raw/ormlite_config.txt b/res/raw/ormlite_config.txt
index f807b08..ead3461 100644
--- a/res/raw/ormlite_config.txt
+++ b/res/raw/ormlite_config.txt
@@ -1,3 +1,3 @@
#
-# generated on 2012/01/24 10:55:14
+# generated on 2012/01/27 02:37:03
#
diff --git a/src/net/cbaines/suma/BusRoute.java b/src/net/cbaines/suma/BusRoute.java
index 8c5d955..11ff798 100644
--- a/src/net/cbaines/suma/BusRoute.java
+++ b/src/net/cbaines/suma/BusRoute.java
@@ -24,6 +24,7 @@ import java.util.Collection;
import java.util.List;
import android.content.Context;
+import android.util.Log;
import com.j256.ormlite.android.apptools.OpenHelperManager;
import com.j256.ormlite.dao.Dao;
@@ -137,6 +138,7 @@ public class BusRoute {
} catch (SQLException e) {
e.printStackTrace();
}
+ Log.e("BusRoute", "Error moving in route");
return null;
}
diff --git a/src/net/cbaines/suma/BusStopActivity.java b/src/net/cbaines/suma/BusStopActivity.java
index 9d5c3c8..97492ec 100644
--- a/src/net/cbaines/suma/BusStopActivity.java
+++ b/src/net/cbaines/suma/BusStopActivity.java
@@ -24,6 +24,7 @@ import java.util.HashSet;
import java.util.Iterator;
import android.content.Context;
+import android.content.Intent;
import android.content.SharedPreferences;
import android.os.AsyncTask;
import android.os.Bundle;
@@ -305,6 +306,7 @@ public class BusStopActivity extends OrmLiteBaseActivity<DatabaseHelper> impleme
// Handle item selection
switch (item.getItemId()) {
case R.id.menu_previous_stop:
+ Log.v(TAG, "Got a request for the previous stop");
if (visibleTimetable.size() != 0) {
HashSet<BusRoute> routes = new HashSet<BusRoute>();
@@ -312,18 +314,77 @@ public class BusStopActivity extends OrmLiteBaseActivity<DatabaseHelper> impleme
routes.add(stop.bus.route);
}
- // TODO: Most of the following
+ Log.v(TAG, routes.size() + " routes in the visible timetable");
if (routes.size() == 1) {
- try {
- routes.iterator().next().moveInRoute(this, getHelper().getBusStopDao().queryForId(busStopID), new Direction(), 1);
- } catch (SQLException e) {
- e.printStackTrace();
+ HashSet<Direction> directions = new HashSet<Direction>();
+
+ for (Stop stop : visibleTimetable) {
+ directions.add(stop.bus.direction);
+ }
+
+ Log.v(TAG, directions.size() + " directions in the visible timetable");
+
+ if (directions.size() == 1) {
+ try {
+ BusStop previous = routes.iterator().next()
+ .moveInRoute(this, getHelper().getBusStopDao().queryForId(busStopID), directions.iterator().next(), 1);
+ Intent i = new Intent(this, BusStopActivity.class);
+ i.putExtra("busStopID", previous.id);
+ i.putExtra("busStopName", previous.description);
+ startActivity(i);
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ } else {
+ // Show dialog
}
+ } else {
+ // Show dialog
}
}
break;
case R.id.menu_next_stop:
+ Log.v(TAG, "Got a request for the next stop");
+ if (visibleTimetable.size() != 0) {
+ HashSet<BusRoute> routes = new HashSet<BusRoute>();
+
+ for (Stop stop : visibleTimetable) {
+ routes.add(stop.bus.route);
+ }
+
+ Log.v(TAG, routes.size() + " routes in the visible timetable");
+
+ if (routes.size() == 1) {
+ HashSet<Direction> directions = new HashSet<Direction>();
+
+ for (Stop stop : visibleTimetable) {
+ directions.add(stop.bus.direction);
+ }
+
+ Log.v(TAG, directions.size() + " directions in the visible timetable");
+
+ if (directions.size() == 1) {
+ try {
+ BusStop next = routes.iterator().next()
+ .moveInRoute(this, getHelper().getBusStopDao().queryForId(busStopID), directions.iterator().next(), 1);
+ Intent i = new Intent(this, BusStopActivity.class);
+ if (next.id == null) {
+ Log.e(TAG, "next.id == null");
+ }
+ i.putExtra("busStopID", next.id);
+ i.putExtra("busStopName", next.description);
+ startActivity(i);
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ } else {
+ // Show dialog
+ }
+ } else {
+ // Show dialog
+ }
+ }
break;
case R.id.menu_refresh_stop:
if (mHandler != null) { // BusTimes are enabled
diff --git a/src/net/cbaines/suma/Direction.java b/src/net/cbaines/suma/Direction.java
index 1ea0fcd..0bc3396 100644
--- a/src/net/cbaines/suma/Direction.java
+++ b/src/net/cbaines/suma/Direction.java
@@ -28,4 +28,35 @@ public class Direction {
public String toString() {
return direction;
}
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((direction == null) ? 0 : direction.hashCode());
+ result = prime * result + ((route == null) ? 0 : route.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ Direction other = (Direction) obj;
+ if (direction == null) {
+ if (other.direction != null)
+ return false;
+ } else if (!direction.equals(other.direction))
+ return false;
+ if (route == null) {
+ if (other.route != null)
+ return false;
+ } else if (!route.equals(other.route))
+ return false;
+ return true;
+ }
}
diff --git a/src/net/cbaines/suma/StopView.java b/src/net/cbaines/suma/StopView.java
index d99c8ba..dc023aa 100644
--- a/src/net/cbaines/suma/StopView.java
+++ b/src/net/cbaines/suma/StopView.java
@@ -78,10 +78,10 @@ public class StopView extends LinearLayout implements OnClickListener {
busDao.refresh(stop.bus);
- if (stop.bus != null) {
+ if (stop.bus.id != null) {
onClickMessage = "Bus " + stop.bus.toString() + " at " + DateFormat.getTimeInstance(DateFormat.SHORT).format(stop.arivalTime);
} else {
- onClickMessage = "Unidentified bus at " + DateFormat.getTimeInstance(DateFormat.SHORT).format(stop.arivalTime);
+ onClickMessage = "Unidentified bus (" + stop.bus.getName() + ") at " + DateFormat.getTimeInstance(DateFormat.SHORT).format(stop.arivalTime);
}
} catch (SQLException e) {
e.printStackTrace();