From 1e18e360f0a34811cedfa3bfc8c0c9c278c09831 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Wed, 8 Feb 2012 16:55:28 +0000 Subject: Bus stop movement is now working, needs more testing though. --- src/net/cbaines/suma/BusStopActivity.java | 33 +++++++++++++++++++++++++++---- src/net/cbaines/suma/POIDialog.java | 4 ---- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/src/net/cbaines/suma/BusStopActivity.java b/src/net/cbaines/suma/BusStopActivity.java index b50e340..b2eff62 100644 --- a/src/net/cbaines/suma/BusStopActivity.java +++ b/src/net/cbaines/suma/BusStopActivity.java @@ -350,10 +350,14 @@ public class BusStopActivity extends OrmLiteBaseActivity impleme for (BusRoute route : routes) { try { + BusStop tmpStop; if (item.getItemId() == R.id.menu_next_stop) { - busStops.add(route.moveInRoute(this, getHelper().getBusStopDao().queryForId(busStopID), null, 1)); + tmpStop = route.moveInRoute(this, getHelper().getBusStopDao().queryForId(busStopID), null, 1); } else { - busStops.add(route.moveInRoute(this, getHelper().getBusStopDao().queryForId(busStopID), null, -1)); + tmpStop = route.moveInRoute(this, getHelper().getBusStopDao().queryForId(busStopID), null, -1); + } + if (!busStops.contains(tmpStop)) { + busStops.add(tmpStop); } } catch (SQLException e) { e.printStackTrace(); @@ -474,8 +478,29 @@ public class BusStopActivity extends OrmLiteBaseActivity impleme } @Override - public void onItemClick(AdapterView arg0, View arg1, int arg2, long arg3) { - // TODO Auto-generated method stub + 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); + + Log.i(TAG, "POI " + poiId + " selected"); + + Intent i = new Intent(this, BusStopActivity.class); + try { + busStop = busStopDao.queryForId(poiId); + + if (busStop == null) { + Log.e(TAG, "stop == null"); + } + if (busStop.id == null) { + Log.e(TAG, "stop.id == null"); + } + i.putExtra("busStopID", busStop.id); + i.putExtra("busStopName", busStop.description); + startActivity(i); + } catch (SQLException e) { + e.printStackTrace(); + } } } diff --git a/src/net/cbaines/suma/POIDialog.java b/src/net/cbaines/suma/POIDialog.java index 8107d06..67be966 100644 --- a/src/net/cbaines/suma/POIDialog.java +++ b/src/net/cbaines/suma/POIDialog.java @@ -80,10 +80,6 @@ public class POIDialog extends Dialog { }); } - void setTitle(String title) { - setTitle(title); - } - void setOnItemClickListener(OnItemClickListener item) { listItems.setOnItemClickListener(item); -- cgit v1.2.3