aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <cbaines8@gmail.com>2012-01-30 23:46:57 +0000
committerChristopher Baines <cbaines8@gmail.com>2012-01-30 23:46:57 +0000
commitfb831b1e33d4b988b97e95493336e076c7f799ab (patch)
treea12dbb905b0addeaf7c050f02d43469c9053d81b
parentfd1a757037a079278c2bf3e393d35bfee6b4c684 (diff)
downloadsouthamptonuniversitymap-fb831b1e33d4b988b97e95493336e076c7f799ab.tar
southamptonuniversitymap-fb831b1e33d4b988b97e95493336e076c7f799ab.tar.gz
Improved about menu, removed the stop navigation (for the time being).
-rw-r--r--assets/bus_stops.csv4
-rw-r--r--gen/net/cbaines/suma/R.java32
-rw-r--r--res/menu/stop_menu.xml10
-rw-r--r--res/values/strings.xml27
-rw-r--r--res/xml/about.xml57
-rw-r--r--src/net/cbaines/suma/AboutActivity.java149
-rw-r--r--src/net/cbaines/suma/BusStopActivity.java153
7 files changed, 200 insertions, 232 deletions
diff --git a/assets/bus_stops.csv b/assets/bus_stops.csv
index bda1d8e..b5fdcb6 100644
--- a/assets/bus_stops.csv
+++ b/assets/bus_stops.csv
@@ -588,7 +588,7 @@
"HAA13663","Victoria Rd nr Swift Rd S","","50 53.4537N","1 22.9816W","",
"HAA13664","Victoria Rd so sewage works NE","","50 53.4683N","1 22.9857W","",
"HAA13665","Kathleen Rd os 111 NE","","50 54.1554N","1 21.0456W","",
-"HAA13668","Univ Interchange NW","","50 56.1650N","1 23.8040W","",
+"HAA13668","Univ Interchange NW","","50 56.1660N","1 23.8040W","",
"HAA13694","Tollbar Way os Berrywood Vill NE","","50 55.9964N","1 18.4935W","",
"HAA13695","Tollbar Way opp Berrywood Vill SW","","50 55.9952N","1 18.4867W","",
"HAA19442","Hamble Ln nr Satchell Ln S","","50 52.4817N","1 19.6976W","",
@@ -1375,7 +1375,7 @@
"SNA19772","Wakefield Rd opp Wakefield Ct NE - HR","","50 55.5150N","1 21.6055W","",
"SNA19773","Glenfield Ave os 13 SW","","50 55.0087N","1 21.9633W","",
"SNA19774","Upper Deacon Rd opp Caerleon Dr SW","","50 54.7235N","1 20.8397W","",
-"SNA19777","Univ Interchange SE","","50 56.1700N","1 23.8120W","",
+"SNA19777","Univ Interchange SE","","50 56.1720N","1 23.8135W","",
"SNA19780","Wessex Ln opp Montefiore Halls SW","","50 56.2417N","1 22.5980W","",
"SNA40401","New Road South os East Park E","","50 54.4189N","1 24.2105W","",
"SNA40402","London Rd os HSBC SW","","50 54.6599N","1 24.2757W","",
diff --git a/gen/net/cbaines/suma/R.java b/gen/net/cbaines/suma/R.java
index 4ebca4b..12ec3d4 100644
--- a/gen/net/cbaines/suma/R.java
+++ b/gen/net/cbaines/suma/R.java
@@ -81,10 +81,8 @@ public final class R {
public static final int menu_favourites=0x7f0a0028;
public static final int menu_find=0x7f0a0023;
public static final int menu_find_my_location=0x7f0a0025;
- public static final int menu_next_stop=0x7f0a002b;
public static final int menu_preferences=0x7f0a0024;
- public static final int menu_previous_stop=0x7f0a0029;
- public static final int menu_refresh_stop=0x7f0a002a;
+ public static final int menu_refresh_stop=0x7f0a0029;
public static final int menu_view=0x7f0a0026;
public static final int radio_u1=0x7f0a0006;
public static final int radio_u1n=0x7f0a0007;
@@ -126,8 +124,33 @@ public final class R {
public static final int U2=0x7f07000b;
public static final int U6=0x7f07000c;
public static final int U9=0x7f07000d;
+ public static final int about=0x7f07002a;
+ public static final int about_android_market=0x7f070037;
+ public static final int about_android_market_summary=0x7f070038;
+ public static final int about_copyright=0x7f07002d;
+ public static final int about_copyright_summary=0x7f07002e;
+ public static final int about_data=0x7f070035;
+ public static final int about_data_summary=0x7f070036;
+ public static final int about_database=0x7f07003f;
+ public static final int about_database_summary=0x7f070040;
+ public static final int about_developer=0x7f070033;
+ public static final int about_developer_summary=0x7f070034;
+ public static final int about_donate=0x7f070041;
+ public static final int about_donate_summary=0x7f070042;
public static final int about_help_message=0x7f070015;
+ public static final int about_license=0x7f07002f;
+ public static final int about_license_summary=0x7f070030;
+ public static final int about_map_data=0x7f070039;
+ public static final int about_map_data_summary=0x7f07003a;
+ public static final int about_map_icons=0x7f07003b;
+ public static final int about_map_icons_summary=0x7f07003c;
public static final int about_menu_instruction_text=0x7f070023;
+ public static final int about_osm_map=0x7f07003d;
+ public static final int about_osm_map_summary=0x7f07003e;
+ public static final int about_project=0x7f070031;
+ public static final int about_project_summary=0x7f070032;
+ public static final int about_version=0x7f07002b;
+ public static final int about_version_summary=0x7f07002c;
public static final int app_name=0x7f070004;
public static final int bitcoin_error_message=0x7f07001a;
public static final int building_non_residential=0x7f070007;
@@ -167,6 +190,7 @@ public final class R {
public static final int view_help_message=0x7f070014;
}
public static final class xml {
- public static final int preferences=0x7f050000;
+ public static final int about=0x7f050000;
+ public static final int preferences=0x7f050001;
}
}
diff --git a/res/menu/stop_menu.xml b/res/menu/stop_menu.xml
index 071a689..408e536 100644
--- a/res/menu/stop_menu.xml
+++ b/res/menu/stop_menu.xml
@@ -1,17 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
- <item
+ <!--<item
android:id="@+id/menu_previous_stop"
android:icon="@drawable/ic_menu_back"
- android:title="@string/menu_previous_stop"/>
+ android:title="@string/menu_previous_stop"/>-->
<item
android:id="@+id/menu_refresh_stop"
- android:icon="@drawable/ic_menu_search"
+ android:icon="@drawable/ic_menu_refresh"
android:title="@string/menu_refresh_stop"/>
- <item
+ <!--<item
android:id="@+id/menu_next_stop"
android:icon="@drawable/ic_menu_forward"
- android:title="@string/menu_next_stop"/>
+ android:title="@string/menu_next_stop"/>-->
</menu> \ No newline at end of file
diff --git a/res/values/strings.xml b/res/values/strings.xml
index f1060fe..ef8d53d 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -41,7 +41,7 @@ GNU General Public License for more details.\n
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.</string>
- <string name="credits_help_message">Software Design: Christopher Banines cbaines8@gmail.com Live Bus Data: provided under the Open Government License by the Southampton City Council ROMANSE office through the University of Southampton Open Data Service. Data: From the OpenStreetMap project, exported and used from the University of Southampton Open Data Service. Map Icons: From the "Map Icons Collection" (http://mapicons.nicolasmollet.com). Map Tiles: From the Mapnik project, through the OSMDroid libary. Database: Using the ORMLite libary.</string>
+ <string name="credits_help_message">Data: Map Icons: From the "Map Icons Collection" (http://mapicons.nicolasmollet.com). Map Tiles: From the Mapnik project, through the OSMDroid libary. Database: Using the ORMLite libary.</string>
<string name="donate_button">Donate</string>
<string name="bitcoin_error_message">You appear to have no bitcoin client installed, or at least none that listen for bitcoin uri\'s. Either install such a client, or just send coins via any method from any device to the address below.</string>
<string name="preferences">Preferences</string>
@@ -84,5 +84,30 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.<
<string name="menu_previous_stop">Previous</string>
<string name="menu_next_stop">Next</string>
<string name="menu_refresh_stop">Refresh</string>
+ <string name="about">About</string>
+ <string name="about_version">Version</string>
+ <string name="about_version_summary">0.15 (alpha)</string>
+ <string name="about_copyright">Copyright</string>
+ <string name="about_copyright_summary">© 2012, Christopher Baines</string>
+ <string name="about_license">License</string>
+ <string name="about_license_summary">GNU Public Licence v2</string>
+ <string name="about_project">Project Home</string>
+ <string name="about_project_summary">Source and Issue Tracker at GitHub</string>
+ <string name="about_developer">Developer</string>
+ <string name="about_developer_summary">Christopher Baines</string>
+ <string name="about_data">Life Bus Data</string>
+ <string name="about_data_summary">Provided under the Open Government License by the Southampton City Council ROMANSE office through the University of Southampton Open Data Service.</string>
+ <string name="about_android_market">Android Market App Page</string>
+ <string name="about_android_market_summary">insert link</string>
+ <string name="about_map_data">Map Data</string>
+ <string name="about_map_data_summary">From the OpenStreetMap project, exported and used from the University of Southampton Open Data Service.</string>
+ <string name="about_map_icons">Map Icons</string>
+ <string name="about_map_icons_summary">From the "Map Icons Collection"</string>
+ <string name="about_osm_map">Map</string>
+ <string name="about_osm_map_summary">Using the OSMDroid Library</string>
+ <string name="about_database">Database</string>
+ <string name="about_database_summary">Using the ORMLite library.</string>
+ <string name="about_donate">Donate</string>
+ <string name="about_donate_summary">Make a personal donation to the developer through Bitcoin.</string>
</resources> \ No newline at end of file
diff --git a/res/xml/about.xml b/res/xml/about.xml
new file mode 100644
index 0000000..59f6cef
--- /dev/null
+++ b/res/xml/about.xml
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="utf-8"?>
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
+
+ <PreferenceCategory
+ android:orderingFromXml="true"
+ android:title="@string/about" >
+ <Preference
+ android:key="about_version"
+ android:summary="@string/about_version_summary"
+ android:title="@string/about_version" />
+ <Preference
+ android:key="about_copyright"
+ android:summary="@string/about_copyright_summary"
+ android:title="@string/about_copyright" />
+ <Preference
+ android:key="about_license"
+ android:summary="@string/about_license_summary"
+ android:title="@string/about_license" />
+ <Preference
+ android:key="about_project"
+ android:summary="@string/about_project_summary"
+ android:title="@string/about_project" />
+ <Preference
+ android:key="about_developer"
+ android:summary="@string/about_developer_summary"
+ android:title="@string/about_developer" />
+ <Preference
+ android:key="about_data"
+ android:summary="@string/about_data_summary"
+ android:title="@string/about_data" />
+ <Preference
+ android:key="about_android_market"
+ android:summary="@string/about_android_market_summary"
+ android:title="@string/about_android_market" />
+ <Preference
+ android:key="about_map_data"
+ android:summary="@string/about_map_data_summary"
+ android:title="@string/about_map_data" />
+ <Preference
+ android:key="about_map_icons"
+ android:summary="@string/about_map_icons_summary"
+ android:title="@string/about_map_icons" />
+ <Preference
+ android:key="about_osm_map"
+ android:summary="@string/about_osm_map_summary"
+ android:title="@string/about_osm_map" />
+ <Preference
+ android:key="about_database"
+ android:summary="@string/about_database_summary"
+ android:title="@string/about_database" />
+ <Preference
+ android:key="about_donate"
+ android:summary="@string/about_donate_summary"
+ android:title="@string/about_donate" />
+ </PreferenceCategory>
+
+</PreferenceScreen> \ No newline at end of file
diff --git a/src/net/cbaines/suma/AboutActivity.java b/src/net/cbaines/suma/AboutActivity.java
index b330596..9c479c8 100644
--- a/src/net/cbaines/suma/AboutActivity.java
+++ b/src/net/cbaines/suma/AboutActivity.java
@@ -19,122 +19,65 @@
package net.cbaines.suma;
-import android.app.Activity;
import android.app.Dialog;
-import android.content.Context;
+import android.content.Intent;
+import android.net.Uri;
import android.os.Bundle;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.view.ViewGroup;
-import android.widget.BaseExpandableListAdapter;
-import android.widget.Button;
-import android.widget.ExpandableListView;
-import android.widget.TextView;
+import android.preference.Preference;
+import android.preference.PreferenceActivity;
+import android.preference.PreferenceScreen;
-public class AboutActivity extends Activity implements OnClickListener {
+public class AboutActivity extends PreferenceActivity {
static final int DONATE_DIALOG_ID = 0;
+ private static final String KEY_ABOUT_LICENSE = "about_license";
+ private static final String KEY_ABOUT_PROJECT = "about_project";
+ private static final String KEY_ABOUT_DEVELOPER = "about_developer";
+ private static final String KEY_ABOUT_DATA = "about_data";
+ private static final String KEY_ABOUT_ANDROID_MARKET = "about_android_market";
+ private static final String KEY_ABOUT_MAP_DATA = "about_map_data";
+ private static final String KEY_ABOUT_MAP_ICONS = "about_map_icons";
+ private static final String KEY_ABOUT_OSM_MAP = "about_osm_map";
+ private static final String KEY_ABOUT_DATABASE = "about_database";
+ private static final String KEY_ABOUT_DONATE = "about_donate";
+
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.about_dialog);
-
- ExpandableListView epView = (ExpandableListView) findViewById(R.id.helpExpandableListView);
- AboutListAdapter mAdapter = new AboutListAdapter(this);
- epView.setAdapter(mAdapter);
-
- Button donateButton = (Button) findViewById(R.id.donateButton);
- donateButton.setOnClickListener(this);
+ addPreferencesFromResource(R.xml.about);
}
- class AboutListAdapter extends BaseExpandableListAdapter {
- private String[] groups = { "Map", "Find", "Preferences", "Find my Location", "View", "About", "Favourites", "Licence", "Credits" };
- private LayoutInflater inflater;
- private Context cxt;
-
- public AboutListAdapter(Context cxt) {
- inflater = LayoutInflater.from(cxt);
- this.cxt = cxt;
- }
-
- public Object getChild(int groupPos, int childPos) {
- if (groupPos == 0) {
- return cxt.getResources().getString(R.string.map_help_message);
- } else if (groupPos == 1) {
- return cxt.getResources().getString(R.string.find_help_message);
- } else if (groupPos == 1) {
- return cxt.getResources().getString(R.string.preferences_help_message);
- } else if (groupPos == 2) {
- return cxt.getResources().getString(R.string.findmylocation_help_message);
- } else if (groupPos == 3) {
- return cxt.getResources().getString(R.string.view_help_message);
- } else if (groupPos == 4) {
- return cxt.getResources().getString(R.string.about_help_message);
- } else if (groupPos == 5) {
- return cxt.getResources().getString(R.string.favourites_help_message);
- } else if (groupPos == 6) {
- return cxt.getResources().getString(R.string.favourites_help_message);
- } else if (groupPos == 7) {
- return cxt.getResources().getString(R.string.licence_help_message);
- } else if (groupPos == 8) {
- return cxt.getResources().getString(R.string.credits_help_message);
- }
- return null;
- }
-
- public long getChildId(int groupPos, int childPos) {
- return childPos;
- }
-
- public View getChildView(int groupPos, int childPos, boolean isLastChild, View convertView, ViewGroup parent) {
- TextView tv = new TextView(cxt);
- tv.setText(getChild(groupPos, childPos).toString());
- return tv;
- }
-
- public int getChildrenCount(int groupPos) {
- return 1;
- }
-
- public Object getGroup(int groupPos) {
- return groups[groupPos];
- }
-
- public int getGroupCount() {
- return groups.length;
- }
-
- public long getGroupId(int groupPos) {
- return groupPos;
- }
-
- public View getGroupView(int groupPos, boolean isExpanded, View convertView, ViewGroup parent) {
- View v = null;
- if (convertView != null)
- v = convertView;
- else
- v = inflater.inflate(R.layout.view_group_row, parent, false);
- String gt = (String) getGroup(groupPos);
- TextView colorGroup = (TextView) v.findViewById(R.id.childname);
- if (gt != null)
- colorGroup.setText(gt);
- return v;
+ @Override
+ public boolean onPreferenceTreeClick(final PreferenceScreen preferenceScreen, final Preference preference) {
+ final String key = preference.getKey();
+ if (KEY_ABOUT_LICENSE.equals(key)) {
+ startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.gnu.org/licenses/gpl-2.0.html")));
+ } else if (KEY_ABOUT_PROJECT.equals(key)) {
+ startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/cbaines/SouthamptonUniversityMap")));
+ } else if (KEY_ABOUT_DEVELOPER.equals(key)) {
+ Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
+ emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { "cbaines8@gmail.com" });
+ emailIntent.setType("text/plain");
+
+ startActivity(Intent.createChooser(emailIntent, "Email the developer"));
+ } else if (KEY_ABOUT_DATA.equals(key)) {
+ startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://data.southampton.ac.uk/bus-routes.html")));
+ } else if (KEY_ABOUT_ANDROID_MARKET.equals(key)) {
+ startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("")));
+ } else if (KEY_ABOUT_MAP_DATA.equals(key)) {
+ startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(String.format("http://data.southampton.ac.uk/places.html"))));
+ } else if (KEY_ABOUT_MAP_ICONS.equals(key)) {
+ startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://mapicons.nicolasmollet.com/")));
+ } else if (KEY_ABOUT_OSM_MAP.equals(key)) {
+ startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.openstreetmap.org/")));
+ } else if (KEY_ABOUT_DATABASE.equals(key)) {
+ startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(String.format("http://ormlite.com/"))));
+ } else if (KEY_ABOUT_DONATE.equals(key)) {
+ showDialog(DONATE_DIALOG_ID);
}
- public boolean hasStableIds() {
- return true;
- }
-
- public boolean isChildSelectable(int groupPos, int childPos) {
- return true;
- }
-
- }
-
- public void onClick(View arg0) {
- showDialog(DONATE_DIALOG_ID);
+ return false;
}
protected Dialog onCreateDialog(int id) {
diff --git a/src/net/cbaines/suma/BusStopActivity.java b/src/net/cbaines/suma/BusStopActivity.java
index ad26c41..93f4ae6 100644
--- a/src/net/cbaines/suma/BusStopActivity.java
+++ b/src/net/cbaines/suma/BusStopActivity.java
@@ -30,7 +30,6 @@ import org.json.JSONException;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
-import android.graphics.Path.Direction;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
@@ -91,6 +90,8 @@ public class BusStopActivity extends OrmLiteBaseActivity<DatabaseHelper> impleme
private CheckBox U6RouteRadioButton;
private CheckBox U9RouteRadioButton;
+ private HashSet<BusRoute> routes = new HashSet<BusRoute>();
+
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.bustimes);
@@ -130,30 +131,35 @@ public class BusStopActivity extends OrmLiteBaseActivity<DatabaseHelper> impleme
if (route.code.equals("U1")) {
if (count != 0) {
U1RouteRadioButton.setVisibility(View.VISIBLE);
+ routes.add(route);
} else {
U1RouteRadioButton.setVisibility(View.GONE);
}
} else if (route.code.equals("U1N")) {
if (count != 0) {
U1NRouteRadioButton.setVisibility(View.VISIBLE);
+ routes.add(route);
} else {
U1NRouteRadioButton.setVisibility(View.GONE);
}
} else if (route.code.equals("U2")) {
if (count != 0) {
U2RouteRadioButton.setVisibility(View.VISIBLE);
+ routes.add(route);
} else {
U2RouteRadioButton.setVisibility(View.GONE);
}
} else if (route.code.equals("U6")) {
if (count != 0) {
U6RouteRadioButton.setVisibility(View.VISIBLE);
+ routes.add(route);
} else {
U6RouteRadioButton.setVisibility(View.GONE);
}
} else if (route.code.equals("U9")) {
if (count != 0) {
U9RouteRadioButton.setVisibility(View.VISIBLE);
+ routes.add(route);
} else {
U9RouteRadioButton.setVisibility(View.GONE);
}
@@ -324,131 +330,44 @@ public class BusStopActivity extends OrmLiteBaseActivity<DatabaseHelper> impleme
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle item selection
- if (item.getItemId() == R.id.menu_previous_stop || item.getItemId() == R.id.menu_next_stop) {
+ if (false) { // (item.getItemId() == R.id.menu_previous_stop || item.getItemId() == R.id.menu_next_stop) {
Log.v(TAG, "Got a request for the stop movement");
- if (visibleTimetable.size() != 0) {
- HashSet<BusRoute> routes = new HashSet<BusRoute>();
- HashSet<String> directions = new HashSet<String>();
-
- for (Stop stop : visibleTimetable) {
- routes.add(stop.bus.route);
- }
- Log.i(TAG, "routes " + routes);
- Log.v(TAG, routes.size() + " routes in the visible timetable");
+ Log.v(TAG, routes.size() + " routes avalible from this stop");
- for (Stop stop : visibleTimetable) {
- directions.add(stop.bus.direction);
- }
-
- Log.i(TAG, "directions " + directions);
-
- if (routes.size() == 1) {
-
- Log.v(TAG, directions.size() + " directions in the visible timetable");
-
- String direction;
- if (directions.size() <= 1) {
- if (directions.size() == 0) {
- direction = null;
- } else {
- direction = directions.iterator().next();
- }
-
- try {
- BusStop stop;
- if (item.getItemId() == R.id.menu_next_stop) {
- stop = routes.iterator().next().moveInRoute(this, getHelper().getBusStopDao().queryForId(busStopID), direction, 1);
- } else {
- stop = routes.iterator().next().moveInRoute(this, getHelper().getBusStopDao().queryForId(busStopID), direction, -1);
- }
- Intent i = new Intent(this, BusStopActivity.class);
- if (stop.id == null) {
- Log.e(TAG, "next.id == null");
- }
- i.putExtra("busStopID", stop.id);
- i.putExtra("busStopName", stop.description);
- startActivity(i);
- } catch (SQLException e) {
- e.printStackTrace();
- }
- } else { // Same route, different directions?
- // ATM, this is not considered possible?
- Log.e(TAG, "Big mistake in onOptionsItemSelected in BusStopActivity");
- }
- } else {
- HashSet<BusStop> stops = new HashSet<BusStop>();
-
- if (directions.size() <= 1) {
-
- for (BusRoute route : routes) {
- try {
- if (item.getItemId() == R.id.menu_next_stop) {
- stops.add(route.moveInRoute(this, getHelper().getBusStopDao().queryForId(busStopID), directions.iterator().next(), 1));
- } else {
- stops.add(route.moveInRoute(this, getHelper().getBusStopDao().queryForId(busStopID), directions.iterator().next(), -1));
- }
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
-
- Log.i(TAG, "stops " + stops);
-
- if (stops.size() == 1) {
- Intent i = new Intent(this, BusStopActivity.class);
- BusStop stop = stops.iterator().next();
- if (stop.id == null) {
- Log.e(TAG, "next.id == null");
- }
- i.putExtra("busStopID", stop.id);
- i.putExtra("busStopName", stop.description);
- startActivity(i);
- } else {
- // Show dialog
- Log.i(TAG, "Showing dialog");
- }
+ HashSet<BusStop> busStops = new HashSet<BusStop>();
+ for (BusRoute route : routes) {
+ try {
+ if (false) { // (item.getItemId() == R.id.menu_next_stop) {
+ busStops.add(route.moveInRoute(this, getHelper().getBusStopDao().queryForId(busStopID), null, 1));
} else {
+ busStops.add(route.moveInRoute(this, getHelper().getBusStopDao().queryForId(busStopID), null, -1));
+ }
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ }
- for (String direction : directions) {
-
- for (BusRoute route : routes) {
- try {
- BusStop stop;
- if (item.getItemId() == R.id.menu_next_stop) {
- stop = route.moveInRoute(this, getHelper().getBusStopDao().queryForId(busStopID), direction, 1);
- } else {
- stop = route.moveInRoute(this, getHelper().getBusStopDao().queryForId(busStopID), direction, -1);
- }
- if (stop != null) {
- stops.add(stop);
- }
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- }
-
- Log.i(TAG, "stops " + stops);
-
- if (stops.size() == 1) {
- Intent i = new Intent(this, BusStopActivity.class);
- BusStop stop = stops.iterator().next();
- if (stop.id == null) {
- Log.e(TAG, "next.id == null");
- }
- i.putExtra("busStopID", stop.id);
- i.putExtra("busStopName", stop.description);
- startActivity(i);
- } else {
- // Show dialog
- Log.i(TAG, "Showing dialog");
- }
+ Log.i(TAG, "stops " + busStops);
- }
+ if (busStops.size() == 1) {
+ Intent i = new Intent(this, BusStopActivity.class);
+ BusStop stop = busStops.iterator().next();
+ if (stop == null) {
+ Log.e(TAG, "stop == null");
}
+ if (stop.id == null) {
+ Log.e(TAG, "stop.id == null");
+ }
+ i.putExtra("busStopID", stop.id);
+ i.putExtra("busStopName", stop.description);
+ startActivity(i);
+ } else {
+ // Show dialog
+ Log.i(TAG, "Showing dialog");
}
+
} else if (item.getItemId() == R.id.menu_refresh_stop) {
if (mHandler != null) { // BusTimes are enabled
mHandler.removeCallbacks(refreshData);