tools:context="de.example.exampletdd.WeatherInformationCurrentDataActivity"
tools:ignore="MergeRootFrame" >
- <ImageView
- android:id="@+id/weather_current_picture"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:contentDescription="@string/icon_weather_description"
- android:scaleType="fitCenter"
- android:src="@drawable/ic_launcher" />
-
<fragment
android:id="@+id/weather_current_data_fragment"
android:layout_width="match_parent"
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:gravity="center"
+ android:layout_gravity="center"
+ android:orientation="vertical" >
+
+ <LinearLayout
+ android:baselineAligned="false"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_gravity="center_horizontal"
+ android:orientation="horizontal" >
+
+ <LinearLayout
+ android:layout_width="0dp"
+ android:layout_weight="1"
+ android:layout_height="wrap_content"
+ android:gravity="center"
+ android:layout_gravity="center"
+ android:orientation="vertical" >
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:gravity="center_horizontal"
+ android:orientation="horizontal" >
+ <!-- Feels like temperature -->
+ <TextView
+ android:id="@+id/weather_current_now_data_feelslike"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="FEELS LIKE"
+ android:layout_gravity="left"
+ android:gravity="left"
+ android:textAlignment="textStart"
+ android:textColor="@color/weather_time_of_day_color_title"
+ android:layout_margin="5dp"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:textStyle="bold" />
+
+ <!-- Feels like temperature Value-->
+ <TextView
+ android:id="@+id/weather_current_now_data_feelslike_value"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="55"
+ android:layout_gravity="left"
+ android:gravity="left"
+ android:textAlignment="textStart"
+ android:layout_marginTop="5dp"
+ android:layout_marginBottom="5dp"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:textStyle="normal" />
+
+ <!-- Feels like temperature Units-->
+ <TextView
+ android:id="@+id/weather_current_now_data_feelslike_units"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text=" ºC"
+ android:layout_gravity="left"
+ android:gravity="left"
+ android:textAlignment="textStart"
+ android:layout_marginTop="5dp"
+ android:layout_marginBottom="5dp"
+ android:layout_marginRight="5dp"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:textStyle="bold" />
+
+ </LinearLayout>
+
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
+ android:orientation="horizontal" >
+ <!-- Humidity -->
+
+ <TextView
+ android:id="@+id/weather_current_now_data_humidity"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="left"
+ android:layout_margin="5dp"
+ android:gravity="left"
+ android:text="HUMIDITY"
+ android:textAlignment="textStart"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:textColor="@color/weather_time_of_day_color_title"
+ android:textStyle="bold" />
+
+ <!-- Humidity Value-->
+ <TextView
+ android:id="@+id/weather_current_now_data_humidity_value"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="83"
+ android:layout_gravity="left"
+ android:gravity="left"
+ android:textAlignment="textStart"
+ android:layout_marginTop="5dp"
+ android:layout_marginBottom="5dp"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:textStyle="normal" />
+
+ <!-- Humidity Units-->
+ <TextView
+ android:id="@+id/weather_current_now_data_humidity_units"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="%"
+ android:layout_gravity="left"
+ android:gravity="left"
+ android:textAlignment="textStart"
+ android:layout_marginTop="5dp"
+ android:layout_marginBottom="5dp"
+ android:layout_marginRight="5dp"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:textStyle="bold" />
+ </LinearLayout>
+
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
+ android:orientation="horizontal" >
+ <!-- Rain -->
+ <TextView
+ android:id="@+id/weather_current_now_data_rain"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="RAIN"
+ android:layout_gravity="left"
+ android:gravity="left"
+ android:textAlignment="textStart"
+ android:textColor="@color/weather_time_of_day_color_title"
+ android:layout_margin="5dp"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:textStyle="bold" />
+
+ <!-- Rain Value-->
+ <TextView
+ android:id="@+id/weather_current_now_data_rain_value"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="1.24"
+ android:layout_gravity="left"
+ android:gravity="left"
+ android:layout_marginTop="5dp"
+ android:layout_marginBottom="5dp"
+ android:textAlignment="textStart"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:textStyle="normal" />
+
+ <!-- Rain Units -->
+ <TextView
+ android:id="@+id/weather_current_now_data_rain_units"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text=" mm 3h"
+ android:layout_gravity="left"
+ android:gravity="left"
+ android:layout_marginTop="5dp"
+ android:layout_marginBottom="5dp"
+ android:layout_marginRight="5dp"
+ android:textAlignment="textStart"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:textStyle="bold" />
+ </LinearLayout>
+
+ </LinearLayout>
+
+ <LinearLayout
+ android:layout_width="0dp"
+ android:layout_weight="1"
+ android:layout_height="wrap_content"
+ android:gravity="center"
+ android:layout_gravity="center"
+ android:orientation="vertical" >
+
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:orientation="horizontal" >
+ <!-- Snow -->
+ <TextView
+ android:id="@+id/weather_current_now_data_snow"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="SNOW"
+ android:layout_gravity="right"
+ android:gravity="right"
+ android:textAlignment="textStart"
+ android:textColor="@color/weather_time_of_day_color_title"
+ android:layout_margin="5dp"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:textStyle="bold" />
+
+ <!-- Snow Value-->
+ <TextView
+ android:id="@+id/weather_current_now_data_snow_value"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="1.22"
+ android:layout_gravity="right"
+ android:gravity="right"
+ android:textAlignment="textStart"
+ android:layout_marginTop="5dp"
+ android:layout_marginBottom="5dp"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:textStyle="normal" />
+
+ <!-- Snow Units-->
+ <TextView
+ android:id="@+id/weather_current_now_data_snow_units"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text=" mm 3h"
+ android:layout_gravity="right"
+ android:gravity="right"
+ android:textAlignment="textStart"
+ android:layout_marginTop="5dp"
+ android:layout_marginBottom="5dp"
+ android:layout_marginRight="5dp"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:textStyle="bold" />
+
+ </LinearLayout>
+
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
+ android:orientation="horizontal" >
+ <!-- Wind -->
+ <TextView
+ android:id="@+id/weather_current_now_data_wind"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="WIND"
+ android:layout_gravity="right"
+ android:gravity="right"
+ android:textAlignment="textStart"
+ android:textColor="@color/weather_time_of_day_color_title"
+ android:layout_margin="5dp"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:textStyle="bold" />
+
+ <!-- Wind Value-->
+ <TextView
+ android:id="@+id/weather_current_now_data_wind_value"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="6.36"
+ android:layout_gravity="right"
+ android:gravity="right"
+ android:textAlignment="textStart"
+ android:layout_marginTop="5dp"
+ android:layout_marginBottom="5dp"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:textStyle="normal" />
+
+ <!-- Wind Units -->
+ <TextView
+ android:id="@+id/weather_current_now_data_wind_units"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text=" m/s"
+ android:layout_gravity="right"
+ android:gravity="right"
+ android:textAlignment="textStart"
+ android:layout_marginTop="5dp"
+ android:layout_marginBottom="5dp"
+ android:layout_marginRight="5dp"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:textStyle="bold" />
+ </LinearLayout>
+
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
+ android:orientation="horizontal" >
+ <!-- Clouds -->
+ <TextView
+ android:id="@+id/weather_current_now_data_clouds"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="CLOUDS"
+ android:layout_gravity="right"
+ android:gravity="right"
+ android:textAlignment="textStart"
+ android:textColor="@color/weather_time_of_day_color_title"
+ android:layout_margin="5dp"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:textStyle="bold" />
+
+ <!-- Clouds Value-->
+ <TextView
+ android:id="@+id/weather_current_now_data_clouds_value"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="6.36"
+ android:layout_gravity="right"
+ android:layout_marginTop="5dp"
+ android:layout_marginBottom="5dp"
+ android:gravity="right"
+ android:textAlignment="textStart"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:textStyle="normal" />
+
+
+ <!-- Clouds Units -->
+ <TextView
+ android:id="@+id/weather_current_now_data_clouds_units"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="%"
+ android:layout_gravity="right"
+ android:gravity="right"
+ android:textAlignment="textStart"
+ android:layout_marginTop="5dp"
+ android:layout_marginBottom="5dp"
+ android:layout_marginRight="5dp"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:textStyle="bold" />
+ </LinearLayout>
+ </LinearLayout>
+
+ </LinearLayout>
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:gravity="center_horizontal"
+ android:orientation="horizontal" >
+
+ <!-- Pressure -->
+ <TextView
+ android:id="@+id/weather_current_now_data_pressure"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="PRESSURE"
+ android:layout_gravity="left"
+ android:gravity="left"
+ android:textAlignment="textStart"
+ android:textColor="@color/weather_time_of_day_color_title"
+ android:layout_margin="5dp"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:textStyle="bold" />
+
+ <!-- Pressure Value-->
+ <TextView
+ android:id="@+id/weather_current_now_data_pressure_value"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="1036.05"
+ android:layout_gravity="left"
+ android:gravity="left"
+ android:textAlignment="textStart"
+ android:layout_marginTop="5dp"
+ android:layout_marginBottom="5dp"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:textStyle="normal" />
+
+ <!-- Pressure Units-->
+ <TextView
+ android:id="@+id/weather_current_now_data_pressure_units"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text=" hpa"
+ android:layout_gravity="left"
+ android:gravity="left"
+ android:textAlignment="textStart"
+ android:layout_marginTop="5dp"
+ android:layout_marginBottom="5dp"
+ android:layout_marginRight="5dp"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:textStyle="bold" />
+
+ </LinearLayout>
+
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:gravity="center"
+ android:layout_gravity="center"
+ android:orientation="horizontal" >
+ <TextView
+ android:id="@+id/weather_current_now_data_sunrise"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="left"
+ android:gravity="left"
+ android:textAlignment="textStart"
+ android:layout_margin="5dp"
+ android:text="SUN RISE"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:textColor="@color/weather_time_of_day_color_title"
+ android:textStyle="bold" />
+
+ <TextView
+ android:id="@+id/weather_current_now_data_sunrise_value"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="left"
+ android:gravity="left"
+ android:textAlignment="textStart"
+ android:layout_marginTop="5dp"
+ android:layout_marginBottom="5dp"
+ android:text="2014.04.20 10:29:33"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:textStyle="normal" />
+
+ </LinearLayout>
+
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:gravity="center"
+ android:layout_gravity="center"
+ android:orientation="horizontal" >
+
+ <TextView
+ android:id="@+id/weather_current_now_data_sunset"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="right"
+ android:gravity="right"
+ android:textAlignment="textStart"
+ android:layout_margin="5dp"
+ android:text="SUN SET"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:textColor="@color/weather_time_of_day_color_title"
+ android:textStyle="bold" />
+
+ <TextView
+ android:id="@+id/weather_current_now_data_sunset_value"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="right"
+ android:gravity="right"
+ android:textAlignment="textStart"
+ android:layout_marginTop="5dp"
+ android:layout_marginBottom="5dp"
+ android:text="2014.04.20 10:29:33"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:textStyle="normal" />
+ </LinearLayout>
+
+</LinearLayout>
android:layout_height="wrap_content"
android:orientation="vertical">
- <!-- Thermometer -->
- <ImageView
- android:id="@+id/thermometer_morn"
- android:layout_width="wrap_content"
- android:layout_height="fill_parent"
- android:layout_below="@+id/weather_morn"
- android:layout_alignParentLeft="true"
- android:orientation="vertical"
- android:contentDescription="Image"
- android:src="@drawable/thermometer"
- android:background="?android:attr/activatedBackgroundIndicator"/>
-
<!-- Temperature -->
<TextView
android:id="@+id/weather_morn_temperature"
android:textAlignment="center"
android:gravity="center|center_vertical"
android:layout_below="@+id/weather_morn"
- android:layout_toRightOf="@id/thermometer_morn"
- android:layout_alignTop="@id/thermometer_morn"
+ android:layout_centerInParent="true"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold" />
android:textAlignment="center"
android:gravity="center"
android:layout_alignParentTop="true"
+ android:layout_centerInParent="true"
android:textAppearance="?android:attr/textAppearanceMedium" />
</RelativeLayout>
android:layout_height="wrap_content"
android:orientation="vertical">
- <!-- Thermometer -->
- <ImageView
- android:id="@+id/thermometer_day"
- android:layout_width="wrap_content"
- android:layout_height="fill_parent"
- android:layout_below="@+id/weather_day"
- android:layout_alignParentLeft="true"
- android:orientation="vertical"
- android:contentDescription="Image"
- android:src="@drawable/thermometer"
- android:background="?android:attr/activatedBackgroundIndicator"/>
<!-- Temperature -->
<TextView
android:textAlignment="center"
android:gravity="center|center_vertical"
android:layout_below="@+id/weather_day"
- android:layout_toRightOf="@id/thermometer_day"
- android:layout_alignTop="@id/thermometer_day"
+ android:layout_centerInParent="true"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold" />
android:layout_width="140dp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
+ android:layout_centerInParent="true"
android:gravity="center"
android:selectAllOnFocus="true"
android:text="DAY"
android:layout_height="wrap_content"
android:orientation="vertical">
- <!-- Thermometer -->
- <ImageView
- android:id="@+id/thermometer_eve"
- android:layout_width="wrap_content"
- android:layout_height="fill_parent"
- android:layout_below="@+id/weather_eve"
- android:layout_alignParentLeft="true"
- android:orientation="vertical"
- android:contentDescription="Image"
- android:src="@drawable/thermometer"
- android:background="?android:attr/activatedBackgroundIndicator"/>
+
<!-- Temperature -->
<TextView
android:textAlignment="center"
android:gravity="center|center_vertical"
android:layout_below="@+id/weather_eve"
- android:layout_toRightOf="@id/thermometer_eve"
- android:layout_alignTop="@id/thermometer_eve"
+ android:layout_centerInParent="true"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold" />
android:text="EVENING"
android:textColor="@color/weather_time_of_day_color_title"
android:textAlignment="center"
+ android:layout_centerInParent="true"
android:gravity="center"
android:layout_alignParentTop="true"
android:textAppearance="?android:attr/textAppearanceMedium" />
android:layout_height="wrap_content"
android:orientation="vertical">
- <!-- Thermometer -->
- <ImageView
- android:id="@+id/thermometer_night"
- android:layout_width="wrap_content"
- android:layout_height="fill_parent"
- android:layout_below="@+id/weather_night"
- android:layout_alignParentLeft="true"
- android:orientation="vertical"
- android:contentDescription="Image"
- android:src="@drawable/thermometer"
- android:background="?android:attr/activatedBackgroundIndicator"/>
<!-- Temperature -->
<TextView
android:textAlignment="center"
android:gravity="center|center_vertical"
android:layout_below="@+id/weather_night"
- android:layout_toRightOf="@id/thermometer_night"
- android:layout_alignTop="@id/thermometer_night"
+ android:layout_centerInParent="true"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold" />
android:textAlignment="center"
android:gravity="center"
android:layout_alignParentTop="true"
+ android:layout_centerInParent="true"
android:textAppearance="?android:attr/textAppearanceMedium" />
</RelativeLayout>
android:layout_gravity="center"
android:orientation="vertical" >
- <RelativeLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:padding="20dp"
- android:orientation="vertical" >
+ <LinearLayout
+ android:baselineAligned="false"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_gravity="center_horizontal"
+ android:paddingTop="20dp"
+ android:orientation="horizontal" >
+
+ <LinearLayout
+ android:layout_width="0dp"
+ android:layout_weight="1"
+ android:layout_height="wrap_content"
+ android:gravity="center"
+ android:layout_gravity="center"
+ android:orientation="vertical" >
+
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
+ android:orientation="horizontal" >
+ <!-- Humidity -->
- <!-- Humidity -->
<TextView
android:id="@+id/weather_current_data_humidity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:text="HUMIDITY"
android:layout_gravity="left"
- android:gravity="left"
- android:layout_alignParentLeft="true"
- android:textAlignment="center"
- android:textColor="@color/weather_time_of_day_color_title"
android:layout_margin="5dp"
+ android:gravity="left"
+ android:text="HUMIDITY"
+ android:textAlignment="textStart"
android:textAppearance="?android:attr/textAppearanceMedium"
+ android:textColor="@color/weather_time_of_day_color_title"
android:textStyle="bold" />
<!-- Humidity Value-->
android:text="83"
android:layout_gravity="left"
android:gravity="left"
- android:layout_toRightOf="@+id/weather_current_data_humidity"
- android:textAlignment="center"
+ android:textAlignment="textStart"
android:layout_marginTop="5dp"
+ android:layout_marginBottom="5dp"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textStyle="normal" />
android:text="%"
android:layout_gravity="left"
android:gravity="left"
- android:textAlignment="center"
- android:layout_toRightOf="@+id/weather_current_data_humidity_value"
- android:paddingTop="5dp"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textStyle="bold" />
-
- <!-- Wind -->
- <TextView
- android:id="@+id/weather_current_data_wind"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="WIND"
- android:layout_gravity="right"
- android:gravity="right"
- android:layout_alignParentRight="true"
- android:textAlignment="center"
- android:textColor="@color/weather_time_of_day_color_title"
- android:layout_margin="5dp"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textStyle="bold" />
-
- <!-- Wind Units -->
- <TextView
- android:id="@+id/weather_current_data_wind_units"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text=" m/s"
- android:layout_gravity="right"
- android:gravity="right"
- android:layout_toLeftOf="@+id/weather_current_data_wind"
- android:textAlignment="center"
+ android:textAlignment="textStart"
android:layout_marginTop="5dp"
+ android:layout_marginBottom="5dp"
+ android:layout_marginRight="5dp"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textStyle="bold" />
-
- <!-- Wind Value-->
- <TextView
- android:id="@+id/weather_current_data_wind_value"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="6.36"
- android:layout_gravity="right"
- android:gravity="right"
- android:layout_toLeftOf="@+id/weather_current_data_wind_units"
- android:textAlignment="center"
- android:layout_marginTop="5dp"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textStyle="normal" />
-
-
-
- </RelativeLayout>
-
-
- <RelativeLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:padding="20dp"
- android:orientation="vertical" >
-
- <!-- Rain -->
+ </LinearLayout>
+
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
+ android:orientation="horizontal" >
+ <!-- Rain -->
<TextView
android:id="@+id/weather_current_data_rain"
android:layout_width="wrap_content"
android:text="RAIN"
android:layout_gravity="left"
android:gravity="left"
- android:layout_alignParentLeft="true"
- android:textAlignment="center"
+ android:textAlignment="textStart"
android:textColor="@color/weather_time_of_day_color_title"
- android:paddingTop="20dp"
- android:paddingBottom="20dp"
android:layout_margin="5dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold" />
android:text="1.24"
android:layout_gravity="left"
android:gravity="left"
- android:textAlignment="center"
- android:layout_toRightOf="@+id/weather_current_data_rain"
- android:paddingTop="20dp"
- android:paddingBottom="20dp"
android:layout_marginTop="5dp"
+ android:layout_marginBottom="5dp"
+ android:textAlignment="textStart"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textStyle="normal" />
android:text=" mm 3h"
android:layout_gravity="left"
android:gravity="left"
- android:textAlignment="center"
- android:layout_toRightOf="@+id/weather_current_data_rain_value"
- android:paddingTop="20dp"
- android:paddingRight="20dp"
- android:paddingBottom="20dp"
android:layout_marginTop="5dp"
+ android:layout_marginBottom="5dp"
+ android:layout_marginRight="5dp"
+ android:textAlignment="textStart"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textStyle="bold" />
-
-
- <!-- Clouds -->
+ </LinearLayout>
+
+ </LinearLayout>
+
+ <LinearLayout
+ android:layout_width="0dp"
+ android:layout_weight="1"
+ android:layout_height="wrap_content"
+ android:gravity="center"
+ android:layout_gravity="center"
+ android:orientation="vertical" >
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
+ android:orientation="horizontal" >
+ <!-- Wind -->
<TextView
- android:id="@+id/weather_current_data_clouds"
+ android:id="@+id/weather_current_data_wind"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:text="CLOUDS"
+ android:text="WIND"
android:layout_gravity="right"
android:gravity="right"
- android:layout_alignParentRight="true"
- android:textAlignment="center"
+ android:textAlignment="textStart"
android:textColor="@color/weather_time_of_day_color_title"
- android:paddingTop="20dp"
- android:paddingBottom="20dp"
android:layout_margin="5dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold" />
- <!-- Clouds Units -->
+ <!-- Wind Value-->
<TextView
- android:id="@+id/weather_current_data_clouds_units"
+ android:id="@+id/weather_current_data_wind_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:text="%"
+ android:text="6.36"
+ android:layout_gravity="right"
+ android:gravity="right"
+ android:textAlignment="textStart"
+ android:layout_marginTop="5dp"
+ android:layout_marginBottom="5dp"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:textStyle="normal" />
+
+ <!-- Wind Units -->
+ <TextView
+ android:id="@+id/weather_current_data_wind_units"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text=" m/s"
android:layout_gravity="right"
android:gravity="right"
- android:layout_toLeftOf="@+id/weather_current_data_clouds"
- android:textAlignment="center"
- android:paddingTop="20dp"
- android:paddingBottom="20dp"
+ android:textAlignment="textStart"
android:layout_marginTop="5dp"
+ android:layout_marginBottom="5dp"
+ android:layout_marginRight="5dp"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textStyle="bold" />
+ </LinearLayout>
+
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
+ android:orientation="horizontal" >
+ <!-- Clouds -->
+ <TextView
+ android:id="@+id/weather_current_data_clouds"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="CLOUDS"
+ android:layout_gravity="right"
+ android:gravity="right"
+ android:textAlignment="textStart"
+ android:textColor="@color/weather_time_of_day_color_title"
+ android:layout_margin="5dp"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:textStyle="bold" />
<!-- Clouds Value-->
<TextView
android:layout_height="wrap_content"
android:text="6.36"
android:layout_gravity="right"
- android:gravity="right"
- android:layout_toLeftOf="@+id/weather_current_data_clouds_units"
- android:textAlignment="center"
- android:paddingTop="20dp"
- android:paddingBottom="20dp"
android:layout_marginTop="5dp"
+ android:layout_marginBottom="5dp"
+ android:gravity="right"
+ android:textAlignment="textStart"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textStyle="normal" />
- </RelativeLayout>
+
+ <!-- Clouds Units -->
+ <TextView
+ android:id="@+id/weather_current_data_clouds_units"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="%"
+ android:layout_gravity="right"
+ android:gravity="right"
+ android:textAlignment="textStart"
+ android:layout_marginTop="5dp"
+ android:layout_marginBottom="5dp"
+ android:layout_marginRight="5dp"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:textStyle="bold" />
+ </LinearLayout>
+ </LinearLayout>
+ </LinearLayout>
+
<LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:gravity="center"
- android:layout_gravity="center"
- android:orientation="horizontal" >
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:gravity="center_horizontal"
+ android:paddingBottom="20dp"
+ android:orientation="horizontal" >
<!-- Pressure -->
<TextView
android:text="PRESSURE"
android:layout_gravity="left"
android:gravity="left"
- android:textAlignment="center"
+ android:textAlignment="textStart"
android:textColor="@color/weather_time_of_day_color_title"
- android:paddingTop="20dp"
- android:paddingLeft="20dp"
- android:paddingBottom="20dp"
android:layout_margin="5dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold" />
android:text="1036.05"
android:layout_gravity="left"
android:gravity="left"
- android:textAlignment="center"
- android:paddingTop="20dp"
- android:paddingBottom="20dp"
+ android:textAlignment="textStart"
android:layout_marginTop="5dp"
+ android:layout_marginBottom="5dp"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textStyle="normal" />
android:text=" hpa"
android:layout_gravity="left"
android:gravity="left"
- android:textAlignment="center"
- android:paddingTop="20dp"
- android:paddingRight="20dp"
- android:paddingBottom="20dp"
+ android:textAlignment="textStart"
android:layout_marginTop="5dp"
+ android:layout_marginBottom="5dp"
+ android:layout_marginRight="5dp"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textStyle="bold" />
--- /dev/null
+package de.example.exampletdd.fragment.current;
+
+import android.content.Context;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+import android.widget.ImageView;
+import android.widget.TextView;
+import de.example.exampletdd.R;
+
+public class WeatherCurrentDataAdapter extends ArrayAdapter<Object> {
+ private static final int FIRST = 0;
+ private static final int SECOND = 1;
+ private static final int THIRD = 2;
+ private final int[] resources;
+
+ public WeatherCurrentDataAdapter(final Context context, final int[] resources) {
+ super(context, 0);
+
+ this.resources = resources;
+ }
+
+
+ @Override
+ public View getView(final int position, final View convertView, final ViewGroup parent) {
+
+ final View view = this.getWorkingView(position, convertView);
+ final int viewType = this.getItemViewType(position);
+
+ if (viewType == FIRST) {
+
+ final ViewFirstHolder viewHolder = this.getViewFirstHolder(view);
+ final WeatherCurrentDataEntryFirst entry = (WeatherCurrentDataEntryFirst) this
+ .getItem(position);
+ viewHolder.picture.setImageBitmap(entry.getPicture());
+ viewHolder.tempMax.setText(entry.getTempMax());
+ viewHolder.tempMin.setText(entry.getTempMin());
+ } else if (viewType == SECOND) {
+ final ViewSecondHolder viewHolder = this.getViewSecondHolder(view);
+ final WeatherCurrentDataEntrySecond entry = (WeatherCurrentDataEntrySecond) this
+ .getItem(position);
+ viewHolder.weatherDescription.setText(entry.getWeatherDescription());
+ } else if (viewType == THIRD) {
+ final ViewThirdHolder viewHolder = this.getViewThirdHolder(view);
+ final WeatherCurrentDataEntryFifth entry = (WeatherCurrentDataEntryFifth) this
+ .getItem(position);
+ viewHolder.humidityValue.setText(entry.getHumidityValue());
+ viewHolder.pressureValue.setText(entry.getPressureValue());
+ viewHolder.rainValue.setText(entry.getRainValue());
+ viewHolder.cloudsValue.setText(entry.getCloudsValue());
+ viewHolder.windValue.setText(entry.getWindValue());
+ viewHolder.sunRiseTime.setText(entry.getSunRiseTime());
+ viewHolder.sunSetTime.setText(entry.getSunSetTime());
+ viewHolder.feelsLike.setText(entry.getFeelsLike());
+ viewHolder.snowValue.setText(entry.getSnowValue());
+ viewHolder.feelsLikeUnits.setText(entry.getFeelsLikeUnits());
+ }
+
+ return view;
+ }
+
+ @Override
+ public int getItemViewType(final int position) {
+ int type = 0;
+
+ if (position == 0) {
+ type = FIRST;
+ } else if (position == 1) {
+ type = SECOND;
+ } else if (position == 2) {
+ type = THIRD;
+ }
+
+ return type;
+ }
+
+ @Override
+ public int getViewTypeCount() {
+ return 3;
+ }
+
+ private View getWorkingView(final int position, final View convertView) {
+ View workingView = null;
+
+ if (convertView == null) {
+ final int viewType = this.getItemViewType(position);
+ final Context context = this.getContext();
+ final LayoutInflater inflater = (LayoutInflater) context
+ .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+
+ workingView = inflater.inflate(this.resources[viewType], null);
+ } else {
+ workingView = convertView;
+ }
+
+ return workingView;
+ }
+
+ private ViewFirstHolder getViewFirstHolder(final View workingView) {
+ final Object tag = workingView.getTag();
+ ViewFirstHolder viewHolder = null;
+
+ if ((null == tag) || !(tag instanceof ViewFirstHolder)) {
+ viewHolder = new ViewFirstHolder();
+
+ viewHolder.picture = (ImageView) workingView
+ .findViewById(R.id.weather_current_data_picture);
+ viewHolder.tempMax = (TextView) workingView
+ .findViewById(R.id.weather_current_data_temp_max);
+ viewHolder.tempMin = (TextView) workingView
+ .findViewById(R.id.weather_current_data_temp_min);
+
+ workingView.setTag(viewHolder);
+
+ } else {
+ viewHolder = (ViewFirstHolder) tag;
+ }
+
+ return viewHolder;
+ }
+
+ private ViewSecondHolder getViewSecondHolder(final View workingView) {
+ final Object tag = workingView.getTag();
+ ViewSecondHolder viewHolder = null;
+
+ if ((null == tag) || !(tag instanceof ViewSecondHolder)) {
+ viewHolder = new ViewSecondHolder();
+
+ viewHolder.weatherDescription = (TextView) workingView
+ .findViewById(R.id.weather_current_data_description);
+
+ workingView.setTag(viewHolder);
+
+ } else {
+ viewHolder = (ViewSecondHolder) tag;
+ }
+
+ return viewHolder;
+ }
+
+ private ViewThirdHolder getViewThirdHolder(final View workingView) {
+ final Object tag = workingView.getTag();
+ ViewThirdHolder viewHolder = null;
+
+ if ((null == tag) || !(tag instanceof ViewThirdHolder)) {
+ viewHolder = new ViewThirdHolder();
+
+ viewHolder.humidityValue = (TextView) workingView
+ .findViewById(R.id.weather_current_now_data_humidity_value);
+ viewHolder.pressureValue = (TextView) workingView
+ .findViewById(R.id.weather_current_now_data_pressure_value);
+ viewHolder.rainValue = (TextView) workingView
+ .findViewById(R.id.weather_current_now_data_rain_value);
+ viewHolder.cloudsValue = (TextView) workingView
+ .findViewById(R.id.weather_current_now_data_clouds_value);
+ viewHolder.windValue = (TextView) workingView
+ .findViewById(R.id.weather_current_now_data_wind_value);
+ viewHolder.cloudsValue = (TextView) workingView
+ .findViewById(R.id.weather_current_now_data_clouds_value);
+ viewHolder.snowValue = (TextView) workingView
+ .findViewById(R.id.weather_current_now_data_snow_value);
+ viewHolder.sunRiseTime = (TextView) workingView
+ .findViewById(R.id.weather_current_now_data_sunrise_value);
+ viewHolder.sunSetTime = (TextView) workingView
+ .findViewById(R.id.weather_current_now_data_sunset_value);
+ viewHolder.feelsLike = (TextView) workingView
+ .findViewById(R.id.weather_current_now_data_feelslike_value);
+ viewHolder.feelsLikeUnits = (TextView) workingView
+ .findViewById(R.id.weather_current_now_data_feelslike_units);
+
+ workingView.setTag(viewHolder);
+
+ } else {
+ viewHolder = (ViewThirdHolder) tag;
+ }
+
+ return viewHolder;
+ }
+
+
+ private static class ViewFirstHolder {
+ public ImageView picture;
+ public TextView tempMax;
+ public TextView tempMin;
+ }
+
+ private static class ViewSecondHolder {
+ public TextView weatherDescription;
+ }
+
+ private static class ViewThirdHolder {
+ public TextView humidityValue;
+ public TextView pressureValue;
+ public TextView windValue;
+ public TextView rainValue;
+ public TextView cloudsValue;
+ public TextView snowValue;
+ public TextView sunRiseTime;
+ public TextView sunSetTime;
+ public TextView feelsLike;
+ public TextView feelsLikeUnits;
+ }
+}
--- /dev/null
+package de.example.exampletdd.fragment.current;
+
+public class WeatherCurrentDataEntryFifth {
+ private final String sunRiseTime;
+ private final String sunSetTime;
+ private final String humidityValue;
+ private final String pressureValue;
+ private final String windValue;
+ private final String rainValue;
+ private final String cloudsValue;
+ private final String feelsLike;
+ private final String feelsLikeUnits;
+ private final String snowValue;
+
+ public WeatherCurrentDataEntryFifth(final String sunRiseTime, final String sunSetTime,
+ final String humidityValue, final String pressureValue, final String windValue,
+ final String rainValue, final String feelsLike, final String feelsLikeUnits,
+ final String snowValue,
+ final String cloudsValue) {
+ this.sunRiseTime = sunRiseTime;
+ this.sunSetTime = sunSetTime;
+ this.humidityValue = humidityValue;
+ this.pressureValue = pressureValue;
+ this.windValue = windValue;
+ this.rainValue = rainValue;
+ this.feelsLike = feelsLike;
+ this.feelsLikeUnits = feelsLikeUnits;
+ this.snowValue = snowValue;
+ this.cloudsValue = cloudsValue;
+ }
+
+ public String getSunRiseTime() {
+ return this.sunRiseTime;
+ }
+
+ public String getSunSetTime() {
+ return this.sunSetTime;
+ }
+
+ public String getFeelsLike() {
+ return this.feelsLike;
+ }
+
+ public String getFeelsLikeUnits() {
+ return this.feelsLikeUnits;
+ }
+
+ public String getHumidityValue() {
+ return this.humidityValue;
+ }
+
+ public String getPressureValue() {
+ return this.pressureValue;
+ }
+
+ public String getWindValue() {
+ return this.windValue;
+ }
+
+ public String getRainValue() {
+ return this.rainValue;
+ }
+
+ public String getCloudsValue() {
+ return this.cloudsValue;
+ }
+
+ public String getSnowValue() {
+ return this.snowValue;
+ }
+}
--- /dev/null
+package de.example.exampletdd.fragment.current;
+
+import android.graphics.Bitmap;
+
+public class WeatherCurrentDataEntryFirst {
+ private final Bitmap picture;
+ private final String tempMax;
+ private final String tempMin;
+
+ public WeatherCurrentDataEntryFirst(final String tempMax, final String tempMin,
+ final Bitmap picture) {
+ this.tempMax = tempMax;
+ this.tempMin = tempMin;
+ this.picture = picture;
+ }
+
+ public Bitmap getPicture() {
+ return this.picture;
+ }
+
+ public String getTempMax() {
+ return this.tempMax;
+ }
+
+ public String getTempMin() {
+ return this.tempMin;
+ }
+}
--- /dev/null
+package de.example.exampletdd.fragment.current;
+
+public class WeatherCurrentDataEntrySecond {
+ private final String weatherDescription;
+
+ public WeatherCurrentDataEntrySecond(final String weatherDescription) {
+ this.weatherDescription = weatherDescription;
+ }
+
+ public String getWeatherDescription() {
+ return this.weatherDescription;
+ }
+
+}
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
-import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
-import java.util.List;
import java.util.Locale;
import org.apache.http.client.ClientProtocolException;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.util.Log;
-import android.widget.ImageView;
import android.widget.ListView;
import com.fasterxml.jackson.core.JsonParseException;
import de.example.exampletdd.R;
import de.example.exampletdd.fragment.ErrorDialogFragment;
import de.example.exampletdd.fragment.ProgressDialogFragment;
-import de.example.exampletdd.fragment.specific.WeatherSpecificDataAdapter;
-import de.example.exampletdd.fragment.specific.WeatherSpecificDataEntry;
+import de.example.exampletdd.fragment.overview.IconsList;
import de.example.exampletdd.httpclient.CustomHTTPClient;
import de.example.exampletdd.model.GeocodingData;
import de.example.exampletdd.model.currentweather.CurrentWeatherData;
Locale.getDefault());
final double tempUnits = this.mIsFahrenheit ? 0 : 273.15;
+ final String symbol = this.mIsFahrenheit ? "ºF" : "ºC";
- final List<WeatherSpecificDataEntry> entries = this.createEmptyEntriesList();
+ final int[] layouts = new int[3];
+ layouts[0] = R.layout.weather_current_data_entry_first;
+ layouts[1] = R.layout.weather_current_data_entry_second;
+ layouts[2] = R.layout.weather_current_data_entry_fifth;
+ final WeatherCurrentDataAdapter adapter = new WeatherCurrentDataAdapter(this.getActivity(),
+ layouts);
- final WeatherSpecificDataAdapter adapter = new WeatherSpecificDataAdapter(
- this.getActivity(), R.layout.weather_data_entry_list);
-
- if (currentWeatherData.getWeather().size() > 0) {
- entries.set(0,
- new WeatherSpecificDataEntry(this.getString(R.string.text_field_description),
- currentWeatherData.getWeather().get(0).getDescription()));
- }
-
- if (currentWeatherData.getMain().getTemp() != null) {
- double conversion = (Double) currentWeatherData.getMain().getTemp();
- conversion = conversion - tempUnits;
- entries.set(1, new WeatherSpecificDataEntry(this.getString(R.string.text_field_tem),
- tempFormatter.format(conversion)));
- }
+ String tempMax = "";
if (currentWeatherData.getMain().getTemp_max() != null) {
double conversion = (Double) currentWeatherData.getMain().getTemp_max();
conversion = conversion - tempUnits;
- entries.set(2, new WeatherSpecificDataEntry(
- this.getString(R.string.text_field_tem_max), tempFormatter.format(conversion)));
+ tempMax = tempFormatter.format(conversion) + symbol;
}
-
- if (currentWeatherData.getMain().getTemp_max() != null) {
+ String tempMin = "";
+ if (currentWeatherData.getMain().getTemp_min() != null) {
double conversion = (Double) currentWeatherData.getMain().getTemp_min();
conversion = conversion - tempUnits;
- entries.set(3, new WeatherSpecificDataEntry(
- this.getString(R.string.text_field_tem_min), tempFormatter.format(conversion)));
+ tempMin = tempFormatter.format(conversion) + symbol;
+ }
+ Bitmap picture;
+ if ((currentWeatherData.getWeather().size() > 0)
+ && (currentWeatherData.getWeather().get(0).getIcon() != null)
+ && (IconsList.getIcon(currentWeatherData.getWeather().get(0).getIcon()) != null)) {
+ final String icon = currentWeatherData.getWeather().get(0).getIcon();
+ picture = BitmapFactory.decodeResource(this.getResources(), IconsList.getIcon(icon)
+ .getResourceDrawable());
+ } else {
+ picture = BitmapFactory.decodeResource(this.getResources(),
+ R.drawable.weather_severe_alert);
}
+ final WeatherCurrentDataEntryFirst entryFirst = new WeatherCurrentDataEntryFirst(tempMax,
+ tempMin, picture);
+ adapter.add(entryFirst);
+ String description = "no description available";
+ if (currentWeatherData.getWeather().size() > 0) {
+ description = currentWeatherData.getWeather().get(0).getDescription();
+ }
+ final WeatherCurrentDataEntrySecond entrySecond = new WeatherCurrentDataEntrySecond(
+ description);
+ adapter.add(entrySecond);
+
+ String humidityValue = "";
+ if ((currentWeatherData.getMain() != null)
+ && (currentWeatherData.getMain().getHumidity() != null)) {
+ final double conversion = (Double) currentWeatherData.getMain().getHumidity();
+ humidityValue = tempFormatter.format(conversion);
+ }
+ String pressureValue = "";
+ if ((currentWeatherData.getMain() != null)
+ && (currentWeatherData.getMain().getPressure() != null)) {
+ final double conversion = (Double) currentWeatherData.getMain().getPressure();
+ pressureValue = tempFormatter.format(conversion);
+ }
+ String windValue = "";
+ if ((currentWeatherData.getWind() != null)
+ && (currentWeatherData.getWind().getSpeed() != null)) {
+ final double conversion = (Double) currentWeatherData.getWind().getSpeed();
+ windValue = tempFormatter.format(conversion);
+ }
+ String rainValue = "";
+ if ((currentWeatherData.getRain() != null)
+ && (currentWeatherData.getRain().get3h() != null)) {
+ final double conversion = (Double) currentWeatherData.getRain().get3h();
+ rainValue = tempFormatter.format(conversion);
+ }
+ String cloudsValue = "";
+ if ((currentWeatherData.getClouds() != null)
+ && (currentWeatherData.getClouds().getAll() != null)) {
+ final double conversion = (Double) currentWeatherData.getClouds().getAll();
+ cloudsValue = tempFormatter.format(conversion);
+ }
+ String snowValue = "";
+ if ((currentWeatherData.getSnow() != null)
+ && (currentWeatherData.getSnow().get3h() != null)) {
+ final double conversion = (Double) currentWeatherData.getSnow().get3h();
+ snowValue = tempFormatter.format(conversion);
+ }
+ String feelsLike = "";
+ if (currentWeatherData.getMain().getTemp() != null) {
+ double conversion = (Double) currentWeatherData.getMain().getTemp();
+ conversion = conversion - tempUnits;
+ feelsLike = tempFormatter.format(conversion);
+ }
+ String sunRiseTime = "";
if (currentWeatherData.getSys().getSunrise() != null) {
final long unixTime = (Long) currentWeatherData.getSys().getSunrise();
final Date unixDate = new Date(unixTime * 1000L);
- final String dateFormatUnix = dateFormat.format(unixDate);
- entries.set(4,
- new WeatherSpecificDataEntry(this.getString(R.string.text_field_sun_rise),
- dateFormatUnix));
+ sunRiseTime = dateFormat.format(unixDate);
}
-
+ String sunSetTime = "";
if (currentWeatherData.getSys().getSunset() != null) {
final long unixTime = (Long) currentWeatherData.getSys().getSunset();
final Date unixDate = new Date(unixTime * 1000L);
- final String dateFormatUnix = dateFormat.format(unixDate);
- entries.set(5, new WeatherSpecificDataEntry(
- this.getString(R.string.text_field_sun_set), dateFormatUnix));
+ sunSetTime = dateFormat.format(unixDate);
}
+ final WeatherCurrentDataEntryFifth entryFifth = new WeatherCurrentDataEntryFifth(
+ sunRiseTime, sunSetTime, humidityValue, pressureValue, windValue, rainValue,
+ feelsLike, symbol, snowValue, cloudsValue);
+ adapter.add(entryFifth);
- if (currentWeatherData.getClouds().getAll() != null) {
- final double cloudiness = (Double) currentWeatherData.getClouds().getAll();
- entries.set(6,
- new WeatherSpecificDataEntry(this.getString(R.string.text_field_cloudiness),
- tempFormatter.format(cloudiness)));
- }
- if (currentWeatherData.getIconData() != null) {
- final Bitmap icon = BitmapFactory.decodeByteArray(currentWeatherData.getIconData(), 0,
- currentWeatherData.getIconData().length);
- final ImageView imageIcon = (ImageView) this.getActivity().findViewById(
- R.id.weather_picture);
- imageIcon.setImageBitmap(icon);
- }
-
- adapter.addAll(entries);
this.setListAdapter(adapter);
}
weatherTask.execute(geocodingData);
}
}
-
- private List<WeatherSpecificDataEntry> createEmptyEntriesList() {
- final List<WeatherSpecificDataEntry> entries = new ArrayList<WeatherSpecificDataEntry>();
- entries.add(new WeatherSpecificDataEntry(this.getString(R.string.text_field_description),
- null));
- entries.add(new WeatherSpecificDataEntry(this.getString(R.string.text_field_tem), null));
- entries.add(new WeatherSpecificDataEntry(this.getString(R.string.text_field_tem_max), null));
- entries.add(new WeatherSpecificDataEntry(this.getString(R.string.text_field_tem_min), null));
- entries.add(new WeatherSpecificDataEntry(this.getString(R.string.text_field_sun_rise), null));
- entries.add(new WeatherSpecificDataEntry(this.getString(R.string.text_field_sun_set), null));
- entries.add(new WeatherSpecificDataEntry(this.getString(R.string.text_field_cloudiness),
- null));
- entries.add(new WeatherSpecificDataEntry(this.getString(R.string.text_field_rain_time),
- null));
- entries.add(new WeatherSpecificDataEntry(this.getString(R.string.text_field_rain_amount),
- null));
- entries.add(new WeatherSpecificDataEntry(this.getString(R.string.text_field_wind_speed),
- null));
- entries.add(new WeatherSpecificDataEntry(this.getString(R.string.text_field_humidity), null));
-
- return entries;
- }
}
import android.net.http.AndroidHttpClient;
import android.os.AsyncTask;
import android.os.Bundle;
+import android.os.Parcelable;
import android.preference.PreferenceManager;
import android.util.Log;
import android.view.View;
private boolean mIsFahrenheit;
private String mDayForecast;
private WeatherServicePersistenceFile mWeatherServicePersistenceFile;
+ private Parcelable mListState;
@Override
public void onCreate(final Bundle savedInstanceState) {
newFragment.show(this.getFragmentManager(), "errorDialog");
}
}
+
+ this.mListState = savedInstanceState.getParcelable("ListState");
}
this.setHasOptionsMenu(false);
savedInstanceState.putSerializable("ForecastWeatherData", forecastWeatherData);
}
+ this.mListState = this.getListView().onSaveInstanceState();
+ savedInstanceState.putParcelable("ListState", this.mListState);
+
super.onSaveInstanceState(savedInstanceState);
}
// 3. Update forecast weather data on display.
final ForecastWeatherData forecastWeatherData = this.mWeatherServicePersistenceFile
.getForecastWeatherData();
- if (forecastWeatherData != null) {
+ if ((this.mListState != null) && (forecastWeatherData != null)) {
+ this.updateForecastWeatherData(forecastWeatherData);
+ this.getListView().onRestoreInstanceState(this.mListState);
+ } else if (forecastWeatherData != null) {
this.updateForecastWeatherData(forecastWeatherData);
}
private ForecastWeatherData doInBackgroundThrowable(final Object... params)
throws ClientProtocolException, MalformedURLException,
URISyntaxException, JsonParseException, IOException {
- // final SharedPreferences sharedPreferences = PreferenceManager
- // .getDefaultSharedPreferences(WeatherInformationOverviewFragment.this
- // .getActivity());
- //
- // final String keyPreference =
- // WeatherInformationOverviewFragment.this
- // .getActivity().getString(
- // R.string.weather_preferences_language_key);
- // final String languagePreferenceValue =
- // sharedPreferences.getString(keyPreference, "");
// 1. Coordinates
final GeocodingData geocodingData = (GeocodingData) params[0];
newFragment.show(this.getFragmentManager(), "errorDialog");
}
}
+
+ this.mChosenDay = savedInstanceState.getInt("Chosen day");
}
}
savedInstanceState.putSerializable("ForecastWeatherData", forecastWeatherData);
}
+ savedInstanceState.putInt("Chosend day", this.mChosenDay);
+
super.onSaveInstanceState(savedInstanceState);
}