diff options
Diffstat (limited to 'src/net/cbaines/suma/BusSpecificStopView.java')
-rw-r--r-- | src/net/cbaines/suma/BusSpecificStopView.java | 53 |
1 files changed, 28 insertions, 25 deletions
diff --git a/src/net/cbaines/suma/BusSpecificStopView.java b/src/net/cbaines/suma/BusSpecificStopView.java index fdb6f56..92ec8c7 100644 --- a/src/net/cbaines/suma/BusSpecificStopView.java +++ b/src/net/cbaines/suma/BusSpecificStopView.java @@ -28,19 +28,18 @@ import android.content.res.Resources; import android.net.Uri; import android.util.Log; import android.view.Gravity; -import android.view.LayoutInflater; 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.RelativeLayout; import android.widget.TextView; 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 RelativeLayout implements OnClickListener, OnLongClickListener { private static final String TAG = "BusSpecificStopView"; @@ -63,14 +62,12 @@ public class BusSpecificStopView extends LinearLayout implements OnClickListener this.context = context; - this.setOrientation(HORIZONTAL); - location = new TextView(context); location.setTextSize(22f); + location.setGravity(Gravity.LEFT); time = new TextView(context); time.setTextSize(22f); - time.setGravity(Gravity.RIGHT); timeProgress = new ProgressBar(context, null, android.R.attr.progressBarStyleSmall); @@ -80,9 +77,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)); - addView(timeProgress, 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) { @@ -96,14 +106,19 @@ public class BusSpecificStopView extends LinearLayout implements OnClickListener } else { location.setText(stop.busStop.description); // TODO } - if (stop.arivalTime != null) { + + if (stop.arivalTime != null) { // Time available time.setText(stop.getShortTimeToArival()); time.setVisibility(View.VISIBLE); timeProgress.setVisibility(View.GONE); - } else { - time.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); @@ -122,19 +137,7 @@ public class BusSpecificStopView extends LinearLayout implements OnClickListener + 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(); |