diff options
author | Nicolai Ehemann <en@enlightened.de> | 2013-04-22 15:14:07 +0200 |
---|---|---|
committer | Nicolai Ehemann <en@enlightened.de> | 2013-04-22 15:14:07 +0200 |
commit | 8d46b61c0e9116ffb33bc7d81bd3055ca22ea3fc (patch) | |
tree | e1a8250ce2441e161a390ae913b15f457df09314 /src/com/cyanogenmod/lockclock/ClockWidgetService.java | |
parent | e44467a35685fb3308da800a2ad34c8a993c4440 (diff) | |
download | android_packages_apps_LockClock-8d46b61c0e9116ffb33bc7d81bd3055ca22ea3fc.tar.gz android_packages_apps_LockClock-8d46b61c0e9116ffb33bc7d81bd3055ca22ea3fc.tar.bz2 android_packages_apps_LockClock-8d46b61c0e9116ffb33bc7d81bd3055ca22ea3fc.zip |
cLock: optimize widget display if parts are not visible
Change-Id: Icc49411b20f27d9ae254ce672e36cb87f2a1602e
Diffstat (limited to 'src/com/cyanogenmod/lockclock/ClockWidgetService.java')
-rwxr-xr-x | src/com/cyanogenmod/lockclock/ClockWidgetService.java | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/src/com/cyanogenmod/lockclock/ClockWidgetService.java b/src/com/cyanogenmod/lockclock/ClockWidgetService.java index 611419a..ebd7823 100755 --- a/src/com/cyanogenmod/lockclock/ClockWidgetService.java +++ b/src/com/cyanogenmod/lockclock/ClockWidgetService.java @@ -101,10 +101,10 @@ public class ClockWidgetService extends IntentService { boolean digitalClock = Preferences.showDigitalClock(this); boolean showWeather = Preferences.showWeather(this); boolean showWeatherWhenMinimized = Preferences.showWeatherWhenMinimized(this); - boolean showCalendar = false; // Update the widgets for (int id : mWidgetIds) { + boolean showCalendar = false; // Determine which layout to use boolean smallWidget = showWeather && showWeatherWhenMinimized @@ -117,23 +117,28 @@ public class ClockWidgetService extends IntentService { showCalendar = false; } else { remoteViews = new RemoteViews(getPackageName(), R.layout.appwidget); - showCalendar = Preferences.showCalendar(this) && !mHideCalendar; + // show calendar if enabled and events available and enough space available + showCalendar = Preferences.showCalendar(this) && !mHideCalendar + && WidgetUtils.canFitCalendar(this, id, digitalClock); } + // Hide the Loading indicator + remoteViews.setViewVisibility(R.id.loading_indicator, View.GONE); + // Always Refresh the Clock widget refreshClock(remoteViews, smallWidget, digitalClock); refreshAlarmStatus(remoteViews, smallWidget); - // Don't bother with Calendar if its not enabled + // Don't bother with Calendar if its not visible if (showCalendar) { refreshCalendar(remoteViews, id); } + // Hide the calendar panel if not visible + remoteViews.setViewVisibility(R.id.calendar_panel, showCalendar ? View.VISIBLE : View.GONE); - // Hide the Loading indicator - remoteViews.setViewVisibility(R.id.loading_indicator, View.GONE); - + boolean canFitWeather = smallWidget || WidgetUtils.canFitWeather(this, id, digitalClock); // Now, if we need to show the actual weather, do so - if (showWeather) { + if (showWeather && canFitWeather) { WeatherInfo weatherInfo = Preferences.getCachedWeatherInfo(this); if (weatherInfo != null) { @@ -142,6 +147,7 @@ public class ClockWidgetService extends IntentService { setNoWeatherData(remoteViews, smallWidget); } } + remoteViews.setViewVisibility(R.id.weather_panel, (showWeather && canFitWeather) ? View.VISIBLE : View.GONE); // Resize the clock font if needed if (digitalClock) { @@ -149,15 +155,6 @@ public class ClockWidgetService extends IntentService { setClockSize(remoteViews, ratio); } - if (showWeather) { - boolean canFitWeather = smallWidget || WidgetUtils.canFitWeather(this, id, digitalClock); - remoteViews.setViewVisibility(R.id.weather_panel, canFitWeather ? View.VISIBLE : View.GONE); - } - - // Hide the calendar panel if there is no space for it - boolean shouldDisplayCalendar = showCalendar && WidgetUtils.canFitCalendar(this, id, digitalClock); - remoteViews.setViewVisibility(R.id.calendar_panel, shouldDisplayCalendar ? View.VISIBLE : View.GONE); - // Do the update mAppWidgetManager.updateAppWidget(id, remoteViews); } |