aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gen/net/cbaines/suma/R.java2
-rw-r--r--res/layout/building_activity.xml3
-rw-r--r--res/layout/bus_activity.xml1
-rw-r--r--res/layout/bus_stop_activity.xml1
-rw-r--r--src/net/cbaines/suma/BuildingActivity.java33
-rw-r--r--src/net/cbaines/suma/BusActivity.java20
-rw-r--r--src/net/cbaines/suma/BusSpecificStopView.java10
7 files changed, 52 insertions, 18 deletions
diff --git a/gen/net/cbaines/suma/R.java b/gen/net/cbaines/suma/R.java
index d65abc0..7e3d3f9 100644
--- a/gen/net/cbaines/suma/R.java
+++ b/gen/net/cbaines/suma/R.java
@@ -54,10 +54,10 @@ public final class R {
public static final int u9_radio_button=0x7f02001d;
}
public static final class id {
+ public static final int buildingActivityContentLayout=0x7f0a0007;
public static final int buildingActivityFavouriteCheckBox=0x7f0a0005;
public static final int buildingActivityImage=0x7f0a0006;
public static final int buildingActivityLoadBar=0x7f0a0008;
- public static final int buildingActivityLoadBarLayout=0x7f0a0007;
public static final int buildingActivityMessage=0x7f0a0009;
public static final int buildingActivityName=0x7f0a0004;
public static final int busActivityBusDestination=0x7f0a000c;
diff --git a/res/layout/building_activity.xml b/res/layout/building_activity.xml
index 777ad0a..1fc1312 100644
--- a/res/layout/building_activity.xml
+++ b/res/layout/building_activity.xml
@@ -25,7 +25,7 @@
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/buildingActivityLoadBarLayout"
+ android:id="@+id/buildingActivityContentLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
@@ -41,6 +41,7 @@
android:id="@+id/buildingActivityMessage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:gravity="center_horizontal"
android:text=""
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
diff --git a/res/layout/bus_activity.xml b/res/layout/bus_activity.xml
index d8b26f6..93ad39a 100644
--- a/res/layout/bus_activity.xml
+++ b/res/layout/bus_activity.xml
@@ -37,6 +37,7 @@
android:id="@+id/busActivityMessage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:gravity="center_horizontal"
android:text=""
android:textAppearance="?android:attr/textAppearanceLarge" />
diff --git a/res/layout/bus_stop_activity.xml b/res/layout/bus_stop_activity.xml
index 66da2f6..40b0505 100644
--- a/res/layout/bus_stop_activity.xml
+++ b/res/layout/bus_stop_activity.xml
@@ -129,6 +129,7 @@
android:id="@+id/busStopMessage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:gravity="center_horizontal"
android:text=""
android:textAppearance="?android:attr/textAppearanceLarge" />
diff --git a/src/net/cbaines/suma/BuildingActivity.java b/src/net/cbaines/suma/BuildingActivity.java
index 509bc41..b4bef1b 100644
--- a/src/net/cbaines/suma/BuildingActivity.java
+++ b/src/net/cbaines/suma/BuildingActivity.java
@@ -62,6 +62,8 @@ public class BuildingActivity extends OrmLiteBaseActivity<DatabaseHelper> implem
private CheckBox favouritesCheckBox;
+ private Drawable buildingImage;
+
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.building_activity);
@@ -90,7 +92,12 @@ public class BuildingActivity extends OrmLiteBaseActivity<DatabaseHelper> implem
buildingName = (TextView) findViewById(R.id.buildingActivityName);
progressBar = (ProgressBar) findViewById(R.id.buildingActivityLoadBar);
+ progressBar.setVisibility(View.VISIBLE);
message = (TextView) findViewById(R.id.buildingActivityMessage);
+ message.setVisibility(View.GONE);
+
+ imageButton = (ImageButton) findViewById(R.id.buildingActivityImage);
+ imageButton.setVisibility(View.GONE);
Log.i(TAG, "Building id " + ID);
@@ -105,9 +112,24 @@ public class BuildingActivity extends OrmLiteBaseActivity<DatabaseHelper> implem
e1.printStackTrace();
}
- GetBuildingImageTask buildingImageTask = new GetBuildingImageTask();
- buildingImageTask.execute(building);
+ }
+
+ protected void onResume() {
+ super.onResume();
+ buildingImage = (Drawable) getLastNonConfigurationInstance();
+ if (buildingImage == null) {
+ GetBuildingImageTask buildingImageTask = new GetBuildingImageTask();
+ buildingImageTask.execute(building);
+ } else {
+ imageButton.setImageDrawable(buildingImage);
+ imageButton.setVisibility(View.VISIBLE);
+ imageButton.setScaleType(ScaleType.CENTER_INSIDE);
+ imageButton.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View v) {
+ }
+ });
+ }
}
class GetBuildingImageTask extends AsyncTask<Building, Integer, Drawable> {
@@ -158,7 +180,7 @@ public class BuildingActivity extends OrmLiteBaseActivity<DatabaseHelper> implem
errorMessage = "MalformedURLException";
} catch (IOException e) {
e.printStackTrace();
- errorMessage = "IOException";
+ errorMessage = "No Image (Either none avalible, or a connection issue)";
}
return null;
@@ -170,8 +192,11 @@ public class BuildingActivity extends OrmLiteBaseActivity<DatabaseHelper> implem
if (image != null) {
Log.i(TAG, "Got a image for " + building + ", now displaying it");
+ buildingImage = image;
+
imageButton = (ImageButton) findViewById(R.id.buildingActivityImage);
imageButton.setImageDrawable(image);
+ imageButton.setVisibility(View.VISIBLE);
imageButton.setScaleType(ScaleType.CENTER_INSIDE);
imageButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
@@ -189,7 +214,7 @@ public class BuildingActivity extends OrmLiteBaseActivity<DatabaseHelper> implem
@Override
public Object onRetainNonConfigurationInstance() {
- return null;
+ return buildingImage;
}
public void onCheckedChanged(CompoundButton button, boolean checked) {
diff --git a/src/net/cbaines/suma/BusActivity.java b/src/net/cbaines/suma/BusActivity.java
index 834ce2f..724b65f 100644
--- a/src/net/cbaines/suma/BusActivity.java
+++ b/src/net/cbaines/suma/BusActivity.java
@@ -162,8 +162,9 @@ public class BusActivity extends ToastHelperActivity implements Preferences {
// Remove the old time from the timetable
synchronized (timetable) {
- timetable.set(num, new StopLoading(bus, busStops.get(num), null, new Date(
- System.currentTimeMillis() - 21000), false));
+ timetable.set(num,
+ new StopLoading(bus, busStops.get(num), null, new Date(
+ System.currentTimeMillis() - 21000), false));
displayTimetable(timetable);
}
@@ -282,7 +283,7 @@ public class BusActivity extends ToastHelperActivity implements Preferences {
}
private class GetTimetableStopTask extends AsyncTask<BusStop, Integer, Stop> {
- private String errorMessage;
+ // private String errorMessage;
private BusStop busStop;
@@ -305,16 +306,16 @@ public class BusActivity extends ToastHelperActivity implements Preferences {
}
Log.i(TAG, "Finished fetching stop for busStop " + position);
} catch (SQLException e) {
- errorMessage = "Error message regarding SQL?";
+ // errorMessage = "Error message regarding SQL?";
e.printStackTrace();
} catch (ClientProtocolException e) {
- errorMessage = "ClientProtocolException!?!";
+ // errorMessage = "ClientProtocolException!?!";
e.printStackTrace();
} catch (IOException e) {
- errorMessage = "Error fetching bus times from server, are you connected to the internet?";
+ // errorMessage = "Error fetching bus times from server, are you connected to the internet?";
e.printStackTrace();
} catch (JSONException e) {
- errorMessage = "Error parsing bus times";
+ // errorMessage = "Error parsing bus times";
e.printStackTrace();
}
return stop;
@@ -331,6 +332,11 @@ public class BusActivity extends ToastHelperActivity implements Preferences {
}
+ @Override
+ public Object onRetainNonConfigurationInstance() {
+ return timetable;
+ }
+
private void displayTimetable(Timetable timetable) {
visibleTimetable = (Timetable) timetable.clone();
diff --git a/src/net/cbaines/suma/BusSpecificStopView.java b/src/net/cbaines/suma/BusSpecificStopView.java
index 92ec8c7..723d7c0 100644
--- a/src/net/cbaines/suma/BusSpecificStopView.java
+++ b/src/net/cbaines/suma/BusSpecificStopView.java
@@ -101,11 +101,11 @@ public class BusSpecificStopView extends RelativeLayout implements OnClickListen
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.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());