From: gu.martinm@gmail.com Date: Sat, 19 Apr 2014 15:16:31 +0000 (+0200) Subject: Trying to implement weather information app. This is hard... X-Git-Tag: weatherinformation-1.0~171 X-Git-Url: https://git.gumartinm.name/?a=commitdiff_plain;h=3b397362e9b7a2004f4b76268d501614b1f3951d;p=AndroidWeatherInformation Trying to implement weather information app. This is hard... --- diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 096164b..8b5e56e 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -9,79 +9,99 @@ android:maxSdkVersion="18" android:minSdkVersion="18" android:targetSdkVersion="18" /> + + android:required="true" /> - - - - - - + + + + + + + android:hardwareAccelerated="false" + android:uiOptions="splitActionBarWhenNarrow" > - - + android:name="de.example.exampletdd.WeatherInformationPreferencesActivity" + android:parentActivityName="de.example.exampletdd.WeatherInformationActivity" > + + - - + android:name="de.example.exampletdd.WeatherInformationMapActivity" + android:parentActivityName="de.example.exampletdd.WeatherInformationActivity" > + + - - + android:name="de.example.exampletdd.WeatherInformationSpecificDataActivity" + android:parentActivityName="de.example.exampletdd.WeatherInformationActivity" > + + - - + android:name="de.example.exampletdd.WeatherInformationCurrentDataActivity" + android:parentActivityName="de.example.exampletdd.WeatherInformationActivity" > + + - - + + android:value="AIzaSyCPjAbkUGfl1M6gkFxnUzBvO_xfq1pWABE" /> + + + + + + + + diff --git a/project.properties b/project.properties index 2110cdf..7612c3e 100644 --- a/project.properties +++ b/project.properties @@ -13,3 +13,4 @@ # 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 diff --git a/res/drawable-hdpi/ic_02d.png b/res/drawable-hdpi/ic_02d.png deleted file mode 100644 index 3451b4a..0000000 Binary files a/res/drawable-hdpi/ic_02d.png and /dev/null differ diff --git a/res/drawable-hdpi/thermometer.png b/res/drawable-hdpi/thermometer.png new file mode 100644 index 0000000..89f39a8 Binary files /dev/null and b/res/drawable-hdpi/thermometer.png differ diff --git a/res/drawable-hdpi/weather_clear.png b/res/drawable-hdpi/weather_clear.png new file mode 100644 index 0000000..974da61 Binary files /dev/null and b/res/drawable-hdpi/weather_clear.png differ diff --git a/res/drawable-hdpi/weather_clear_night.png b/res/drawable-hdpi/weather_clear_night.png new file mode 100644 index 0000000..2db4d82 Binary files /dev/null and b/res/drawable-hdpi/weather_clear_night.png differ diff --git a/res/drawable-hdpi/weather_few_clouds.png b/res/drawable-hdpi/weather_few_clouds.png new file mode 100644 index 0000000..ab3e430 Binary files /dev/null and b/res/drawable-hdpi/weather_few_clouds.png differ diff --git a/res/drawable-hdpi/weather_few_clouds_night.png b/res/drawable-hdpi/weather_few_clouds_night.png new file mode 100644 index 0000000..67ee004 Binary files /dev/null and b/res/drawable-hdpi/weather_few_clouds_night.png differ diff --git a/res/drawable-hdpi/weather_fog.png b/res/drawable-hdpi/weather_fog.png new file mode 100644 index 0000000..bc3c429 Binary files /dev/null and b/res/drawable-hdpi/weather_fog.png differ diff --git a/res/drawable-hdpi/weather_overcast.png b/res/drawable-hdpi/weather_overcast.png new file mode 100644 index 0000000..8075b13 Binary files /dev/null and b/res/drawable-hdpi/weather_overcast.png differ diff --git a/res/drawable-hdpi/weather_severe_alert.png b/res/drawable-hdpi/weather_severe_alert.png new file mode 100644 index 0000000..42334e8 Binary files /dev/null and b/res/drawable-hdpi/weather_severe_alert.png differ diff --git a/res/drawable-hdpi/weather_showers.png b/res/drawable-hdpi/weather_showers.png new file mode 100644 index 0000000..d2a456a Binary files /dev/null and b/res/drawable-hdpi/weather_showers.png differ diff --git a/res/drawable-hdpi/weather_showers_scattered.png b/res/drawable-hdpi/weather_showers_scattered.png new file mode 100644 index 0000000..e58ade9 Binary files /dev/null and b/res/drawable-hdpi/weather_showers_scattered.png differ diff --git a/res/drawable-hdpi/weather_snow.png b/res/drawable-hdpi/weather_snow.png new file mode 100644 index 0000000..4812c8c Binary files /dev/null and b/res/drawable-hdpi/weather_snow.png differ diff --git a/res/drawable-hdpi/weather_storm.png b/res/drawable-hdpi/weather_storm.png new file mode 100644 index 0000000..b829abf Binary files /dev/null and b/res/drawable-hdpi/weather_storm.png differ diff --git a/res/drawable-mdpi/ic_02d.png b/res/drawable-mdpi/ic_02d.png deleted file mode 100644 index 482afa3..0000000 Binary files a/res/drawable-mdpi/ic_02d.png and /dev/null differ diff --git a/res/drawable-mdpi/thermometer.png b/res/drawable-mdpi/thermometer.png new file mode 100644 index 0000000..f645657 Binary files /dev/null and b/res/drawable-mdpi/thermometer.png differ diff --git a/res/drawable-mdpi/weather_clear.png b/res/drawable-mdpi/weather_clear.png new file mode 100644 index 0000000..0bdb0da Binary files /dev/null and b/res/drawable-mdpi/weather_clear.png differ diff --git a/res/drawable-mdpi/weather_clear_night.png b/res/drawable-mdpi/weather_clear_night.png new file mode 100644 index 0000000..2617ec1 Binary files /dev/null and b/res/drawable-mdpi/weather_clear_night.png differ diff --git a/res/drawable-mdpi/weather_few_clouds.png b/res/drawable-mdpi/weather_few_clouds.png new file mode 100644 index 0000000..5a78bd0 Binary files /dev/null and b/res/drawable-mdpi/weather_few_clouds.png differ diff --git a/res/drawable-mdpi/weather_few_clouds_night.png b/res/drawable-mdpi/weather_few_clouds_night.png new file mode 100644 index 0000000..3dcd13f Binary files /dev/null and b/res/drawable-mdpi/weather_few_clouds_night.png differ diff --git a/res/drawable-mdpi/weather_fog.png b/res/drawable-mdpi/weather_fog.png new file mode 100644 index 0000000..7d99916 Binary files /dev/null and b/res/drawable-mdpi/weather_fog.png differ diff --git a/res/drawable-mdpi/weather_overcast.png b/res/drawable-mdpi/weather_overcast.png new file mode 100644 index 0000000..79303a5 Binary files /dev/null and b/res/drawable-mdpi/weather_overcast.png differ diff --git a/res/drawable-mdpi/weather_severe_alert.png b/res/drawable-mdpi/weather_severe_alert.png new file mode 100644 index 0000000..308931b Binary files /dev/null and b/res/drawable-mdpi/weather_severe_alert.png differ diff --git a/res/drawable-mdpi/weather_showers.png b/res/drawable-mdpi/weather_showers.png new file mode 100644 index 0000000..6dce4e1 Binary files /dev/null and b/res/drawable-mdpi/weather_showers.png differ diff --git a/res/drawable-mdpi/weather_showers_scattered.png b/res/drawable-mdpi/weather_showers_scattered.png new file mode 100644 index 0000000..0e0b43e Binary files /dev/null and b/res/drawable-mdpi/weather_showers_scattered.png differ diff --git a/res/drawable-mdpi/weather_snow.png b/res/drawable-mdpi/weather_snow.png new file mode 100644 index 0000000..9364b58 Binary files /dev/null and b/res/drawable-mdpi/weather_snow.png differ diff --git a/res/drawable-mdpi/weather_storm.png b/res/drawable-mdpi/weather_storm.png new file mode 100644 index 0000000..5e37b51 Binary files /dev/null and b/res/drawable-mdpi/weather_storm.png differ diff --git a/res/drawable-xhdpi/ic_02d.png b/res/drawable-xhdpi/ic_02d.png deleted file mode 100644 index 775ee02..0000000 Binary files a/res/drawable-xhdpi/ic_02d.png and /dev/null differ diff --git a/res/drawable-xhdpi/thermometer.png b/res/drawable-xhdpi/thermometer.png new file mode 100644 index 0000000..bd86520 Binary files /dev/null and b/res/drawable-xhdpi/thermometer.png differ diff --git a/res/drawable-xhdpi/weather_clear.png b/res/drawable-xhdpi/weather_clear.png new file mode 100644 index 0000000..42bad9c Binary files /dev/null and b/res/drawable-xhdpi/weather_clear.png differ diff --git a/res/drawable-xhdpi/weather_clear_night.png b/res/drawable-xhdpi/weather_clear_night.png new file mode 100644 index 0000000..a9ab2dc Binary files /dev/null and b/res/drawable-xhdpi/weather_clear_night.png differ diff --git a/res/drawable-xhdpi/weather_few_clouds.png b/res/drawable-xhdpi/weather_few_clouds.png new file mode 100644 index 0000000..954a7fd Binary files /dev/null and b/res/drawable-xhdpi/weather_few_clouds.png differ diff --git a/res/drawable-xhdpi/weather_few_clouds_night.png b/res/drawable-xhdpi/weather_few_clouds_night.png new file mode 100644 index 0000000..be93567 Binary files /dev/null and b/res/drawable-xhdpi/weather_few_clouds_night.png differ diff --git a/res/drawable-xhdpi/weather_fog.png b/res/drawable-xhdpi/weather_fog.png new file mode 100644 index 0000000..bcca0a8 Binary files /dev/null and b/res/drawable-xhdpi/weather_fog.png differ diff --git a/res/drawable-xhdpi/weather_overcast.png b/res/drawable-xhdpi/weather_overcast.png new file mode 100644 index 0000000..5096963 Binary files /dev/null and b/res/drawable-xhdpi/weather_overcast.png differ diff --git a/res/drawable-xhdpi/weather_severe_alert.png b/res/drawable-xhdpi/weather_severe_alert.png new file mode 100644 index 0000000..c074f4e Binary files /dev/null and b/res/drawable-xhdpi/weather_severe_alert.png differ diff --git a/res/drawable-xhdpi/weather_showers.png b/res/drawable-xhdpi/weather_showers.png new file mode 100644 index 0000000..28264f2 Binary files /dev/null and b/res/drawable-xhdpi/weather_showers.png differ diff --git a/res/drawable-xhdpi/weather_showers_scattered.png b/res/drawable-xhdpi/weather_showers_scattered.png new file mode 100644 index 0000000..f76f4e9 Binary files /dev/null and b/res/drawable-xhdpi/weather_showers_scattered.png differ diff --git a/res/drawable-xhdpi/weather_snow.png b/res/drawable-xhdpi/weather_snow.png new file mode 100644 index 0000000..5226484 Binary files /dev/null and b/res/drawable-xhdpi/weather_snow.png differ diff --git a/res/drawable-xhdpi/weather_storm.png b/res/drawable-xhdpi/weather_storm.png new file mode 100644 index 0000000..7539dee Binary files /dev/null and b/res/drawable-xhdpi/weather_storm.png differ diff --git a/res/drawable-xxhdpi/ic_02d.png b/res/drawable-xxhdpi/ic_02d.png deleted file mode 100644 index 54649c6..0000000 Binary files a/res/drawable-xxhdpi/ic_02d.png and /dev/null differ diff --git a/res/drawable-xxhdpi/thermometer.png b/res/drawable-xxhdpi/thermometer.png new file mode 100644 index 0000000..37b3747 Binary files /dev/null and b/res/drawable-xxhdpi/thermometer.png differ diff --git a/res/drawable-xxhdpi/weather_clear.png b/res/drawable-xxhdpi/weather_clear.png new file mode 100644 index 0000000..73a5bbd Binary files /dev/null and b/res/drawable-xxhdpi/weather_clear.png differ diff --git a/res/drawable-xxhdpi/weather_clear_night.png b/res/drawable-xxhdpi/weather_clear_night.png new file mode 100644 index 0000000..2c60054 Binary files /dev/null and b/res/drawable-xxhdpi/weather_clear_night.png differ diff --git a/res/drawable-xxhdpi/weather_few_clouds.png b/res/drawable-xxhdpi/weather_few_clouds.png new file mode 100644 index 0000000..2d38702 Binary files /dev/null and b/res/drawable-xxhdpi/weather_few_clouds.png differ diff --git a/res/drawable-xxhdpi/weather_few_clouds_night.png b/res/drawable-xxhdpi/weather_few_clouds_night.png new file mode 100644 index 0000000..333afa7 Binary files /dev/null and b/res/drawable-xxhdpi/weather_few_clouds_night.png differ diff --git a/res/drawable-xxhdpi/weather_fog.png b/res/drawable-xxhdpi/weather_fog.png new file mode 100644 index 0000000..1bebc54 Binary files /dev/null and b/res/drawable-xxhdpi/weather_fog.png differ diff --git a/res/drawable-xxhdpi/weather_overcast.png b/res/drawable-xxhdpi/weather_overcast.png new file mode 100644 index 0000000..e3101eb Binary files /dev/null and b/res/drawable-xxhdpi/weather_overcast.png differ diff --git a/res/drawable-xxhdpi/weather_severe_alert.png b/res/drawable-xxhdpi/weather_severe_alert.png new file mode 100644 index 0000000..b0ac4b7 Binary files /dev/null and b/res/drawable-xxhdpi/weather_severe_alert.png differ diff --git a/res/drawable-xxhdpi/weather_showers.png b/res/drawable-xxhdpi/weather_showers.png new file mode 100644 index 0000000..6a1860c Binary files /dev/null and b/res/drawable-xxhdpi/weather_showers.png differ diff --git a/res/drawable-xxhdpi/weather_showers_scattered.png b/res/drawable-xxhdpi/weather_showers_scattered.png new file mode 100644 index 0000000..97d0f77 Binary files /dev/null and b/res/drawable-xxhdpi/weather_showers_scattered.png differ diff --git a/res/drawable-xxhdpi/weather_snow.png b/res/drawable-xxhdpi/weather_snow.png new file mode 100644 index 0000000..ac714cc Binary files /dev/null and b/res/drawable-xxhdpi/weather_snow.png differ diff --git a/res/drawable-xxhdpi/weather_storm.png b/res/drawable-xxhdpi/weather_storm.png new file mode 100644 index 0000000..c339221 Binary files /dev/null and b/res/drawable-xxhdpi/weather_storm.png differ diff --git a/res/layout/activity_masterdetail_detail.xml b/res/layout/activity_masterdetail_detail.xml new file mode 100644 index 0000000..d306e79 --- /dev/null +++ b/res/layout/activity_masterdetail_detail.xml @@ -0,0 +1,7 @@ + diff --git a/res/layout/activity_masterdetail_list.xml b/res/layout/activity_masterdetail_list.xml new file mode 100644 index 0000000..6f7c60c --- /dev/null +++ b/res/layout/activity_masterdetail_list.xml @@ -0,0 +1,10 @@ + diff --git a/res/layout/activity_masterdetail_twopane.xml b/res/layout/activity_masterdetail_twopane.xml new file mode 100644 index 0000000..f09e404 --- /dev/null +++ b/res/layout/activity_masterdetail_twopane.xml @@ -0,0 +1,38 @@ + + + + + + + + + diff --git a/res/layout/activity_test_scroll.xml b/res/layout/activity_test_scroll.xml new file mode 100644 index 0000000..5ad3eba --- /dev/null +++ b/res/layout/activity_test_scroll.xml @@ -0,0 +1,331 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/res/layout/fragment_masterdetail_detail.xml b/res/layout/fragment_masterdetail_detail.xml new file mode 100644 index 0000000..ea1a39a --- /dev/null +++ b/res/layout/fragment_masterdetail_detail.xml @@ -0,0 +1,9 @@ + diff --git a/res/layout/fragment_test_scroll.xml b/res/layout/fragment_test_scroll.xml new file mode 100644 index 0000000..cccb845 --- /dev/null +++ b/res/layout/fragment_test_scroll.xml @@ -0,0 +1,16 @@ + + + + + diff --git a/res/layout/weather_main_entry_list.xml b/res/layout/weather_main_entry_list.xml index 6802af1..f11a2ac 100644 --- a/res/layout/weather_main_entry_list.xml +++ b/res/layout/weather_main_entry_list.xml @@ -2,31 +2,59 @@ + + + diff --git a/res/menu/test_scroll.xml b/res/menu/test_scroll.xml new file mode 100644 index 0000000..3a15165 --- /dev/null +++ b/res/menu/test_scroll.xml @@ -0,0 +1,11 @@ + + + + + diff --git a/res/menu/weather_main_menu.xml b/res/menu/weather_main_menu.xml index f2f40d1..e2c28f0 100644 --- a/res/menu/weather_main_menu.xml +++ b/res/menu/weather_main_menu.xml @@ -12,7 +12,7 @@ android:checkable="false" android:enabled="true" android:icon="@drawable/ic_action_refresh" - android:showAsAction="ifRoom|withText"> + android:showAsAction="ifRoom"> + android:showAsAction="ifRoom"> + android:showAsAction="ifRoom"> diff --git a/res/values-large/refs.xml b/res/values-large/refs.xml new file mode 100644 index 0000000..f1ea4e6 --- /dev/null +++ b/res/values-large/refs.xml @@ -0,0 +1,12 @@ + + + + @layout/activity_masterdetail_twopane + + diff --git a/res/values-sw600dp/refs.xml b/res/values-sw600dp/refs.xml new file mode 100644 index 0000000..f1ea4e6 --- /dev/null +++ b/res/values-sw600dp/refs.xml @@ -0,0 +1,12 @@ + + + + @layout/activity_masterdetail_twopane + + diff --git a/res/values/strings.xml b/res/values/strings.xml index e87cdcc..b6355fd 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -47,5 +47,11 @@ country not found Downloading remote data Please wait… + TestScrollActivity + Section 1 + Section 2 + Section 3 + MasterDetails + MasterDetail Detail diff --git a/res/values/styles.xml b/res/values/styles.xml index a2374b4..0ed23ba 100644 --- a/res/values/styles.xml +++ b/res/values/styles.xml @@ -16,5 +16,8 @@ + + + #48aed4 diff --git a/src/de/example/exampletdd/MasterDetailDetailActivity.java b/src/de/example/exampletdd/MasterDetailDetailActivity.java new file mode 100644 index 0000000..4700060 --- /dev/null +++ b/src/de/example/exampletdd/MasterDetailDetailActivity.java @@ -0,0 +1,66 @@ +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}. + *

