0f5211c7267e2d190239770081a354dd5df0061d
[JavaForFun] /
1 package name.gumartinm.weather.information.activity;
2
3 import android.app.ActionBar;
4 import android.os.Bundle;
5 import android.support.v4.app.FragmentActivity;
6
7 import name.gumartinm.weather.information.R;
8 import name.gumartinm.weather.information.model.DatabaseQueries;
9 import name.gumartinm.weather.information.model.WeatherLocation;
10
11 import java.text.MessageFormat;
12 import java.util.Locale;
13
14 public class SpecificActivity extends FragmentActivity {
15
16     @Override
17     protected void onCreate(final Bundle savedInstanceState) {
18         super.onCreate(savedInstanceState);
19         this.setContentView(R.layout.weather_specific);
20
21         final ActionBar actionBar = this.getActionBar();
22
23         actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
24         actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE, ActionBar.DISPLAY_SHOW_TITLE);
25         actionBar.setDisplayHomeAsUpEnabled(true);
26
27     }
28
29     @Override
30     public void onResume() {
31         super.onResume();
32
33         // 1. Update title.
34         final DatabaseQueries query = new DatabaseQueries(this);
35         final WeatherLocation weatherLocation = query.queryDataBase();
36         if (weatherLocation != null) {
37                 final ActionBar actionBar = this.getActionBar();
38             final String[] array = new String[2];
39             array[0] = weatherLocation.getCity();
40             array[1] = weatherLocation.getCountry();
41             final MessageFormat message = new MessageFormat("{0},{1}", Locale.US);
42             final String cityCountry = message.format(array);
43             actionBar.setTitle(cityCountry);
44         }
45     }
46 }