From: Daniel Sandler Date: Thu, 3 Dec 2009 16:44:30 +0000 (-0500) Subject: Show a long dash instead of 0° if no temperature is available. (DO NOT MERGE) X-Git-Tag: android-x86-2.2~36^2^2~8 X-Git-Url: http://git.osdn.net/view?p=android-x86%2Fpackages-apps-DeskClock.git;a=commitdiff_plain;h=7e827acae69298441b970262a309a957c92da155 Show a long dash instead of 0° if no temperature is available. (DO NOT MERGE) Fixes http://b/2301604 --- diff --git a/src/com/android/deskclock/DeskClock.java b/src/com/android/deskclock/DeskClock.java index 3cfcc38..88030cd 100644 --- a/src/com/android/deskclock/DeskClock.java +++ b/src/com/android/deskclock/DeskClock.java @@ -389,21 +389,35 @@ public class DeskClock extends Activity { mWeatherIconDrawable = mGenieResources.getDrawable(cur.getInt( cur.getColumnIndexOrThrow("iconResId"))); - mWeatherCurrentTemperatureString = String.format("%d\u00b0", - (cur.getInt(cur.getColumnIndexOrThrow("temperature")))); - mWeatherHighTemperatureString = String.format("%d\u00b0", - (cur.getInt(cur.getColumnIndexOrThrow("highTemperature")))); - mWeatherLowTemperatureString = String.format("%d\u00b0", - (cur.getInt(cur.getColumnIndexOrThrow("lowTemperature")))); + mWeatherLocationString = cur.getString( cur.getColumnIndexOrThrow("location")); + + // any of these may be NULL + final int colTemp = cur.getColumnIndexOrThrow("temperature"); + final int colHigh = cur.getColumnIndexOrThrow("highTemperature"); + final int colLow = cur.getColumnIndexOrThrow("lowTemperature"); + + mWeatherCurrentTemperatureString = + cur.isNull(colTemp) + ? "\u2014" + : String.format("%d\u00b0", cur.getInt(colTemp)); + mWeatherHighTemperatureString = + cur.isNull(colHigh) + ? "\u2014" + : String.format("%d\u00b0", cur.getInt(colHigh)); + mWeatherLowTemperatureString = + cur.isNull(colLow) + ? "\u2014" + : String.format("%d\u00b0", cur.getInt(colLow)); } else { Log.w(LOG_TAG, "No weather information available (cur=" + cur +")"); mWeatherIconDrawable = null; - mWeatherHighTemperatureString = ""; - mWeatherLowTemperatureString = ""; mWeatherLocationString = getString(R.string.weather_fetch_failure); + mWeatherCurrentTemperatureString = + mWeatherHighTemperatureString = + mWeatherLowTemperatureString = ""; } mHandy.sendEmptyMessage(UPDATE_WEATHER_DISPLAY_MSG);