Пример #1
0
  @SuppressWarnings("UnusedDeclaration")
  public void onEventMainThread(ShowDisclaimerEvent event) {
    mBus.removeStickyEvent(ShowDisclaimerEvent.class);
    if (!Installation.wasDisclaimerShown(this)) {
      final MainActivity that = this;
      AlertDialog dialog =
          new AlertDialog.Builder(this)
              .setTitle(R.string.disclaimer_header)
              .setMessage(R.string.disclaimer)
              .setPositiveButton(
                  R.string.accept,
                  new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                      Installation.setDisclaimerShown(that);
                      mBus.post(new DisclaimerAcceptedEvent());
                    }
                  })
              .setNegativeButton(
                  R.string.cancel,
                  new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {

                      that.finish();
                    }
                  })
              .create();
      dialog.show();
    } else {
      mBus.post(new DisclaimerAcceptedEvent());
    }
  }
Пример #2
0
  public void onEventMainThread(RetrofitError error) {
    setProgressBarIndeterminateVisibility(false);

    Toast toast = Toast.makeText(this, R.string.error_fetch_openweathermap, Toast.LENGTH_LONG);
    toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
    toast.show();

    mBus.removeStickyEvent(error);
  }
Пример #3
0
  public void onEventMainThread(WeatherData weatherData) {
    Log.d(TAG, weatherData.name);
    setProgressBarIndeterminateVisibility(false);
    Double temp = weatherData.main.temp - 272.15; // kelvin to celcius
    vh.tvTemperature.setText(Integer.toString(temp.intValue()));

    String url = WeatherData.ICON_BASE_URL + weatherData.weather.get(0).icon + WeatherData.EXT;
    Log.d(TAG, url);
    Picasso.with(this).load(url).into(vh.ivClouds);

    temp = weatherData.main.temp_min - 272.15;
    String minTemp =
        getResources().getString(R.string.label_max)
            + " "
            + Integer.toString(temp.intValue())
            + getString(R.string.label_degrees);
    vh.tvMinTemp.setText(minTemp);

    temp = weatherData.main.temp_max - 272.15;
    String maxTemp =
        getResources().getString(R.string.label_max)
            + " "
            + Integer.toString(temp.intValue())
            + getString(R.string.label_degrees);
    vh.tvMaxTemp.setText(maxTemp);

    String humidity = Integer.toString(weatherData.main.humidity) + "%";
    vh.tvHumidity.setText(humidity);

    Float windSpeed = (weatherData.wind.speed / 1000) * 3600; // meter/sec to km/hr
    String windSpeedStr = Integer.toString(windSpeed.intValue()) + " " + "Kmph";
    vh.tvWindSpeed.setText(windSpeedStr);

    String visibility = Long.toString(weatherData.visibility / 1000) + "K"; // meter to Km
    vh.tvVisibility.setText(visibility);

    mBus.removeStickyEvent(weatherData);
  }