diff options
Diffstat (limited to 'src/net/cbaines/suma/BusSpecificStopView.java')
-rw-r--r-- | src/net/cbaines/suma/BusSpecificStopView.java | 75 |
1 files changed, 29 insertions, 46 deletions
diff --git a/src/net/cbaines/suma/BusSpecificStopView.java b/src/net/cbaines/suma/BusSpecificStopView.java index bdebcba..4cac19a 100644 --- a/src/net/cbaines/suma/BusSpecificStopView.java +++ b/src/net/cbaines/suma/BusSpecificStopView.java @@ -36,8 +36,7 @@ import android.widget.Toast; import com.j256.ormlite.android.apptools.OpenHelperManager; import com.j256.ormlite.dao.Dao; -public class BusSpecificStopView extends LinearLayout implements - OnClickListener, OnLongClickListener { +public class BusSpecificStopView extends LinearLayout implements OnClickListener, OnLongClickListener { private static final String TAG = "BusSpecificStopView"; @@ -66,10 +65,8 @@ public class BusSpecificStopView extends LinearLayout implements setStop(stop); - addView(location, new LayoutParams(LayoutParams.WRAP_CONTENT, - LayoutParams.WRAP_CONTENT)); - addView(time, new LayoutParams(LayoutParams.FILL_PARENT, - LayoutParams.WRAP_CONTENT)); + addView(location, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); + addView(time, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); } @@ -100,8 +97,7 @@ public class BusSpecificStopView extends LinearLayout implements time.setText(""); } - DatabaseHelper helper = OpenHelperManager.getHelper(context, - DatabaseHelper.class); + DatabaseHelper helper = OpenHelperManager.getHelper(context, DatabaseHelper.class); try { Dao<Bus, Integer> busDao = helper.getBusDao(); @@ -112,31 +108,21 @@ public class BusSpecificStopView extends LinearLayout implements 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); + } } } else { @@ -144,16 +130,15 @@ public class BusSpecificStopView extends LinearLayout implements if (stop.live) { onClickMessage = "Bus " + stop.bus.toString(); } else { - onClickMessage = "Timetabled bus " - + stop.bus.toString(); + + onClickMessage = "Timetabled bus " + stop.bus.toString(); } } else { if (stop.live) { - onClickMessage = "Unidentified bus (" - + stop.bus.getName() + ")"; + onClickMessage = "Unidentified bus (" + stop.bus.getName() + ")"; } else { - onClickMessage = "Timetabled bus (" - + stop.bus.getName() + ")"; + onClickMessage = "Timetabled bus (" + stop.bus.getName() + ")"; + } } } @@ -167,8 +152,9 @@ public class BusSpecificStopView extends LinearLayout implements 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); @@ -177,8 +163,8 @@ public class BusSpecificStopView extends LinearLayout implements } public boolean onLongClick(View v) { // TODO - DatabaseHelper helper = OpenHelperManager.getHelper(context, - DatabaseHelper.class); + + DatabaseHelper helper = OpenHelperManager.getHelper(context, DatabaseHelper.class); try { Dao<Bus, Integer> busDao = helper.getBusDao(); @@ -191,14 +177,12 @@ public class BusSpecificStopView extends LinearLayout implements ((Activity) context).startActivityForResult(i, 0); } else { if (context.activityToast == null) { - context.activityToast = Toast - .makeText( - context, - "Arival prediction not avalible for timetabled buses", - Toast.LENGTH_SHORT); + + context.activityToast = Toast.makeText(context, "Arival prediction not avalible for timetabled buses", + Toast.LENGTH_SHORT); } else { - context.activityToast - .setText("Arival prediction not avalible for timetabled buses"); + context.activityToast.setText("Arival prediction not avalible for timetabled buses"); + context.activityToast.setDuration(Toast.LENGTH_SHORT); } context.activityToast.show(); @@ -209,5 +193,4 @@ public class BusSpecificStopView extends LinearLayout implements } return false; } - } |