Пример #1
0
 private void setMarginParams(int margin, TextView textView) {
   textView.setPadding(
       textView.getPaddingLeft(), textView.getPaddingTop(), margin, textView.getPaddingBottom());
 }
Пример #2
0
  private void updateUI(final int position) {
    if (!weatherForecast.isSuccessed() || weatherForecast == WeatherForecast.NULL) return;

    swipeIndicatorPresenter.setCurrentActivePosition(position);
    int size = weatherForecast.getForecastList().size();

    if (position == 0) ibPrevious.setAlpha(128);
    else if (position == size - 1) ibNext.setAlpha(128);
    else {
      ibPrevious.setAlpha(255);
      ibNext.setAlpha(255);
    }

    WeatherModel model = weatherForecast.getForecastList().get(position);

    DateUtils utils = new DateUtils();
    String nameOfDay = utils.getDayName(model.getDate());

    tvDate.setText(nameOfDay);

    int currentTemp = Integer.parseInt(model.getMaxTemperature());

    if (currentTemp < 0) tvMinus.setVisibility(View.VISIBLE);
    else {
      int invis = mConfiguration.isTablet() ? View.GONE : View.INVISIBLE;
      tvMinus.setVisibility(invis);
    }
    currentTemp = Math.abs(currentTemp);
    // int margin = resolveMargin(currentTemp);

    tvCurrentTemp.setText("" + currentTemp);

    // setMarginParams(margin, tvCurrentTemp);

    if (mConfiguration.isTablet()) {
      String locationName = mConfiguration.getLocationName();
      locationName = (locationName == null) ? "" : locationName;
      tvLocation.setText(locationName);
    }

    tvNightTemp.setText(model.getMinTemperature());
    if (position == 0) {
      tvHumidity.setText(model.getHumidity() + " %");
      ivHumidity.setImageResource(getHumidityResource((model.getHumidity())));
    } else {
      tvHumidity.setText(model.getPrecipitation());
      ivHumidity.setImageResource(R.drawable.precipmm);
    }

    tvWindSpeed.setText(model.getWindSpeed());
    tvWindDirection.setText(model.getWindDirection().getDisplayName());
    ivLunarState.setImageResource(
        ResourcesCodeUtils.getLunarStateImageResource(model.getLunarState()));

    WeatherState weatherState = model.getState();
    tvWeatherDescription.setText(weatherState.getDisplayName());
    int backgroundColor = ResourcesCodeUtils.getWeatherBackgroundColor(weatherState);

    OWAnimationUtils.rotate(ivWindDirection, Float.parseFloat(model.getWindDegree()) + 180);
    weatherContainer.setBackgroundColor(getResources().getColor(backgroundColor));
  }