2 * Copyright 2014 Gustavo Martin Morcuende
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package name.gumartinm.weather.information.activity;
18 import android.app.ActionBar;
19 import android.os.Bundle;
20 import android.support.v4.app.FragmentActivity;
22 import name.gumartinm.weather.information.R;
23 import name.gumartinm.weather.information.model.DatabaseQueries;
24 import name.gumartinm.weather.information.model.WeatherLocation;
26 import java.text.MessageFormat;
27 import java.util.Locale;
29 public class SpecificActivity extends FragmentActivity {
32 protected void onCreate(final Bundle savedInstanceState) {
33 super.onCreate(savedInstanceState);
34 this.setContentView(R.layout.weather_specific);
36 final ActionBar actionBar = this.getActionBar();
38 actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
39 actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE, ActionBar.DISPLAY_SHOW_TITLE);
40 actionBar.setDisplayHomeAsUpEnabled(true);
45 public void onResume() {
49 final DatabaseQueries query = new DatabaseQueries(this);
50 final WeatherLocation weatherLocation = query.queryDataBase();
51 if (weatherLocation != null) {
52 final ActionBar actionBar = this.getActionBar();
53 final String[] array = new String[2];
54 array[0] = weatherLocation.getCity();
55 array[1] = weatherLocation.getCountry();
56 final MessageFormat message = new MessageFormat("{0},{1}", Locale.US);
57 final String cityCountry = message.format(array);
58 actionBar.setTitle(cityCountry);