android:maxSdkVersion="18"
android:minSdkVersion="18"
android:targetSdkVersion="18" />
+
<uses-feature
android:glEsVersion="0x00020000"
- android:required="true"/>
+ android:required="true" />
<uses-permission android:name="android.permission.INTERNET" />
- <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
- <!-- The following two permissions are not required to use
- Google Maps Android API v2, but are recommended. -->
- <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
- <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
- <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
+ <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+ <!--
+ The following two permissions are not required to use
+ Google Maps Android API v2, but are recommended.
+ -->
+ <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
+ <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
+ <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
- android:logo="@drawable/ic_launcher"
android:label="@string/app_name"
+ android:logo="@drawable/ic_launcher"
android:theme="@style/AppTheme" >
<activity
android:name="de.example.exampletdd.WeatherInformationActivity"
- android:uiOptions="splitActionBarWhenNarrow"
- android:hardwareAccelerated="false">
+ android:hardwareAccelerated="false"
+ android:uiOptions="splitActionBarWhenNarrow" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
-
<activity
- android:name=".WeatherInformationPreferencesActivity"
- android:parentActivityName="de.example.exampletdd.WeatherInformationActivity">
- <intent-filter >
+ android:name="de.example.exampletdd.WeatherInformationPreferencesActivity"
+ android:parentActivityName="de.example.exampletdd.WeatherInformationActivity" >
+ <intent-filter>
<action android:name="android.intent.action.WEATHERINFORMATIONSETTINGS" />
+
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
-
<activity
- android:name=".WeatherInformationMapActivity"
- android:parentActivityName="de.example.exampletdd.WeatherInformationActivity">
- <intent-filter >
+ android:name="de.example.exampletdd.WeatherInformationMapActivity"
+ android:parentActivityName="de.example.exampletdd.WeatherInformationActivity" >
+ <intent-filter>
<action android:name="android.intent.action.WEATHERINFORMATIONMAP" />
+
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
-
<activity
- android:name=".WeatherInformationSpecificDataActivity"
- android:parentActivityName="de.example.exampletdd.WeatherInformationActivity">
- <intent-filter >
+ android:name="de.example.exampletdd.WeatherInformationSpecificDataActivity"
+ android:parentActivityName="de.example.exampletdd.WeatherInformationActivity" >
+ <intent-filter>
<action android:name="android.intent.action.WEATHERINFORMATIONSPECIFICDATA" />
+
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
-
<activity
- android:name=".WeatherInformationCurrentDataActivity"
- android:parentActivityName="de.example.exampletdd.WeatherInformationActivity">
- <intent-filter >
+ android:name="de.example.exampletdd.WeatherInformationCurrentDataActivity"
+ android:parentActivityName="de.example.exampletdd.WeatherInformationActivity" >
+ <intent-filter>
<action android:name="android.intent.action.WEATHERINFORMATIONCURRENTDATA" />
+
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
-
-
+
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
- android:value=""/>
+ android:value="AIzaSyCPjAbkUGfl1M6gkFxnUzBvO_xfq1pWABE" />
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
+
+ <activity
+ android:name="de.example.exampletdd.TestScrollActivity"
+ android:label="@string/title_activity_test_scroll"
+ android:parentActivityName="de.example.exampletdd.WeatherInformationActivity" >
+ </activity>
+ <activity
+ android:name="de.example.exampletdd.MasterDetailListActivity"
+ android:label="@string/title_masterdetail_list" >
+ </activity>
+ <activity
+ android:name="de.example.exampletdd.MasterDetailDetailActivity"
+ android:label="@string/title_masterdetail_detail"
+ android:parentActivityName="de.example.exampletdd.MasterDetailListActivity" >
+ <meta-data
+ android:name="android.support.PARENT_ACTIVITY"
+ android:value="de.example.exampletdd.MasterDetailListActivity" />
+ </activity>
</application>
</manifest>
# Project target.
target=android-18
android.library.reference.1=../../../../android/android-sdk-linux/extras/google/google_play_services/libproject/google-play-services_lib
+android.library=false
--- /dev/null
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:id="@+id/masterdetail_detail_container"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ tools:context="de.example.exampletdd.MasterDetailDetailActivity"
+ tools:ignore="MergeRootFrame" />
--- /dev/null
+<fragment xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:id="@+id/masterdetail_list"
+ android:name="de.example.exampletdd.MasterDetailListFragment"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_marginLeft="16dp"
+ android:layout_marginRight="16dp"
+ tools:context="de.example.exampletdd.MasterDetailListActivity"
+ tools:layout="@android:layout/list_content" />
--- /dev/null
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_marginLeft="16dp"
+ android:layout_marginRight="16dp"
+ android:baselineAligned="false"
+ android:divider="?android:attr/dividerHorizontal"
+ android:orientation="horizontal"
+ android:showDividers="middle"
+ tools:context="de.example.exampletdd.MasterDetailListActivity" >
+
+ <!--
+ This layout is a two-pane layout for the MasterDetails
+ master/detail flow. See res/values-large/refs.xml and
+ res/values-sw600dp/refs.xml for an example of layout aliases
+ that replace the single-pane version of the layout with
+ this two-pane version.
+
+ For more on layout aliases, see:
+ http://developer.android.com/training/multiscreen/screensizes.html#TaskUseAliasFilters
+ -->
+
+ <fragment
+ android:id="@+id/masterdetail_list"
+ android:name="de.example.exampletdd.MasterDetailListFragment"
+ android:layout_width="0dp"
+ android:layout_height="match_parent"
+ android:layout_weight="1"
+ tools:layout="@android:layout/list_content" />
+
+ <FrameLayout
+ android:id="@+id/masterdetail_detail_container"
+ android:layout_width="0dp"
+ android:layout_height="match_parent"
+ android:layout_weight="3" />
+
+</LinearLayout>
--- /dev/null
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:id="@+id/container"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ tools:context="de.example.exampletdd.TestScrollActivity"
+ tools:ignore="MergeRootFrame" >
+
+
+ <RelativeLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_gravity="top|center"
+ android:orientation="horizontal">
+
+ <ImageView
+ android:id="@+id/weather_current_picture"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="top|center"
+ android:layout_centerHorizontal="true"
+ android:contentDescription="@string/icon_weather_description"
+ android:maxHeight="380dp"
+ android:maxWidth="380dp"
+ android:minHeight="180dp"
+ android:minWidth="180dp"
+ android:src="@drawable/weather_snow" />
+
+ <!-- Temperature Max-->
+ <TextView
+ android:id="@+id/weather_max_temperature"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="55ºC"
+ android:textAlignment="center"
+ android:layout_toRightOf="@id/weather_current_picture"
+ android:layout_alignTop="@id/weather_current_picture"
+ android:layout_margin="10dp"
+ android:layout_gravity="top|center"
+ android:layout_centerHorizontal="true"
+ android:textAppearance="?android:attr/textAppearanceLarge"
+ android:textStyle="bold" />
+
+ <!-- Temperature Min-->
+ <TextView
+ android:id="@+id/weather_min_temperature"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="55ºC"
+ android:textAlignment="center"
+ android:layout_toRightOf="@id/weather_current_picture"
+ android:layout_below="@+id/weather_max_temperature"
+ android:layout_margin="10dp"
+ android:layout_gravity="top|center"
+ android:layout_centerHorizontal="true"
+ android:textAppearance="?android:attr/textAppearanceMedium" />
+
+ <!-- Weather description-->
+ <TextView
+ android:id="@+id/weather_description"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:gravity="center"
+ android:text="Light rain"
+ android:textAlignment="center"
+ android:textColor="@color/weather_time_of_day_color_title"
+ android:layout_below="@+id/weather_current_picture"
+ android:layout_margin="5dp"
+ android:textStyle="bold"
+ android:textAppearance="?android:attr/textAppearanceLarge" />
+
+
+
+
+
+ <!-- Humidity -->
+ <TextView
+ android:id="@+id/weather_humidity"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="HUMIDITY"
+ android:gravity="left"
+ android:layout_alignParentLeft="true"
+ android:textAlignment="center"
+ android:layout_below="@+id/weather_description"
+ android:layout_margin="10dp"
+ android:textAppearance="?android:attr/textAppearanceSmall" />
+
+ <!-- Wind -->
+ <TextView
+ android:id="@+id/weather_wind"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="WIND"
+ android:gravity="right"
+ android:layout_alignParentRight="true"
+ android:layout_below="@+id/weather_description"
+ android:layout_toRightOf="@id/weather_humidity"
+ android:textAlignment="center"
+ android:layout_margin="10dp"
+ android:textAppearance="?android:attr/textAppearanceSmall" />
+
+ <!-- Pressure -->
+ <TextView
+ android:id="@+id/weather_pressure"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="PRESSURE"
+ android:gravity="left"
+ android:layout_alignParentLeft="true"
+ android:textAlignment="center"
+ android:layout_below="@+id/weather_humidity"
+ android:layout_margin="10dp"
+ android:textAppearance="?android:attr/textAppearanceSmall" />
+
+ <!-- Rain -->
+ <TextView
+ android:id="@+id/weather_rain"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="RAIN"
+ android:gravity="right"
+ android:layout_alignParentRight="true"
+ android:layout_below="@+id/weather_wind"
+ android:layout_toRightOf="@id/weather_humidity"
+ android:textAlignment="center"
+ android:layout_margin="10dp"
+ android:textAppearance="?android:attr/textAppearanceSmall" />
+
+ </RelativeLayout>
+
+ <HorizontalScrollView
+ android:layout_width="fill_parent"
+ android:layout_gravity="bottom"
+ android:layout_height="150dp" >
+
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal" >
+
+
+ <RelativeLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="vertical">
+
+ <!-- Thermometer -->
+ <ImageView
+ android:id="@+id/thermometer"
+ 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:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:text="55ºC"
+ android:textAlignment="center"
+ android:gravity="center|center_vertical"
+ android:layout_below="@+id/weather_morn"
+ android:layout_toRightOf="@id/thermometer"
+ android:layout_alignTop="@id/thermometer"
+ android:textAppearance="?android:attr/textAppearanceLarge"
+ android:textStyle="bold" />
+
+ <!-- Time of day -->
+
+ <TextView
+ android:id="@+id/weather_morn"
+ android:layout_width="140dp"
+ android:layout_height="wrap_content"
+ android:layout_alignParentTop="true"
+ android:gravity="center"
+ android:selectAllOnFocus="true"
+ android:text="DAY"
+ android:textColor="@color/weather_time_of_day_color_title"
+ android:textAlignment="center"
+ android:textAppearance="?android:attr/textAppearanceLarge" />
+
+ </RelativeLayout>
+
+
+ <RelativeLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="vertical">
+
+ <!-- Thermometer -->
+ <ImageView
+ android:id="@+id/thermometer"
+ 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:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:text="55ºC"
+ android:textAlignment="center"
+ android:gravity="center|center_vertical"
+ android:layout_below="@+id/weather_morn"
+ android:layout_toRightOf="@id/thermometer"
+ android:layout_alignTop="@id/thermometer"
+ android:textAppearance="?android:attr/textAppearanceLarge"
+ android:textStyle="bold" />
+
+ <!-- Time of day -->
+ <TextView
+ android:id="@+id/weather_morn"
+ android:layout_width="140dp"
+ android:layout_height="wrap_content"
+ android:text="MORNING"
+ android:textColor="@color/weather_time_of_day_color_title"
+ android:textAlignment="center"
+ android:gravity="center"
+ android:layout_alignParentTop="true"
+ android:textAppearance="?android:attr/textAppearanceLarge" />
+
+ </RelativeLayout>
+
+
+ <RelativeLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="vertical">
+
+ <!-- Thermometer -->
+ <ImageView
+ android:id="@+id/thermometer"
+ 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:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:text="55ºC"
+ android:textAlignment="center"
+ android:gravity="center|center_vertical"
+ android:layout_below="@+id/weather_morn"
+ android:layout_toRightOf="@id/thermometer"
+ android:layout_alignTop="@id/thermometer"
+ android:textAppearance="?android:attr/textAppearanceLarge"
+ android:textStyle="bold" />
+
+ <!-- Time of day -->
+ <TextView
+ android:id="@+id/weather_morn"
+ android:layout_width="140dp"
+ android:layout_height="wrap_content"
+ android:text="EVENING"
+ android:textColor="@color/weather_time_of_day_color_title"
+ android:textAlignment="center"
+ android:gravity="center"
+ android:layout_alignParentTop="true"
+ android:textAppearance="?android:attr/textAppearanceLarge" />
+
+ </RelativeLayout>
+
+
+ <RelativeLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="vertical">
+
+ <!-- Thermometer -->
+ <ImageView
+ android:id="@+id/thermometer"
+ 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:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:text="55ºC"
+ android:textAlignment="center"
+ android:gravity="center|center_vertical"
+ android:layout_below="@+id/weather_morn"
+ android:layout_toRightOf="@id/thermometer"
+ android:layout_alignTop="@id/thermometer"
+ android:textAppearance="?android:attr/textAppearanceLarge"
+ android:textStyle="bold" />
+
+ <!-- Time of day -->
+ <TextView
+ android:id="@+id/weather_morn"
+ android:layout_width="140dp"
+ android:layout_height="wrap_content"
+ android:text="NIGHT"
+ android:textColor="@color/weather_time_of_day_color_title"
+ android:textAlignment="center"
+ android:gravity="center"
+ android:layout_alignParentTop="true"
+ android:textAppearance="?android:attr/textAppearanceLarge" />
+
+ </RelativeLayout>
+
+ </LinearLayout>
+ </HorizontalScrollView>
+
+</FrameLayout>
\ No newline at end of file
--- /dev/null
+<TextView xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:id="@+id/masterdetail_detail"
+ style="?android:attr/textAppearanceLarge"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:padding="16dp"
+ android:textIsSelectable="true"
+ tools:context="de.example.exampletdd.MasterDetailDetailFragment" />
--- /dev/null
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:paddingBottom="@dimen/activity_vertical_margin"
+ android:paddingLeft="@dimen/activity_horizontal_margin"
+ android:paddingRight="@dimen/activity_horizontal_margin"
+ android:paddingTop="@dimen/activity_vertical_margin"
+ tools:context="de.example.exampletdd.TestScrollActivity$PlaceholderFragment" >
+
+ <TextView
+ android:id="@+id/section_label"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content" />
+
+</RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
+ android:padding="15dp"
android:orientation="vertical" >
<TextView
- android:id="@+id/weather_main_entry_date"
+ android:id="@+id/weather_main_entry_date_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_alignBottom="@+id/weather_main_entry_temperature"
+ android:layout_above="@+id/weather_main_entry_date_number"
android:layout_alignParentLeft="true"
- android:layout_alignTop="@+id/weather_main_entry_temperature"
- android:text="Date"
+ android:layout_alignBottom="@+id/weather_main_entry_temperature_max"
+ android:layout_alignTop="@+id/weather_main_entry_temperature_max"
+ android:text="SUN"
android:textAlignment="center"
android:textAllCaps="true"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textStyle="bold" />
+ <TextView
+ android:id="@+id/weather_main_entry_date_number"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignBottom="@+id/weather_main_entry_temperature_min"
+ android:layout_alignParentLeft="true"
+ android:layout_alignTop="@+id/weather_main_entry_temperature_min"
+ android:text="APR 23"
+ android:textAlignment="center"
+ android:textAllCaps="true"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:textStyle="normal" />
<TextView
- android:id="@+id/weather_main_entry_temperature"
+ android:id="@+id/weather_main_entry_temperature_max"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_alignBottom="@+id/weather_main_entry_image"
android:layout_alignTop="@+id/weather_main_entry_image"
android:layout_centerHorizontal="true"
- android:text="Temperature"
+ android:text="12ºC"
+ android:textAlignment="center"
+ android:textAllCaps="true"
+ android:textColor="@color/weather_time_of_day_color_title"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:textStyle="bold" />
+
+ <TextView
+ android:id="@+id/weather_main_entry_temperature_min"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_below="@+id/weather_main_entry_temperature_max"
+ android:layout_alignBottom="@+id/weather_main_entry_image"
+ android:layout_centerHorizontal="true"
+ android:text="5ºC"
android:textAlignment="center"
android:textAllCaps="true"
+ android:textColor="@color/weather_time_of_day_color_title"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="normal" />
--- /dev/null
+<menu xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ tools:context="de.example.exampletdd.TestScrollActivity" >
+
+ <item
+ android:id="@+id/action_settings"
+ android:orderInCategory="100"
+ android:showAsAction="never"
+ android:title="@string/action_settings"/>
+
+</menu>
android:checkable="false"
android:enabled="true"
android:icon="@drawable/ic_action_refresh"
- android:showAsAction="ifRoom|withText">
+ android:showAsAction="ifRoom">
</item>
<item
android:id="@+id/weather_menu_settings"
android:checkable="false"
android:enabled="true"
android:icon="@drawable/ic_action_settings"
- android:showAsAction="ifRoom|withText">
+ android:showAsAction="ifRoom">
</item>
<item
android:id="@+id/weather_menu_map"
android:icon="@drawable/ic_action_place"
- android:showAsAction="ifRoom|withText"
+ android:showAsAction="ifRoom"
android:visible="true"
android:checkable="false"
android:enabled="true"
android:checkable="false"
android:enabled="true"
android:icon="@drawable/ic_action_import_export"
- android:showAsAction="ifRoom|withText">
+ android:showAsAction="ifRoom">
</item>
--- /dev/null
+<resources>
+
+ <!--
+ Layout alias to replace the single-pane version of the layout with a
+ two-pane version on Large screens.
+
+ For more on layout aliases, see:
+ http://developer.android.com/training/multiscreen/screensizes.html#TaskUseAliasFilters
+ -->
+ <item name="activity_masterdetail_list" type="layout">@layout/activity_masterdetail_twopane</item>
+
+</resources>
--- /dev/null
+<resources>
+
+ <!--
+ Layout alias to replace the single-pane version of the layout with a
+ two-pane version on Large screens.
+
+ For more on layout aliases, see:
+ http://developer.android.com/training/multiscreen/screensizes.html#TaskUseAliasFilters
+ -->
+ <item name="activity_masterdetail_list" type="layout">@layout/activity_masterdetail_twopane</item>
+
+</resources>
<string name="country_not_found">country not found</string>
<string name="progress_dialog_get_remote_data">Downloading remote data</string>
<string name="progress_dialog_generic_message">Please wait…</string>
+ <string name="title_activity_test_scroll">TestScrollActivity</string>
+ <string name="title_section1">Section 1</string>
+ <string name="title_section2">Section 2</string>
+ <string name="title_section3">Section 3</string>
+ <string name="title_masterdetail_list">MasterDetails</string>
+ <string name="title_masterdetail_detail">MasterDetail Detail</string>
</resources>
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
+
+
+ <color name="weather_time_of_day_color_title">#48aed4</color>
</resources>
--- /dev/null
+package de.example.exampletdd;
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.support.v4.app.FragmentActivity;
+import android.support.v4.app.NavUtils;
+import android.view.MenuItem;
+
+/**
+ * An activity representing a single MasterDetail detail screen. This activity
+ * is only used on handset devices. On tablet-size devices, item details are
+ * presented side-by-side with a list of items in a
+ * {@link MasterDetailListActivity}.
+ * <p>
+ * This activity is mostly just a 'shell' activity containing nothing more than
+ * a {@link MasterDetailDetailFragment}.
+ */
+public class MasterDetailDetailActivity extends FragmentActivity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_masterdetail_detail);
+
+ // Show the Up button in the action bar.
+ getActionBar().setDisplayHomeAsUpEnabled(true);
+
+ // savedInstanceState is non-null when there is fragment state
+ // saved from previous configurations of this activity
+ // (e.g. when rotating the screen from portrait to landscape).
+ // In this case, the fragment will automatically be re-added
+ // to its container so we don't need to manually add it.
+ // For more information, see the Fragments API guide at:
+ //
+ // http://developer.android.com/guide/components/fragments.html
+ //
+ if (savedInstanceState == null) {
+ // Create the detail fragment and add it to the activity
+ // using a fragment transaction.
+ Bundle arguments = new Bundle();
+ arguments.putString(MasterDetailDetailFragment.ARG_ITEM_ID,
+ getIntent().getStringExtra(MasterDetailDetailFragment.ARG_ITEM_ID));
+ MasterDetailDetailFragment fragment = new MasterDetailDetailFragment();
+ fragment.setArguments(arguments);
+ getSupportFragmentManager().beginTransaction()
+ .add(R.id.masterdetail_detail_container, fragment).commit();
+ }
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ int id = item.getItemId();
+ if (id == android.R.id.home) {
+ // This ID represents the Home or Up button. In the case of this
+ // activity, the Up button is shown. Use NavUtils to allow users
+ // to navigate up one level in the application structure. For
+ // more details, see the Navigation pattern on Android Design:
+ //
+ // http://developer.android.com/design/patterns/navigation.html#up-vs-back
+ //
+ NavUtils.navigateUpTo(this, new Intent(this, MasterDetailListActivity.class));
+ return true;
+ }
+ return super.onOptionsItemSelected(item);
+ }
+}
--- /dev/null
+package de.example.exampletdd;
+
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+
+import de.example.exampletdd.dummy.DummyContent;
+
+/**
+ * A fragment representing a single MasterDetail detail screen. This fragment is
+ * either contained in a {@link MasterDetailListActivity} in two-pane mode (on
+ * tablets) or a {@link MasterDetailDetailActivity} on handsets.
+ */
+public class MasterDetailDetailFragment extends Fragment {
+ /**
+ * The fragment argument representing the item ID that this fragment
+ * represents.
+ */
+ public static final String ARG_ITEM_ID = "item_id";
+
+ /**
+ * The dummy content this fragment is presenting.
+ */
+ private DummyContent.DummyItem mItem;
+
+ /**
+ * Mandatory empty constructor for the fragment manager to instantiate the
+ * fragment (e.g. upon screen orientation changes).
+ */
+ public MasterDetailDetailFragment() {
+ }
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ if (getArguments().containsKey(ARG_ITEM_ID)) {
+ // Load the dummy content specified by the fragment
+ // arguments. In a real-world scenario, use a Loader
+ // to load content from a content provider.
+ mItem = DummyContent.ITEM_MAP.get(getArguments().getString(ARG_ITEM_ID));
+ }
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+ View rootView = inflater.inflate(R.layout.fragment_masterdetail_detail, container, false);
+
+ // Show the dummy content as text in a TextView.
+ if (mItem != null) {
+ ((TextView) rootView.findViewById(R.id.masterdetail_detail)).setText(mItem.content);
+ }
+
+ return rootView;
+ }
+}
--- /dev/null
+package de.example.exampletdd;
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.support.v4.app.FragmentActivity;
+
+/**
+ * An activity representing a list of MasterDetails. This activity has different
+ * presentations for handset and tablet-size devices. On handsets, the activity
+ * presents a list of items, which when touched, lead to a
+ * {@link MasterDetailDetailActivity} representing item details. On tablets, the
+ * activity presents the list of items and item details side-by-side using two
+ * vertical panes.
+ * <p>
+ * The activity makes heavy use of fragments. The list of items is a
+ * {@link MasterDetailListFragment} and the item details (if present) is a
+ * {@link MasterDetailDetailFragment}.
+ * <p>
+ * This activity also implements the required
+ * {@link MasterDetailListFragment.Callbacks} interface to listen for item
+ * selections.
+ */
+public class MasterDetailListActivity extends FragmentActivity implements
+ MasterDetailListFragment.Callbacks {
+
+ /**
+ * Whether or not the activity is in two-pane mode, i.e. running on a tablet
+ * device.
+ */
+ private boolean mTwoPane;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_masterdetail_list);
+
+ if (findViewById(R.id.masterdetail_detail_container) != null) {
+ // The detail container view will be present only in the
+ // large-screen layouts (res/values-large and
+ // res/values-sw600dp). If this view is present, then the
+ // activity should be in two-pane mode.
+ mTwoPane = true;
+
+ // In two-pane mode, list items should be given the
+ // 'activated' state when touched.
+ ((MasterDetailListFragment) getSupportFragmentManager().findFragmentById(
+ R.id.masterdetail_list)).setActivateOnItemClick(true);
+ }
+
+ // TODO: If exposing deep links into your app, handle intents here.
+ }
+
+ /**
+ * Callback method from {@link MasterDetailListFragment.Callbacks}
+ * indicating that the item with the given ID was selected.
+ */
+ @Override
+ public void onItemSelected(String id) {
+ if (mTwoPane) {
+ // In two-pane mode, show the detail view in this activity by
+ // adding or replacing the detail fragment using a
+ // fragment transaction.
+ Bundle arguments = new Bundle();
+ arguments.putString(MasterDetailDetailFragment.ARG_ITEM_ID, id);
+ MasterDetailDetailFragment fragment = new MasterDetailDetailFragment();
+ fragment.setArguments(arguments);
+ getSupportFragmentManager().beginTransaction()
+ .replace(R.id.masterdetail_detail_container, fragment).commit();
+
+ } else {
+ // In single-pane mode, simply start the detail activity
+ // for the selected item ID.
+ Intent detailIntent = new Intent(this, MasterDetailDetailActivity.class);
+ detailIntent.putExtra(MasterDetailDetailFragment.ARG_ITEM_ID, id);
+ startActivity(detailIntent);
+ }
+ }
+}
--- /dev/null
+package de.example.exampletdd;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.support.v4.app.ListFragment;
+import android.view.View;
+import android.widget.ArrayAdapter;
+import android.widget.ListView;
+
+import de.example.exampletdd.dummy.DummyContent;
+
+/**
+ * A list fragment representing a list of MasterDetails. This fragment also
+ * supports tablet devices by allowing list items to be given an 'activated'
+ * state upon selection. This helps indicate which item is currently being
+ * viewed in a {@link MasterDetailDetailFragment}.
+ * <p>
+ * Activities containing this fragment MUST implement the {@link Callbacks}
+ * interface.
+ */
+public class MasterDetailListFragment extends ListFragment {
+
+ /**
+ * The serialization (saved instance state) Bundle key representing the
+ * activated item position. Only used on tablets.
+ */
+ private static final String STATE_ACTIVATED_POSITION = "activated_position";
+
+ /**
+ * The fragment's current callback object, which is notified of list item
+ * clicks.
+ */
+ private Callbacks mCallbacks = sDummyCallbacks;
+
+ /**
+ * The current activated item position. Only used on tablets.
+ */
+ private int mActivatedPosition = ListView.INVALID_POSITION;
+
+ /**
+ * A callback interface that all activities containing this fragment must
+ * implement. This mechanism allows activities to be notified of item
+ * selections.
+ */
+ public interface Callbacks {
+ /**
+ * Callback for when an item has been selected.
+ */
+ public void onItemSelected(String id);
+ }
+
+ /**
+ * A dummy implementation of the {@link Callbacks} interface that does
+ * nothing. Used only when this fragment is not attached to an activity.
+ */
+ private static Callbacks sDummyCallbacks = new Callbacks() {
+ @Override
+ public void onItemSelected(String id) {
+ }
+ };
+
+ /**
+ * Mandatory empty constructor for the fragment manager to instantiate the
+ * fragment (e.g. upon screen orientation changes).
+ */
+ public MasterDetailListFragment() {
+ }
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ // TODO: replace with a real list adapter.
+ setListAdapter(new ArrayAdapter<DummyContent.DummyItem>(getActivity(),
+ android.R.layout.simple_list_item_activated_1, android.R.id.text1,
+ DummyContent.ITEMS));
+ }
+
+ @Override
+ public void onViewCreated(View view, Bundle savedInstanceState) {
+ super.onViewCreated(view, savedInstanceState);
+
+ // Restore the previously serialized activated item position.
+ if (savedInstanceState != null && savedInstanceState.containsKey(STATE_ACTIVATED_POSITION)) {
+ setActivatedPosition(savedInstanceState.getInt(STATE_ACTIVATED_POSITION));
+ }
+ }
+
+ @Override
+ public void onAttach(Activity activity) {
+ super.onAttach(activity);
+
+ // Activities containing this fragment must implement its callbacks.
+ if (!(activity instanceof Callbacks)) {
+ throw new IllegalStateException("Activity must implement fragment's callbacks.");
+ }
+
+ mCallbacks = (Callbacks) activity;
+ }
+
+ @Override
+ public void onDetach() {
+ super.onDetach();
+
+ // Reset the active callbacks interface to the dummy implementation.
+ mCallbacks = sDummyCallbacks;
+ }
+
+ @Override
+ public void onListItemClick(ListView listView, View view, int position, long id) {
+ super.onListItemClick(listView, view, position, id);
+
+ // Notify the active callbacks interface (the activity, if the
+ // fragment is attached to one) that an item has been selected.
+ mCallbacks.onItemSelected(DummyContent.ITEMS.get(position).id);
+ }
+
+ @Override
+ public void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ if (mActivatedPosition != ListView.INVALID_POSITION) {
+ // Serialize and persist the activated item position.
+ outState.putInt(STATE_ACTIVATED_POSITION, mActivatedPosition);
+ }
+ }
+
+ /**
+ * Turns on activate-on-click mode. When this mode is on, list items will be
+ * given the 'activated' state when touched.
+ */
+ public void setActivateOnItemClick(boolean activateOnItemClick) {
+ // When setting CHOICE_MODE_SINGLE, ListView will automatically
+ // give items the 'activated' state when touched.
+ getListView().setChoiceMode(
+ activateOnItemClick ? ListView.CHOICE_MODE_SINGLE : ListView.CHOICE_MODE_NONE);
+ }
+
+ private void setActivatedPosition(int position) {
+ if (position == ListView.INVALID_POSITION) {
+ getListView().setItemChecked(mActivatedPosition, false);
+ } else {
+ getListView().setItemChecked(position, true);
+ }
+
+ mActivatedPosition = position;
+ }
+}
--- /dev/null
+package de.example.exampletdd;
+
+import android.app.ActionBar;
+import android.app.Activity;
+import android.app.Fragment;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+import android.widget.TextView;
+
+public class TestScrollActivity extends Activity implements ActionBar.OnNavigationListener {
+
+ /**
+ * The serialization (saved instance state) Bundle key representing the
+ * current dropdown position.
+ */
+ private static final String STATE_SELECTED_NAVIGATION_ITEM = "selected_navigation_item";
+
+ @Override
+ protected void onCreate(final Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ this.setContentView(R.layout.activity_test_scroll);
+
+ // Set up the action bar to show a dropdown list.
+ final ActionBar actionBar = this.getActionBar();
+ actionBar.setDisplayShowTitleEnabled(false);
+ actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
+
+ // Set up the dropdown list navigation in the action bar.
+ actionBar.setListNavigationCallbacks(
+ // Specify a SpinnerAdapter to populate the dropdown list.
+ new ArrayAdapter<String>(actionBar.getThemedContext(),
+ android.R.layout.simple_list_item_1, android.R.id.text1, new String[] {
+ this.getString(R.string.title_section1),
+ this.getString(R.string.title_section2),
+ this.getString(R.string.title_section3), }), this);
+ }
+
+ @Override
+ public void onRestoreInstanceState(final Bundle savedInstanceState) {
+ // Restore the previously serialized current dropdown position.
+ if (savedInstanceState.containsKey(STATE_SELECTED_NAVIGATION_ITEM)) {
+ this.getActionBar().setSelectedNavigationItem(
+ savedInstanceState.getInt(STATE_SELECTED_NAVIGATION_ITEM));
+ }
+ }
+
+ @Override
+ public void onSaveInstanceState(final Bundle outState) {
+ // Serialize the current dropdown position.
+ outState.putInt(STATE_SELECTED_NAVIGATION_ITEM, this.getActionBar().getSelectedNavigationIndex());
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(final Menu menu) {
+
+ // Inflate the menu; this adds items to the action bar if it is present.
+ this.getMenuInflater().inflate(R.menu.test_scroll, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(final MenuItem item) {
+ // Handle action bar item clicks here. The action bar will
+ // automatically handle clicks on the Home/Up button, so long
+ // as you specify a parent activity in AndroidManifest.xml.
+ final int id = item.getItemId();
+ if (id == R.id.action_settings) {
+ return true;
+ }
+ return super.onOptionsItemSelected(item);
+ }
+
+ @Override
+ public boolean onNavigationItemSelected(final int position, final long id) {
+ // When the given dropdown item is selected, show its contents in the
+ // container view.
+ // getFragmentManager().beginTransaction()
+ // .replace(R.id.container, PlaceholderFragment.newInstance(position +
+ // 1)).commit();
+ return true;
+ }
+
+ /**
+ * A placeholder fragment containing a simple view.
+ */
+ public static class PlaceholderFragment extends Fragment {
+ /**
+ * The fragment argument representing the section number for this
+ * fragment.
+ */
+ private static final String ARG_SECTION_NUMBER = "section_number";
+
+ /**
+ * Returns a new instance of this fragment for the given section number.
+ */
+ public static PlaceholderFragment newInstance(final int sectionNumber) {
+ final PlaceholderFragment fragment = new PlaceholderFragment();
+ final Bundle args = new Bundle();
+ args.putInt(ARG_SECTION_NUMBER, sectionNumber);
+ fragment.setArguments(args);
+ return fragment;
+ }
+
+ public PlaceholderFragment() {
+ }
+
+ @Override
+ public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
+ final Bundle savedInstanceState) {
+ final View rootView = inflater.inflate(R.layout.fragment_test_scroll, container, false);
+ final TextView textView = (TextView) rootView.findViewById(R.id.section_label);
+ textView.setText(Integer.toString(this.getArguments().getInt(ARG_SECTION_NUMBER)));
+ return rootView;
+ }
+ }
+
+}
super.onOptionsItemSelected(item);
Intent intent;
- switch (item.getItemId()) {
- case R.id.weather_menu_settings:
+ final int itemId = item.getItemId();
+ if (itemId == R.id.weather_menu_settings) {
intent = new Intent("de.example.exampletdd.WEATHERINFO")
.setComponent(new ComponentName("de.example.exampletdd",
"de.example.exampletdd.WeatherInformationPreferencesActivity"));
this.startActivity(intent);
return true;
- case R.id.weather_menu_get:
+ } else if (itemId == R.id.weather_menu_get) {
this.getWeather();
return true;
- case R.id.weather_menu_map:
+ } else if (itemId == R.id.weather_menu_map) {
intent = new Intent("de.example.exampletdd.WEATHERINFO")
.setComponent(new ComponentName("de.example.exampletdd",
"de.example.exampletdd.WeatherInformationMapActivity"));
this.startActivity(intent);
return true;
- case R.id.weather_menu_current:
+ } else if (itemId == R.id.weather_menu_current) {
intent = new Intent("de.example.exampletdd.WEATHERINFO")
.setComponent(new ComponentName("de.example.exampletdd",
- "de.example.exampletdd.WeatherInformationCurrentDataActivity"));
+ "de.example.exampletdd.TestScrollActivity"));
this.startActivity(intent);
return true;
- default:
- break;
+ } else {
}
return super.onOptionsItemSelected(item);
.getString(R.string.city_not_found) : geocodingData.getCity();
final String country = (geocodingData.getCountry() == null) ? this
.getString(R.string.country_not_found) : geocodingData.getCountry();
- actionBar.setTitle("Specific weather data information");
- actionBar.setSubtitle(city + "," + country);
+ actionBar.setTitle(city + "," + country);
}
}
--- /dev/null
+package de.example.exampletdd.dummy;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Helper class for providing sample content for user interfaces created by
+ * Android template wizards.
+ * <p>
+ * TODO: Replace all uses of this class before publishing your app.
+ */
+public class DummyContent {
+
+ /**
+ * An array of sample (dummy) items.
+ */
+ public static List<DummyItem> ITEMS = new ArrayList<DummyItem>();
+
+ /**
+ * A map of sample (dummy) items, by ID.
+ */
+ public static Map<String, DummyItem> ITEM_MAP = new HashMap<String, DummyItem>();
+
+ static {
+ // Add 3 sample items.
+ addItem(new DummyItem("1", "Item 1"));
+ addItem(new DummyItem("2", "Item 2"));
+ addItem(new DummyItem("3", "Item 3"));
+ }
+
+ private static void addItem(DummyItem item) {
+ ITEMS.add(item);
+ ITEM_MAP.put(item.id, item);
+ }
+
+ /**
+ * A dummy item representing a piece of content.
+ */
+ public static class DummyItem {
+ public String id;
+ public String content;
+
+ public DummyItem(String id, String content) {
+ this.id = id;
+ this.content = content;
+ }
+
+ @Override
+ public String toString() {
+ return content;
+ }
+ }
+}
--- /dev/null
+package de.example.exampletdd.fragment.overview;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import de.example.exampletdd.R;
+
+public enum IconsList {
+ ICON_01d("01d") {
+ @Override
+ public int getResourceDrawable() {
+ return R.drawable.weather_clear;
+ }
+ },
+ ICON_01n("01n") {
+ @Override
+ public int getResourceDrawable() {
+ return R.drawable.weather_clear_night;
+ }
+ },
+ ICON_02d("02d") {
+ @Override
+ public int getResourceDrawable() {
+ return R.drawable.weather_few_clouds;
+ }
+ },
+ ICON_02n("02n") {
+ @Override
+ public int getResourceDrawable() {
+ return R.drawable.weather_few_clouds_night;
+ }
+ },
+ ICON_03d("03d") {
+ @Override
+ public int getResourceDrawable() {
+ return R.drawable.weather_few_clouds;
+ }
+ },
+ ICON_03n("03n") {
+ @Override
+ public int getResourceDrawable() {
+ return R.drawable.weather_few_clouds;
+ }
+ },
+ ICON_04d("04d") {
+ @Override
+ public int getResourceDrawable() {
+ return R.drawable.weather_overcast;
+ }
+ },
+ ICON_04n("04n") {
+ @Override
+ public int getResourceDrawable() {
+ return R.drawable.weather_overcast;
+ }
+ },
+ ICON_09d("09d") {
+ @Override
+ public int getResourceDrawable() {
+ return R.drawable.weather_showers;
+ }
+ },
+ ICON_09n("09n") {
+ @Override
+ public int getResourceDrawable() {
+ return R.drawable.weather_showers;
+ }
+ },
+ ICON_10d("10d") {
+ @Override
+ public int getResourceDrawable() {
+ return R.drawable.weather_showers_scattered;
+ }
+ },
+ ICON_10n("10n") {
+ @Override
+ public int getResourceDrawable() {
+ return R.drawable.weather_showers_scattered;
+ }
+ },
+ ICON_11d("11d") {
+ @Override
+ public int getResourceDrawable() {
+ return R.drawable.weather_storm;
+ }
+ },
+ ICON_11n("11n") {
+ @Override
+ public int getResourceDrawable() {
+ return R.drawable.weather_storm;
+ }
+ },
+ ICON_13d("13d") {
+ @Override
+ public int getResourceDrawable() {
+ return R.drawable.weather_snow;
+ }
+ },
+ ICON_13n("13n") {
+ @Override
+ public int getResourceDrawable() {
+ return R.drawable.weather_snow;
+ }
+ },
+ ICON_50d("50d") {
+ @Override
+ public int getResourceDrawable() {
+ return R.drawable.weather_fog;
+ }
+ },
+ ICON_50n("50n") {
+ @Override
+ public int getResourceDrawable() {
+ return R.drawable.weather_fog;
+ }
+ };
+
+ private final String icon;
+ // Map with every enum constant. Class variable initializer. JLS§12.4.2
+ // Executed in textual order.
+ private static final Map<String, IconsList> codeMap = new HashMap<String, IconsList>();
+
+ // Static initializer. JLS§12.4.2 Executed in textual order.
+ static {
+ for (final IconsList code : IconsList.values()) {
+ codeMap.put(code.getIcon(), code);
+ }
+ }
+
+ private IconsList(final String icon) {
+ this.icon = icon;
+ }
+
+ public static final IconsList getIcon(final String icon) {
+ return codeMap.get(icon);
+ }
+
+ private String getIcon() {
+ return this.icon;
+ }
+
+ public abstract int getResourceDrawable();
+}
final WeatherOverviewAdapter adapter = new WeatherOverviewAdapter(this.getActivity(),
R.layout.weather_main_entry_list);
- final Bitmap picture = BitmapFactory.decodeResource(
- this.getResources(), R.drawable.ic_02d);
+
final DecimalFormat tempFormatter = (DecimalFormat) NumberFormat.getNumberInstance(Locale.getDefault());
tempFormatter.applyPattern("#####.##");
- final SimpleDateFormat dateFormat = new SimpleDateFormat("EEE, MMM d", Locale.getDefault());
+ final SimpleDateFormat dayNameFormatter = new SimpleDateFormat("EEE", Locale.getDefault());
+ final SimpleDateFormat monthAndDayNumberormatter = new SimpleDateFormat("MMM d",
+ Locale.getDefault());
final double tempUnits = this.mIsFahrenheit ? 0 : 273.15;
final String symbol = this.mIsFahrenheit ? "ºF" : "ºC";
for (final de.example.exampletdd.model.forecastweather.List forecast : forecastWeatherData
.getList()) {
+ Bitmap picture;
+
+ if ((forecast.getWeather().size() > 0) &&
+ (forecast.getWeather().get(0).getIcon() != null) &&
+ (IconsList.getIcon(forecast.getWeather().get(0).getIcon()) != null)) {
+ final String icon = forecast.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 Long forecastUNIXDate = (Long) forecast.getDt();
calendar.setTimeInMillis(forecastUNIXDate * 1000L);
final Date dayTime = calendar.getTime();
- final String dayText = dateFormat.format(dayTime);
+ final String dayTextName = dayNameFormatter.format(dayTime);
+ final String monthAndDayNumberText = monthAndDayNumberormatter.format(dayTime);
Double maxTemp = null;
if (forecast.getTemp().getMax() != null) {
}
if ((maxTemp != null) && (minTemp != null)) {
- entries.add(new WeatherOverviewEntry(dayText, tempFormatter.format(maxTemp)
- + symbol, tempFormatter.format(minTemp) + symbol, picture));
+ entries.add(new WeatherOverviewEntry(dayTextName, monthAndDayNumberText,
+ tempFormatter.format(maxTemp) + symbol, tempFormatter.format(minTemp) + symbol,
+ picture));
}
}
// Setting date
- viewHolder.dateView.setText(entry.getDate());
+ viewHolder.dateNameView.setText(entry.getDateName());
+ viewHolder.dateNumberView.setText(entry.getDateNumber());
// Setting temperature max/min
- viewHolder.temperatureView.setText(entry.getMaxTemp() + "/" + entry.getMinTemp());
+ viewHolder.temperatureMaxView.setText(entry.getMaxTemp());
+ viewHolder.temperatureMinView.setText(entry.getMinTemp());
// Set image view
viewHolder.pictureView.setImageBitmap(entry.getPicture());
if((null == tag) || !(tag instanceof ViewHolder)) {
viewHolder = new ViewHolder();
- viewHolder.dateView = (TextView) workingView
- .findViewById(R.id.weather_main_entry_date);
- viewHolder.temperatureView = (TextView) workingView
- .findViewById(R.id.weather_main_entry_temperature);
+ viewHolder.dateNameView = (TextView) workingView
+ .findViewById(R.id.weather_main_entry_date_name);
+ viewHolder.dateNumberView = (TextView) workingView
+ .findViewById(R.id.weather_main_entry_date_number);
+ viewHolder.temperatureMaxView = (TextView) workingView
+ .findViewById(R.id.weather_main_entry_temperature_max);
+ viewHolder.temperatureMinView = (TextView) workingView
+ .findViewById(R.id.weather_main_entry_temperature_min);
viewHolder.pictureView = (ImageView) workingView
.findViewById(R.id.weather_main_entry_image);
* Since views are recycled, these references will never change
*/
private static class ViewHolder {
- public TextView dateView;
- public TextView temperatureView;
+ public TextView dateNameView;
+ public TextView dateNumberView;
+ public TextView temperatureMaxView;
+ public TextView temperatureMinView;
public ImageView pictureView;
}
import android.graphics.Bitmap;
public class WeatherOverviewEntry {
- private final String date;
+ private final String dateName;
+ private final String dateNumber;
private final String maxTemp;
private final String minTemp;
private final Bitmap picture;
- public WeatherOverviewEntry(final String date, final String maxTemp, final String minTemp,
+ public WeatherOverviewEntry(final String dateName, final String dateNumber,
+ final String maxTemp, final String minTemp,
final Bitmap picture) {
- this.date = date;
+ this.dateName = dateName;
+ this.dateNumber = dateNumber;
this.maxTemp = maxTemp;
this.minTemp = minTemp;
this.picture = picture;
}
- public String getDate() {
- return this.date;
+ public String getDateName() {
+ return this.dateName;
+ }
+
+ public String getDateNumber() {
+ return this.dateNumber;
}
public String getMaxTemp() {
import java.io.IOException;
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;
final de.example.exampletdd.model.forecastweather.List forecast = forecastWeatherData
.getList().get((chosenDay));
+ final SimpleDateFormat dayFormatter = new SimpleDateFormat("EEEE - MMM d", Locale.getDefault());
+ final Calendar calendar = Calendar.getInstance();
+ final Long forecastUNIXDate = (Long) forecast.getDt();
+ calendar.setTimeInMillis(forecastUNIXDate * 1000L);
+ final Date date = calendar.getTime();
+ this.getActivity().getActionBar().setSubtitle(dayFormatter.format(date).toUpperCase());
+
if (forecast.getWeather().size() > 0) {
entries.set(0,
new WeatherSpecificDataEntry(this.getString(R.string.text_field_description),