Exemplo n.º 1
0
 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
   MenuInflater inflater = getMenuInflater();
   inflater.inflate(R.menu.menu_main, menu);
   MenuItem units = menu.findItem(R.id.change_units);
   units.setChecked(
       AppSettings.getInstance(this).getBoolean(AppSettings.Key.IS_FAHRENHEIT, false));
   return true;
 }
Exemplo n.º 2
0
 @Override
 public void onWeatherUpdateFinished(CurrentWeather weather) {
   hideProgressIndicator();
   String name = AppSettings.getInstance(this).getString(AppSettings.Key.CURRENT_LOCATION_NAME);
   CollapsingToolbarLayout collapsingToolbarLayout =
       (CollapsingToolbarLayout) findViewById(R.id.toolbar_layout);
   collapsingToolbarLayout.setTitle(
       WeatherHelper.getFormattedTemperature(weather.getMain().getTemp()) + " " + name);
   updateAllWidgets();
 }
Exemplo n.º 3
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    // Handle item selection
    switch (item.getItemId()) {
      case R.id.change_units:
        boolean units =
            AppSettings.getInstance(this).getBoolean(AppSettings.Key.IS_FAHRENHEIT, false);
        AppSettings.getInstance(this).put(AppSettings.Key.IS_FAHRENHEIT, !units);
        item.setChecked(!units);
        ShowForecastFragment f =
            (ShowForecastFragment) getFragmentManager().findFragmentById(R.id.showForecastFragment);
        if (f != null) {
          f.getWeatherForLocation();
        }

        // Update all widgets
        updateAllWidgets();

        return true;
      default:
        return super.onOptionsItemSelected(item);
    }
  }