Exemplo n.º 1
0
  public void setCurrentTime() {

    LocalTime nowHours = new LocalTime();
    LocalDate nowDate = new LocalDate();

    try {
      // TODO - Fetch the preference for this boolean
      typeHour = mPrefs.getTypeHourPlan();
      boolean biHour = (new TypeHourEnum(typeHour)).isBiHour();

      Period s = edp.checkCurrentPeriod(nowHours, nowDate, selectedPlan, biHour);
      PricePlan price = s.getPrice();

      if (biHour == false) {
        makeAllVisible();
        if (price.isVazio()) {
          highlight(tvVazio);
        } else if (price.isCheia()) {
          highlight(tvCheia);
        } else if (price.isPonta()) {
          highlight(tvPonta);
        }
      } else if (biHour == true) {
        erase(tvCheia);
        if (price.isVazio()) {
          highlight(tvVazio);
        } else {
          highlight(tvPonta);
        }
      }

      if (selectedPlan.equals("BTN Ciclo Semanal")) {
        spinner.setSelection(0);
      } else {
        spinner.setSelection(1);
      }

      int startHour = s.getHours().getStartHour();
      int startMinute = s.getHours().getStartMinute();
      int endHour = s.getHours().getEndHour();
      int endMinute = s.getHours().getEndMinute();

      tvStart.setText(String.format(Locale.US, "%02dh%02dm", startHour, startMinute));
      tvEnd.setText(String.format(Locale.US, "%02dh%02dm", endHour, endMinute));
      Log.e(Constants.LOG, String.format(Locale.US, "Period: %s", s.toString()));

    } catch (DayWithoutPlanException e) {
      Log.e(Constants.LOG, e.getMessage());
    } catch (PlanNotFoundException e) {
      Log.e(Constants.LOG, e.getMessage());
    }
  }