aboutsummaryrefslogtreecommitdiff
path: root/src/net/cbaines/suma/POIView.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/cbaines/suma/POIView.java')
-rw-r--r--src/net/cbaines/suma/POIView.java129
1 files changed, 65 insertions, 64 deletions
diff --git a/src/net/cbaines/suma/POIView.java b/src/net/cbaines/suma/POIView.java
index fb8a6c6..b27b4f3 100644
--- a/src/net/cbaines/suma/POIView.java
+++ b/src/net/cbaines/suma/POIView.java
@@ -29,96 +29,97 @@ import android.widget.TextView;
public class POIView extends LinearLayout {
- private final static String TAG = "POIView";
+ private final static String TAG = "POIView";
- private final TextView name;
- private final TextView dist;
- private final BusRoutesView routes;
+ private final TextView name;
+ private final TextView dist;
+ private final BusRoutesView routes;
- private LayoutParams textLayoutParams;
+ private LayoutParams textLayoutParams;
- final int width;
+ final int width;
- public POIView(Context context, POI poi) {
- this(context, poi, -1);
- }
+ public POIView(Context context, POI poi) {
+ this(context, poi, -1);
+ }
- public POIView(Context context, POI poi, int distInM) {
- super(context);
+ public POIView(Context context, POI poi, int distInM) {
+ super(context);
- Display display = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
- width = display.getWidth();
- // int height = display.getHeight();
+ Display display = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
+ width = display.getWidth();
+ // int height = display.getHeight();
- this.setOrientation(HORIZONTAL);
+ this.setOrientation(HORIZONTAL);
- name = new TextView(context);
- name.setTextSize(16f);
- name.setGravity(Gravity.LEFT);
+ name = new TextView(context);
+ name.setTextSize(16f);
+ name.setGravity(Gravity.LEFT);
- dist = new TextView(context);
- dist.setTextSize(16f);
- dist.setGravity(Gravity.RIGHT);
+ dist = new TextView(context);
+ dist.setTextSize(16f);
+ dist.setGravity(Gravity.RIGHT);
- routes = new BusRoutesView(context, (byte) 0);
+ routes = new BusRoutesView(context, (byte) 0);
- textLayoutParams = new LayoutParams(width - (width / 4), LayoutParams.WRAP_CONTENT);
- LayoutParams distLayoutParams = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
- LayoutParams busRouteLayoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
+ textLayoutParams = new LayoutParams(width - (width / 4), LayoutParams.WRAP_CONTENT);
+ LayoutParams distLayoutParams = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
+ LayoutParams busRouteLayoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
- setPOIAndDist(poi, distInM);
+ setPOIAndDist(poi, distInM);
- addView(routes, busRouteLayoutParams);
- addView(name, textLayoutParams);
- addView(dist, distLayoutParams);
- }
+ addView(routes, busRouteLayoutParams);
+ addView(name, textLayoutParams);
+ addView(dist, distLayoutParams);
+ }
- public void setPOI(POI poi) {
- setPOIAndDist(poi, -1);
- }
+ public void setPOI(POI poi) {
+ setPOIAndDist(poi, -1);
+ }
- public void setPOIAndDist(POI poi, int distInM) {
+ public void setPOIAndDist(POI poi, int distInM) {
- // Log.i(TAG, "Looking at poi " + poi.id);
+ // Log.i(TAG, "Looking at poi " + poi.id);
- if (poi.type == POI.BUILDING) {
- Building building = (Building) poi;
- // Log.i(TAG, "Its a building of name " + building.name);
+ if (poi.type == POI.BUILDING) {
+ Building building = (Building) poi;
+ // Log.i(TAG, "Its a building of name " + building.name);
- name.setText(building.name + " (" + building.id + ")");
- } else if (poi.type == POI.BUS_STOP) {
+ name.setText(building.name + " (" + building.id + ")");
+ } else if (poi.type == POI.BUS_STOP) {
- BusStop busStop = (BusStop) poi;
- // Log.i(TAG, "Its a bus stop of description " + busStop.description);
+ BusStop busStop = (BusStop) poi;
+ // Log.i(TAG, "Its a bus stop of description " +
+ // busStop.description);
- name.setText(busStop.description + " (" + busStop.id + ")");
+ name.setText(busStop.description + " (" + busStop.id + ")");
- routes.setRoutes(busStop.routes);
+ routes.setRoutes(busStop.routes);
- } else if (poi.type == POI.SITE) {
+ } else if (poi.type == POI.SITE) {
- Site site = (Site) poi;
- // Log.i(TAG, "Its a site of name " + site.name);
+ Site site = (Site) poi;
+ // Log.i(TAG, "Its a site of name " + site.name);
- name.setText(site.name + " (" + site.id + ")");
- } else {
- Log.w(TAG, "Cant identify " + poi.type);
+ name.setText(site.name + " (" + site.id + ")");
+ } else {
+ Log.w(TAG, "Cant identify " + poi.type);
- name.setText(poi.id);
- }
+ name.setText(poi.id);
+ }
+
+ textLayoutParams = new LayoutParams(width - (width / 4), LayoutParams.WRAP_CONTENT);
- textLayoutParams = new LayoutParams(width - (width / 4), LayoutParams.WRAP_CONTENT);
-
- if (distInM != -1) {
- textLayoutParams.width = width - (width / 4);
- name.requestLayout();
- dist.setText(String.valueOf(distInM) + "m");
- } else {
- textLayoutParams.width = LayoutParams.FILL_PARENT;
- name.requestLayout();
- dist.setText("");
- // Log.w("POIView", "No dist avalible for S" + poi.id);
+ if (distInM != -1) {
+ textLayoutParams.width = width - (width / 4);
+ name.requestLayout();
+ dist.setText(String.valueOf(distInM) + "m");
+ } else {
+ textLayoutParams.width = LayoutParams.FILL_PARENT;
+ name.requestLayout();
+ dist.setText("");
+ // Log.w("POIView", "No dist avalible for S" + poi.id);
+ }
}
- }
} \ No newline at end of file