diff options
-rw-r--r-- | res/layout/poi_dialog.xml | 4 | ||||
-rw-r--r-- | src/net/cbaines/suma/BuildingActivity.java | 8 | ||||
-rw-r--r-- | src/net/cbaines/suma/BusRoutesView.java | 78 | ||||
-rw-r--r-- | src/net/cbaines/suma/POIView.java | 81 |
4 files changed, 89 insertions, 82 deletions
diff --git a/res/layout/poi_dialog.xml b/res/layout/poi_dialog.xml index 44cb02a..cf97083 100644 --- a/res/layout/poi_dialog.xml +++ b/res/layout/poi_dialog.xml @@ -4,7 +4,9 @@ android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="horizontal" - android:padding="10dp" > + android:paddingBottom="10dp" + android:paddingLeft="10dp" + android:paddingRight="10dp" > <TextView android:id="@+id/favouriteDialogMessage" diff --git a/src/net/cbaines/suma/BuildingActivity.java b/src/net/cbaines/suma/BuildingActivity.java index df6dea2..62fbb44 100644 --- a/src/net/cbaines/suma/BuildingActivity.java +++ b/src/net/cbaines/suma/BuildingActivity.java @@ -25,10 +25,6 @@ import java.util.HashSet; import android.content.Context; import android.os.Bundle; - -import com.hp.hpl.jena.rdf.model.Model; -import com.hp.hpl.jena.rdf.model.ModelFactory; -import com.hp.hpl.jena.util.FileManager; import com.j256.ormlite.android.apptools.OrmLiteBaseActivity; public class BuildingActivity extends OrmLiteBaseActivity<DatabaseHelper> { @@ -48,7 +44,7 @@ public class BuildingActivity extends OrmLiteBaseActivity<DatabaseHelper> { final DatabaseHelper helper = getHelper(); // create an empty model - Model model = ModelFactory.createDefaultModel(); + // Model model = ModelFactory.createDefaultModel(); // use the FileManager to find the input file InputStream in = getResources().openRawResource(R.raw.u9); @@ -57,7 +53,7 @@ public class BuildingActivity extends OrmLiteBaseActivity<DatabaseHelper> { } // read the RDF/XML file - model.read(in, null); + // model.read(in, null); instance = this; diff --git a/src/net/cbaines/suma/BusRoutesView.java b/src/net/cbaines/suma/BusRoutesView.java new file mode 100644 index 0000000..f5af076 --- /dev/null +++ b/src/net/cbaines/suma/BusRoutesView.java @@ -0,0 +1,78 @@ +package net.cbaines.suma; + +import android.R.color; +import android.content.Context; +import android.view.View; +import android.widget.TableLayout; +import android.widget.TextView; + +public class BusRoutesView extends TableLayout { + + private TextView u1; + private TextView u1n; + private TextView u2; + private TextView u6; + private TextView u9; + + public BusRoutesView(Context context, final byte routes) { + super(context); + + u1 = new TextView(context); + u1.setText(R.string.U1); + u1.setBackgroundResource(R.drawable.u1_back_selected); + // /u1.setTextColor(color.white); + + u1n = new TextView(context); + u1n.setText(R.string.U1N); + u1n.setBackgroundResource(R.drawable.u1n_back_selected); + // u1n.setTextColor(color.white); + + u2 = new TextView(context); + u2.setText(R.string.U2); + u2.setBackgroundResource(R.drawable.u2_back_selected); + // u2.setTextColor(color.white); + + u6 = new TextView(context); + u6.setText(R.string.U6); + u6.setBackgroundResource(R.drawable.u6_back_selected); + // u6.setTextColor(color.white); + + u9 = new TextView(context); + u9.setText(R.string.U9); + u9.setBackgroundResource(R.drawable.u9_back_selected); + // u9.setTextColor(color.white); + + } + + void setRoutes(byte routes) { + + removeView(u1); + removeView(u1n); + removeView(u2); + removeView(u6); + removeView(u9); + + LayoutParams busRouteLayoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); + + if ((routes & (1 << 0)) != 0) { + addView(u1, busRouteLayoutParams); + u1.setVisibility(View.VISIBLE); + } + if ((routes & (1 << 1)) != 0) { + u1n.setVisibility(View.VISIBLE); + addView(u1n, busRouteLayoutParams); + } + if ((routes & (1 << 2)) != 0) { + u2.setVisibility(View.VISIBLE); + addView(u2, busRouteLayoutParams); + } + if ((routes & (1 << 3)) != 0) { + u6.setVisibility(View.VISIBLE); + addView(u6, busRouteLayoutParams); + } + if ((routes & (1 << 4)) != 0) { + u9.setVisibility(View.VISIBLE); + addView(u9, busRouteLayoutParams); + } + } +} diff --git a/src/net/cbaines/suma/POIView.java b/src/net/cbaines/suma/POIView.java index 0fb1496..d312f37 100644 --- a/src/net/cbaines/suma/POIView.java +++ b/src/net/cbaines/suma/POIView.java @@ -27,6 +27,7 @@ import android.view.View; import android.view.WindowManager; import android.widget.LinearLayout; import android.widget.TextView; +import android.widget.TableLayout.LayoutParams; public class POIView extends LinearLayout { @@ -34,12 +35,7 @@ public class POIView extends LinearLayout { private final TextView name; private final TextView dist; - - private TextView u1; - private TextView u1n; - private TextView u2; - private TextView u6; - private TextView u9; + private final BusRoutesView routes; private LayoutParams textLayoutParams; @@ -66,60 +62,15 @@ public class POIView extends LinearLayout { dist.setTextSize(16f); dist.setGravity(Gravity.RIGHT); - u1 = new TextView(context); - u1.setText(R.string.U1); - u1.setBackgroundResource(R.drawable.u1_back_selected); - u1n = new TextView(context); - u1n.setText(R.string.U1N); - u1n.setBackgroundResource(R.drawable.u1n_back_selected); - u2 = new TextView(context); - u2.setText(R.string.U2); - u2.setBackgroundResource(R.drawable.u2_back_selected); - u6 = new TextView(context); - u6.setText(R.string.U6); - u6.setBackgroundResource(R.drawable.u6_back_selected); - u9 = new TextView(context); - u9.setText(R.string.U9); - u9.setBackgroundResource(R.drawable.u9_back_selected); + 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); - - setPOIAndDist(poi, distInM); - LayoutParams busRouteLayoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); - addView(u1, busRouteLayoutParams); - addView(u1n, busRouteLayoutParams); - addView(u2, busRouteLayoutParams); - addView(u6, busRouteLayoutParams); - addView(u9, busRouteLayoutParams); - - u1.setVisibility(View.GONE); - u1n.setVisibility(View.GONE); - u2.setVisibility(View.GONE); - u6.setVisibility(View.GONE); - u9.setVisibility(View.GONE); - - if (poi.type == POI.BUS_STOP) { - BusStop busStop = (BusStop) poi; - if ((busStop.routes & (1 << 0)) != 0) { - u1.setVisibility(View.VISIBLE); - } - if ((busStop.routes & (1 << 1)) != 0) { - u1n.setVisibility(View.VISIBLE); - } - if ((busStop.routes & (1 << 2)) != 0) { - u2.setVisibility(View.VISIBLE); - } - if ((busStop.routes & (1 << 3)) != 0) { - u6.setVisibility(View.VISIBLE); - } - if ((busStop.routes & (1 << 4)) != 0) { - u9.setVisibility(View.VISIBLE); - } - } + setPOIAndDist(poi, distInM); + addView(routes, busRouteLayoutParams); addView(name, textLayoutParams); addView(dist, distLayoutParams); } @@ -132,12 +83,6 @@ public class POIView extends LinearLayout { // Log.i(TAG, "Looking at poi " + poi.id); - u1.setVisibility(View.GONE); - u1n.setVisibility(View.GONE); - u2.setVisibility(View.GONE); - u6.setVisibility(View.GONE); - u9.setVisibility(View.GONE); - if (poi.type == POI.BUILDING) { Building building = (Building) poi; // Log.i(TAG, "Its a building of name " + building.name); @@ -150,21 +95,7 @@ public class POIView extends LinearLayout { name.setText(busStop.description + " (" + busStop.id + ")"); - if ((busStop.routes & (1 << 0)) != 0) { - u1.setVisibility(View.VISIBLE); - } - if ((busStop.routes & (1 << 1)) != 0) { - u1n.setVisibility(View.VISIBLE); - } - if ((busStop.routes & (1 << 2)) != 0) { - u2.setVisibility(View.VISIBLE); - } - if ((busStop.routes & (1 << 3)) != 0) { - u6.setVisibility(View.VISIBLE); - } - if ((busStop.routes & (1 << 4)) != 0) { - u9.setVisibility(View.VISIBLE); - } + routes.setRoutes(busStop.routes); } else if (poi.type == POI.SITE) { |