From 625e2068d0c6288321d3a6be31490767eed4defe Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Tue, 6 Mar 2012 23:08:34 +0000 Subject: Small UI improvements, BusActivity still needs more work. --- gen/net/cbaines/suma/R.java | Bin 15019 -> 15019 bytes res/layout/building_activity.xml | 3 ++- res/layout/bus_activity.xml | 1 + res/layout/bus_stop_activity.xml | 1 + src/net/cbaines/suma/BuildingActivity.java | 33 ++++++++++++++++++++++---- src/net/cbaines/suma/BusActivity.java | 20 ++++++++++------ src/net/cbaines/suma/BusSpecificStopView.java | 10 ++++---- 7 files changed, 51 insertions(+), 17 deletions(-) diff --git a/gen/net/cbaines/suma/R.java b/gen/net/cbaines/suma/R.java index d65abc0..7e3d3f9 100644 Binary files a/gen/net/cbaines/suma/R.java and b/gen/net/cbaines/suma/R.java differ 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 @@ 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 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 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 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 { @@ -158,7 +180,7 @@ public class BuildingActivity extends OrmLiteBaseActivity 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 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 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 { - 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()); -- cgit v1.2.3