aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristopher Baines <cbaines8@gmail.com>2012-03-06 23:08:34 +0000
committerChristopher Baines <cbaines8@gmail.com>2012-03-06 23:08:34 +0000
commit625e2068d0c6288321d3a6be31490767eed4defe (patch)
treeff0f8466a95e1d4362ca950cc602d240bbb0194e /src
parent56c74a2fa83916915587ae2de1b46a50f2c856ee (diff)
downloadsouthamptonuniversitymap-625e2068d0c6288321d3a6be31490767eed4defe.tar
southamptonuniversitymap-625e2068d0c6288321d3a6be31490767eed4defe.tar.gz
Small UI improvements, BusActivity still needs more work.
Diffstat (limited to 'src')
-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
3 files changed, 47 insertions, 16 deletions
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());