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.java72
1 files changed, 24 insertions, 48 deletions
diff --git a/src/net/cbaines/suma/BusStopActivity.java b/src/net/cbaines/suma/BusStopActivity.java
index d9eaed3..0d4dea4 100644
--- a/src/net/cbaines/suma/BusStopActivity.java
+++ b/src/net/cbaines/suma/BusStopActivity.java
@@ -59,8 +59,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 {
final static String TAG = "BusTimeActivity";
@@ -106,7 +106,7 @@ public class BusStopActivity extends OrmLiteBaseActivity<DatabaseHelper>
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.bustimes);
+ setContentView(R.layout.bus_stop_activity);
final DatabaseHelper helper = getHelper();
@@ -132,15 +132,12 @@ public class BusStopActivity extends OrmLiteBaseActivity<DatabaseHelper>
Dao<RouteStops, Integer> routeStopsDao = helper.getRouteStopsDao();
for (BusRoute route : busRouteDao) {
- QueryBuilder<RouteStops, Integer> queryBuilder = routeStopsDao
- .queryBuilder();
+ QueryBuilder<RouteStops, Integer> queryBuilder = routeStopsDao.queryBuilder();
- queryBuilder.where()
- .eq(RouteStops.ROUTE_ID_FIELD_NAME, route.id).and()
+ queryBuilder.where().eq(RouteStops.ROUTE_ID_FIELD_NAME, route.id).and()
.eq(RouteStops.STOP_ID_FIELD_NAME, busStopID);
queryBuilder.setCountOf(true);
- PreparedQuery<RouteStops> preparedQuery = queryBuilder
- .prepare();
+ PreparedQuery<RouteStops> preparedQuery = queryBuilder.prepare();
long count = routeStopsDao.countOf(preparedQuery);
@@ -211,12 +208,9 @@ public class BusStopActivity extends OrmLiteBaseActivity<DatabaseHelper>
public void onResume() {
super.onResume();
- SharedPreferences sharedPrefs = PreferenceManager
- .getDefaultSharedPreferences(this);
- if (sharedPrefs.getBoolean(UNI_LINK_BUS_TIMES,
- UNI_LINK_BUS_TIMES_ENABLED_BY_DEFAULT)
- || sharedPrefs.getBoolean(NON_UNI_LINK_BUS_TIMES,
- NON_UNI_LINK_BUS_TIMES_ENABLED_BY_DEFAULT)) {
+ SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
+ if (sharedPrefs.getBoolean(UNI_LINK_BUS_TIMES, UNI_LINK_BUS_TIMES_ENABLED_BY_DEFAULT)
+ || sharedPrefs.getBoolean(NON_UNI_LINK_BUS_TIMES, NON_UNI_LINK_BUS_TIMES_ENABLED_BY_DEFAULT)) {
Log.i(TAG, "Live Times enabled");
timetable = (Timetable) getLastNonConfigurationInstance();
@@ -294,8 +288,7 @@ public class BusStopActivity extends OrmLiteBaseActivity<DatabaseHelper>
return timetable;
}
- private class GetTimetableTask extends
- AsyncTask<String, Integer, Timetable> {
+ private class GetTimetableTask extends AsyncTask<String, Integer, Timetable> {
String errorMessage;
protected void onPreExecute() {
@@ -305,21 +298,12 @@ public class BusStopActivity extends OrmLiteBaseActivity<DatabaseHelper>
protected Timetable doInBackground(String... activity) {
Timetable newTimetable = null;
try {
- final SharedPreferences sharedPrefs = PreferenceManager
- .getDefaultSharedPreferences(instance);
-
- newTimetable = DataManager
- .getTimetable(
- instance,
- busStopID,
- 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));
+ final SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(instance);
+
+ newTimetable = DataManager.getTimetable(instance, busStopID, 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();
@@ -365,8 +349,7 @@ public class BusStopActivity extends OrmLiteBaseActivity<DatabaseHelper>
@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 (item.getItemId() == R.id.menu_previous_stop || item.getItemId() == R.id.menu_next_stop) {
Log.v(TAG, "Got a request for the stop movement");
Log.v(TAG, routes.size() + " routes avalible from this stop");
@@ -377,11 +360,9 @@ public class BusStopActivity extends OrmLiteBaseActivity<DatabaseHelper>
try {
Set<BusStop> tmpStops;
if (item.getItemId() == R.id.menu_next_stop) {
- tmpStops = route.moveInRoute(this, getHelper()
- .getBusStopDao().queryForId(busStopID), 1);
+ tmpStops = route.moveInRoute(this, getHelper().getBusStopDao().queryForId(busStopID), 1);
} else {
- tmpStops = route.moveInRoute(this, getHelper()
- .getBusStopDao().queryForId(busStopID), -1);
+ tmpStops = route.moveInRoute(this, getHelper().getBusStopDao().queryForId(busStopID), -1);
}
for (BusStop busStop : tmpStops) {
if (!busStops.contains(busStop)) {
@@ -410,8 +391,7 @@ public class BusStopActivity extends OrmLiteBaseActivity<DatabaseHelper>
} else {
showDialog(POI_DIALOG_ID);
if (busDialog == null) {
- Log.e(TAG,
- "Very wierd, just tried to launch the favourite's dialog, but its null?");
+ Log.e(TAG, "Very wierd, just tried to launch the favourite's dialog, but its null?");
return false;
}
@@ -450,11 +430,9 @@ public class BusStopActivity extends OrmLiteBaseActivity<DatabaseHelper>
busTimeContentLayout.setGravity(Gravity.CENTER);
} else {
- for (Iterator<Stop> stopIter = visibleTimetable.iterator(); stopIter
- .hasNext();) {
+ for (Iterator<Stop> stopIter = visibleTimetable.iterator(); stopIter.hasNext();) {
Stop stop = stopIter.next();
- Log.i(TAG, "Begin filtering, looking at " + stop
- + " with route " + stop.bus.route.code);
+ Log.i(TAG, "Begin filtering, looking at " + stop + " with route " + stop.bus.route.code);
if (stop.bus.route.code.equals("U1")) {
if (!U1RouteRadioButton.isChecked()) {
stopIter.remove();
@@ -480,8 +458,7 @@ public class BusStopActivity extends OrmLiteBaseActivity<DatabaseHelper>
if (visibleTimetable.size() == 0) {
busTimeContentLayout.setGravity(Gravity.CENTER);
- busStopMessage
- .setText("No Busses (With the current enabled routes)");
+ busStopMessage.setText("No Busses (With the current enabled routes)");
busStopMessage.setVisibility(View.VISIBLE);
busTimeList.setVisibility(View.GONE);
} else {
@@ -510,8 +487,7 @@ public class BusStopActivity extends OrmLiteBaseActivity<DatabaseHelper>
return null;
}
- public void onItemClick(AdapterView<?> parent, View view, int position,
- long id) {
+ public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Log.i(TAG, "OnItemClick pos " + position + " id " + id);
String poiId = busDialog.adapter.getItemStringId(position);