From e28037aa89b5a7328d986f8001665ef41bf2309d Mon Sep 17 00:00:00 2001 From: DvTonder Date: Mon, 6 Jun 2016 22:20:38 -0400 Subject: Handle >5 forecast items in cLock Forecast view Change-Id: Ifd4891b990d89d1a4c535a3efb9c3db39eae7aab --- res/layout/forecast_activity.xml | 24 +++++++++++++++++----- res/layout/forecast_item.xml | 16 +++++++-------- res/values/dimens.xml | 1 + .../lockclock/weather/ForecastBuilder.java | 17 +++++++++++++-- 4 files changed, 42 insertions(+), 16 deletions(-) diff --git a/res/layout/forecast_activity.xml b/res/layout/forecast_activity.xml index 25f881c..fe71b1c 100644 --- a/res/layout/forecast_activity.xml +++ b/res/layout/forecast_activity.xml @@ -170,14 +170,28 @@ + android:layout_marginBottom="8dp" + android:layout_marginTop="8dp"> + + + + + + + xmlns:tools="http://schemas.android.com/tools" + android:orientation="vertical"> + android:padding="2dp" + android:scaleType="centerInside" + tools:ignore="ContentDescription" /> 340dp 36dp + 10dp diff --git a/src/com/cyanogenmod/lockclock/weather/ForecastBuilder.java b/src/com/cyanogenmod/lockclock/weather/ForecastBuilder.java index 4bb2b84..ed52688 100644 --- a/src/com/cyanogenmod/lockclock/weather/ForecastBuilder.java +++ b/src/com/cyanogenmod/lockclock/weather/ForecastBuilder.java @@ -186,8 +186,14 @@ public class ForecastBuilder { TimeZone MyTimezone = TimeZone.getDefault(); Calendar calendar = new GregorianCalendar(MyTimezone); int weatherTempUnit = w.getTemperatureUnit(); - // Iterate through the forecasts - for (DayForecast d : forecasts) { + int numForecasts = forecasts.size(); + int itemSidePadding = context.getResources().getDimensionPixelSize( + R.dimen.forecast_item_padding_side); + + // Iterate through the Forecasts + for (int count = 0; count < numForecasts; count ++) { + DayForecast d = forecasts.get(count); + // Load the views View forecastItem = inflater.inflate(R.layout.forecast_item, null); @@ -230,6 +236,13 @@ public class ForecastBuilder { // Add the view smallPanel.addView(forecastItem, new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, 1)); + + // Add a divider to the right for all but the last view + if (count < numForecasts - 1) { + View divider = new View(context); + smallPanel.addView(divider, new LinearLayout.LayoutParams( + itemSidePadding, LinearLayout.LayoutParams.MATCH_PARENT)); + } } return true; } -- cgit v1.2.3