aboutsummaryrefslogtreecommitdiff
path: root/src/net/cbaines/suma/BusSpecificStopView.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/cbaines/suma/BusSpecificStopView.java')
-rw-r--r--src/net/cbaines/suma/BusSpecificStopView.java93
1 files changed, 50 insertions, 43 deletions
diff --git a/src/net/cbaines/suma/BusSpecificStopView.java b/src/net/cbaines/suma/BusSpecificStopView.java
index f0fc273..777d031 100644
--- a/src/net/cbaines/suma/BusSpecificStopView.java
+++ b/src/net/cbaines/suma/BusSpecificStopView.java
@@ -32,6 +32,7 @@ import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnLongClickListener;
import android.widget.LinearLayout;
+import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
@@ -46,6 +47,8 @@ public class BusSpecificStopView extends LinearLayout implements OnClickListener
private final TextView location;
private final TextView time;
+ private final ProgressBar timeProgress;
+
private String onClickMessage = "";
private final BusActivity context;
@@ -59,14 +62,19 @@ public class BusSpecificStopView extends LinearLayout implements OnClickListener
this.context = context;
- this.setOrientation(HORIZONTAL);
+ View.inflate(context, R.layout.bus_specific_stop_view, this);
- location = new TextView(context);
+ // location = new TextView(context);
+ location = (TextView) findViewById(R.id.busSpecificStopViewName);
location.setTextSize(22f);
+ location.setGravity(Gravity.LEFT);
- time = new TextView(context);
+ // time = new TextView(context);
+ time = (TextView) findViewById(R.id.busSpecificStopViewTime);
time.setTextSize(22f);
- time.setGravity(Gravity.RIGHT);
+
+ // timeProgress = new ProgressBar(context, null, android.R.attr.progressBarStyleSmall);
+ timeProgress = (ProgressBar) findViewById(R.id.busSpecificStopViewProgressBar);
Resources resources = context.getResources();
onClickHelpMessage = resources.getString(R.string.bus_stop_view_on_click_toast_help_message);
@@ -74,9 +82,22 @@ public class BusSpecificStopView extends LinearLayout implements OnClickListener
setStop(stop);
- addView(location, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
- addView(time, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
-
+ // RelativeLayout.LayoutParams relativeParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
+ // LayoutParams.WRAP_CONTENT);
+ // relativeParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
+ //
+ // RelativeLayout.LayoutParams relativeParams2 = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
+ // LayoutParams.FILL_PARENT);
+ // relativeParams2.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
+ //
+ // addView(location, relativeParams);
+ // addView(time, relativeParams2);
+ //
+ // // LinearLayout progressLayout = new LinearLayout(context);
+ // // progressLayout.setOrientation(LinearLayout.VERTICAL);
+ // // progressLayout.addView(timeProgress, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
+ //
+ // addView(timeProgress, relativeParams2);
}
public void setStop(Stop stop) {
@@ -85,15 +106,24 @@ public class BusSpecificStopView extends LinearLayout implements OnClickListener
this.stop = stop;
- if (stop.busStop.description.length() > 20) {
- location.setText(stop.busStop.description.substring(0, 20)); // TODO
- } else {
- location.setText(stop.busStop.description); // TODO
- }
- if (stop.arivalTime != null) {
+ // if (stop.busStop.description.length() > 20) {
+ // location.setText(stop.busStop.description.substring(0, 20)); // TODO
+ // } else {
+ location.setText(stop.busStop.description); // TODO
+ // }
+
+ if (stop.arivalTime != null) { // Time available
time.setText(stop.getShortTimeToArival());
- } else {
+ time.setVisibility(View.VISIBLE);
+ timeProgress.setVisibility(View.GONE);
+ } else if (stop instanceof StopLoading) {
+ time.setText("");
+ time.setVisibility(View.GONE);
+ timeProgress.setVisibility(View.VISIBLE);
+ } else { // No time available (yet) and not currently loading
+ time.setVisibility(View.GONE);
time.setText("");
+ timeProgress.setVisibility(View.GONE);
}
DatabaseHelper helper = OpenHelperManager.getHelper(context, DatabaseHelper.class);
@@ -104,38 +134,15 @@ public class BusSpecificStopView extends LinearLayout implements OnClickListener
busDao.refresh(stop.bus);
if (stop.arivalTime != null) {
-
- if (stop.bus.id != null) {
- if (stop.live) {
- 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);
- }
+ if (stop.live) {
+ onClickMessage = stop.busStop.description + " 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);
- } else {
- onClickMessage = "Timetabled bus (" + stop.bus.getName() + ") at "
- + DateFormat.getTimeInstance(DateFormat.SHORT).format(stop.arivalTime);
- }
+ onClickMessage = stop.busStop.description + " at "
+ + DateFormat.getTimeInstance(DateFormat.SHORT).format(stop.arivalTime) + " (timetabled)";
}
} else {
- if (stop.bus.id != null) {
- if (stop.live) {
- onClickMessage = "Bus " + stop.bus.toString();
- } else {
- onClickMessage = "Timetabled bus " + stop.bus.toString();
- }
- } else {
- if (stop.live) {
- onClickMessage = "Unidentified bus (" + stop.bus.getName() + ")";
- } else {
- onClickMessage = "Timetabled bus (" + stop.bus.getName() + ")";
- }
- }
+ onClickMessage = stop.busStop.description + " on route, but arival time is not avalible";
}
} catch (SQLException e) {
e.printStackTrace();