+ * 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); + } +} diff --git a/src/de/example/exampletdd/MasterDetailDetailFragment.java b/src/de/example/exampletdd/MasterDetailDetailFragment.java new file mode 100644 index 0000000..b679c40 --- /dev/null +++ b/src/de/example/exampletdd/MasterDetailDetailFragment.java @@ -0,0 +1,59 @@ +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; + } +} diff --git a/src/de/example/exampletdd/MasterDetailListActivity.java b/src/de/example/exampletdd/MasterDetailListActivity.java new file mode 100644 index 0000000..7cf2a57 --- /dev/null +++ b/src/de/example/exampletdd/MasterDetailListActivity.java @@ -0,0 +1,78 @@ +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. + *

+ * 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}. + *

+ * 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); + } + } +} diff --git a/src/de/example/exampletdd/MasterDetailListFragment.java b/src/de/example/exampletdd/MasterDetailListFragment.java new file mode 100644 index 0000000..e81b39b --- /dev/null +++ b/src/de/example/exampletdd/MasterDetailListFragment.java @@ -0,0 +1,147 @@ +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}. + *

+ * 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(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; + } +} diff --git a/src/de/example/exampletdd/TestScrollActivity.java b/src/de/example/exampletdd/TestScrollActivity.java new file mode 100644 index 0000000..b894a94 --- /dev/null +++ b/src/de/example/exampletdd/TestScrollActivity.java @@ -0,0 +1,122 @@ +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(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; + } + } + +} diff --git a/src/de/example/exampletdd/WeatherInformationActivity.java b/src/de/example/exampletdd/WeatherInformationActivity.java index c58c3a1..b45a6ff 100644 --- a/src/de/example/exampletdd/WeatherInformationActivity.java +++ b/src/de/example/exampletdd/WeatherInformationActivity.java @@ -60,30 +60,29 @@ public class WeatherInformationActivity extends Activity { 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); diff --git a/src/de/example/exampletdd/WeatherInformationSpecificDataActivity.java b/src/de/example/exampletdd/WeatherInformationSpecificDataActivity.java index 549b61b..bf56f69 100644 --- a/src/de/example/exampletdd/WeatherInformationSpecificDataActivity.java +++ b/src/de/example/exampletdd/WeatherInformationSpecificDataActivity.java @@ -35,8 +35,7 @@ public class WeatherInformationSpecificDataActivity extends Activity { .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); } } diff --git a/src/de/example/exampletdd/dummy/DummyContent.java b/src/de/example/exampletdd/dummy/DummyContent.java new file mode 100644 index 0000000..6c09241 --- /dev/null +++ b/src/de/example/exampletdd/dummy/DummyContent.java @@ -0,0 +1,55 @@ +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. + *

