diff options
Diffstat (limited to 'src/net/cbaines/suma/StopView.java')
-rw-r--r-- | src/net/cbaines/suma/StopView.java | 74 |
1 files changed, 26 insertions, 48 deletions
diff --git a/src/net/cbaines/suma/StopView.java b/src/net/cbaines/suma/StopView.java index f942137..27c3a4c 100644 --- a/src/net/cbaines/suma/StopView.java +++ b/src/net/cbaines/suma/StopView.java @@ -36,8 +36,7 @@ import android.widget.Toast; import com.j256.ormlite.android.apptools.OpenHelperManager; import com.j256.ormlite.dao.Dao; -public class StopView extends LinearLayout implements OnClickListener, - OnLongClickListener { +public class StopView extends LinearLayout implements OnClickListener, OnLongClickListener { // private final ImageView icon; @@ -66,10 +65,8 @@ public class StopView extends LinearLayout implements OnClickListener, setStop(stop); - addView(name, new LayoutParams(LayoutParams.WRAP_CONTENT, - LayoutParams.WRAP_CONTENT)); - addView(time, new LayoutParams(LayoutParams.FILL_PARENT, - LayoutParams.WRAP_CONTENT)); + addView(name, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); + addView(time, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); } public void setStop(Stop stop) { @@ -81,8 +78,7 @@ public class StopView extends LinearLayout implements OnClickListener, name.setText(stop.bus.getName()); time.setText(stop.getTimeToArival()); - DatabaseHelper helper = OpenHelperManager.getHelper(context, - DatabaseHelper.class); + DatabaseHelper helper = OpenHelperManager.getHelper(context, DatabaseHelper.class); try { Dao<Bus, Integer> busDao = helper.getBusDao(); @@ -91,31 +87,20 @@ public class StopView extends LinearLayout implements OnClickListener, if (stop.bus.id != null) { if (stop.live) { - onClickMessage = "Bus " - + stop.bus.toString() - + " at " - + DateFormat.getTimeInstance(DateFormat.SHORT) - .format(stop.arivalTime); + + onClickMessage = "Bus " + stop.bus.toString() + " at " + + DateFormat.getTimeInstance(DateFormat.SHORT).format(stop.arivalTime); } else { - onClickMessage = "Timetabled bus " - + stop.bus.toString() - + " at " - + DateFormat.getTimeInstance(DateFormat.SHORT) - .format(stop.arivalTime); + onClickMessage = "Timetabled bus " + stop.bus.toString() + " at " + + DateFormat.getTimeInstance(DateFormat.SHORT).format(stop.arivalTime); } } else { if (stop.live) { - onClickMessage = "Unidentified bus (" - + stop.bus.getName() - + ") at " - + DateFormat.getTimeInstance(DateFormat.SHORT) - .format(stop.arivalTime); + onClickMessage = "Unidentified bus (" + stop.bus.getName() + ") at " + + DateFormat.getTimeInstance(DateFormat.SHORT).format(stop.arivalTime); } else { - onClickMessage = "Timetabled bus (" - + stop.bus.getName() - + ") at " - + DateFormat.getTimeInstance(DateFormat.SHORT) - .format(stop.arivalTime); + onClickMessage = "Timetabled bus (" + stop.bus.getName() + ") at " + + DateFormat.getTimeInstance(DateFormat.SHORT).format(stop.arivalTime); } } } catch (SQLException e) { @@ -128,8 +113,8 @@ public class StopView extends LinearLayout implements OnClickListener, public void onClick(View v) { if (context.activityToast == null) { - context.activityToast = Toast.makeText(context, onClickMessage, - Toast.LENGTH_SHORT); + + context.activityToast = Toast.makeText(context, onClickMessage, Toast.LENGTH_SHORT); } else { context.activityToast.setText(onClickMessage); context.activityToast.setDuration(Toast.LENGTH_SHORT); @@ -139,8 +124,8 @@ public class StopView extends LinearLayout implements OnClickListener, } public boolean onLongClick(View v) { - DatabaseHelper helper = OpenHelperManager.getHelper(context, - DatabaseHelper.class); + + DatabaseHelper helper = OpenHelperManager.getHelper(context, DatabaseHelper.class); try { Dao<Bus, Integer> busDao = helper.getBusDao(); @@ -149,8 +134,7 @@ public class StopView extends LinearLayout implements OnClickListener, busDao.refresh(stop.bus); busRouteDao.refresh(stop.bus.route); - Log.i("StopView", "Bus route " + stop.bus.route + " Uni-Link " - + stop.bus.route.uniLink + " Bus ID " + stop.bus.id); + Log.i("StopView", "Bus route " + stop.bus.route + " Uni-Link " + stop.bus.route.uniLink + " Bus ID " + stop.bus.id); if (stop.bus.id != null && stop.bus.route.uniLink) { Intent i = new Intent(context, BusActivity.class); @@ -160,27 +144,21 @@ public class StopView extends LinearLayout implements OnClickListener, } else { if (!stop.bus.route.uniLink) { if (context.activityToast == null) { - context.activityToast = Toast - .makeText( - context, - "Bus schedules only avalible for Uni-Link buses", - Toast.LENGTH_SHORT); + + context.activityToast = Toast.makeText(context, "Bus schedules only avalible for Uni-Link buses", + Toast.LENGTH_SHORT); } else { - context.activityToast - .setText("Bus schedules only avalible for Uni-Link buses"); + context.activityToast.setText("Bus schedules only avalible for Uni-Link buses"); context.activityToast.setDuration(Toast.LENGTH_SHORT); } context.activityToast.show(); } else { if (context.activityToast == null) { - context.activityToast = Toast - .makeText( - context, - "Bus schedules not avalible for unidentified buses", - Toast.LENGTH_SHORT); + + context.activityToast = Toast.makeText(context, "Bus schedules not avalible for unidentified buses", + Toast.LENGTH_SHORT); } else { - context.activityToast - .setText("Bus schedules not avalible for unidentified buses"); + context.activityToast.setText("Bus schedules not avalible for unidentified buses"); context.activityToast.setDuration(Toast.LENGTH_SHORT); } context.activityToast.show(); |