+ * TODO: Replace all uses of this class before publishing your app. + */ +public class DummyContent { + + /** + * An array of sample (dummy) items. + */ + public static List ITEMS = new ArrayList(); + + /** + * A map of sample (dummy) items, by ID. + */ + public static Map ITEM_MAP = new HashMap(); + + 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; + } + } +} diff --git a/src/de/example/exampletdd/fragment/overview/IconsList.java b/src/de/example/exampletdd/fragment/overview/IconsList.java new file mode 100644 index 0000000..ecfb2e9 --- /dev/null +++ b/src/de/example/exampletdd/fragment/overview/IconsList.java @@ -0,0 +1,143 @@ +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 codeMap = new HashMap(); + + // 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(); +} diff --git a/src/de/example/exampletdd/fragment/overview/WeatherInformationOverviewFragment.java b/src/de/example/exampletdd/fragment/overview/WeatherInformationOverviewFragment.java index a3ca249..9d4a579 100644 --- a/src/de/example/exampletdd/fragment/overview/WeatherInformationOverviewFragment.java +++ b/src/de/example/exampletdd/fragment/overview/WeatherInformationOverviewFragment.java @@ -165,11 +165,12 @@ public class WeatherInformationOverviewFragment extends ListFragment implements 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"; @@ -178,11 +179,24 @@ public class WeatherInformationOverviewFragment extends ListFragment implements 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) { @@ -197,8 +211,9 @@ public class WeatherInformationOverviewFragment extends ListFragment implements } 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)); } } diff --git a/src/de/example/exampletdd/fragment/overview/WeatherOverviewAdapter.java b/src/de/example/exampletdd/fragment/overview/WeatherOverviewAdapter.java index e053181..6d2a26d 100644 --- a/src/de/example/exampletdd/fragment/overview/WeatherOverviewAdapter.java +++ b/src/de/example/exampletdd/fragment/overview/WeatherOverviewAdapter.java @@ -31,10 +31,12 @@ public class WeatherOverviewAdapter extends ArrayAdapter { // 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()); @@ -71,10 +73,14 @@ public class WeatherOverviewAdapter extends ArrayAdapter { 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); @@ -92,8 +98,10 @@ public class WeatherOverviewAdapter extends ArrayAdapter { * 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; } diff --git a/src/de/example/exampletdd/fragment/overview/WeatherOverviewEntry.java b/src/de/example/exampletdd/fragment/overview/WeatherOverviewEntry.java index 3dfd92d..c8d6b05 100644 --- a/src/de/example/exampletdd/fragment/overview/WeatherOverviewEntry.java +++ b/src/de/example/exampletdd/fragment/overview/WeatherOverviewEntry.java @@ -3,21 +3,28 @@ package de.example.exampletdd.fragment.overview; 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() { diff --git a/src/de/example/exampletdd/fragment/specific/WeatherInformationSpecificDataFragment.java b/src/de/example/exampletdd/fragment/specific/WeatherInformationSpecificDataFragment.java index 5501a7f..aecda8a 100644 --- a/src/de/example/exampletdd/fragment/specific/WeatherInformationSpecificDataFragment.java +++ b/src/de/example/exampletdd/fragment/specific/WeatherInformationSpecificDataFragment.java @@ -3,7 +3,10 @@ package de.example.exampletdd.fragment.specific; 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; @@ -128,6 +131,13 @@ public class WeatherInformationSpecificDataFragment extends ListFragment impleme 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),