@Override
 public void onClick(View v) {
   if (v instanceof ImageView) {
     manageSelection((ImageView) v);
   } else if (v == actionbarButtonClear) {
     reset();
   } else if (v == tvHeader) {
     if (!tvDurations.getText().toString().equals(NO_SELECTION)
         && tempEndLeaveEndCalendar != null) {
       if (((leave.getTypeID() == Leave.LEAVETYPEVACATIONKEY
                   || leave.getTypeID() == Leave.LEAVETYPESICKKEY)
               && tempRemBalance >= 0)
           || !(leave.getTypeID() == Leave.LEAVETYPEVACATIONKEY
               || leave.getTypeID() == Leave.LEAVETYPESICKKEY)) submitDialog.show();
     } else
       Toast.makeText(getActivity(), "Please chose an updated date!", Toast.LENGTH_SHORT).show();
   } else if (v == actionbarButtonBack || v == actionbarTitle) {
     linearNavFragmentActivity.onBackPressed();
   }
 }
  @Override
  protected View createView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_leaveinput_dates, null);
    perWeekItems = new HashMap<Integer, HashMap<Integer, Item>>();
    nonworkingDays = new ArrayList<String>();
    leaveDays = new HashMap<String, Float>();

    lv = (ListView) view.findViewById(R.id.lists_lv);
    adapter = new ListAdapter(this);
    lv.setAdapter(adapter);

    tvHeader = (RelativeLayout) view.findViewById(R.id.fragment_leaveinput_dates_header);
    tvLeaveType = (TextView) view.findViewById(R.id.fragment_leaveinput_dates_headerleavetype);
    tvDurations = (TextView) view.findViewById(R.id.fragment_leaveinput_dates_headerdates);
    tvRemDays = (TextView) view.findViewById(R.id.fragment_leaveinput_dates_remdays);
    tvNumDays = (TextView) view.findViewById(R.id.fragment_leaveinput_dates_numdays);
    tvMonthYearHeader = (TextView) view.findViewById(R.id.fragment_leaveinput_monthyearheader);

    monthYearFormat = new SimpleDateFormat("MMMM yyyy");
    startCalendar = Calendar.getInstance();
    endCalendar = Calendar.getInstance();
    tvLeaveType.setText(leave.getTypeDescription());
    tvDurations.setText(NO_SELECTION);
    tvRemDays.setText("");
    tvNumDays.setText("");

    if (leave.getTypeID() == Leave.LEAVETYPEVACATIONKEY
        || leave.getTypeID() == Leave.LEAVETYPEUNPAIDKEY
        || leave.getTypeID() == Leave.LEAVETYPEBUSINESSTRIPKEY
        || leave.getTypeID() == Leave.LEAVETYPEBIRTHDAYKEY) {
      endCalendar.set(Calendar.YEAR, startCalendar.get(Calendar.YEAR));
      endCalendar.set(Calendar.MONTH, startCalendar.get(Calendar.MONTH) + 11);
      endCalendar.set(Calendar.DAY_OF_MONTH, 31);
    } else {
      // get 3 months of leave data to current date
      startCalendar.set(Calendar.MONTH, endCalendar.get(Calendar.MONTH) - 2);
      startCalendar.set(Calendar.DAY_OF_MONTH, 1);
    }

    linearNavFragmentActivity.startLoading();
    new Thread(new MyLeavesAndHolidaysUpdater()).start();

    dialogView = (RelativeLayout) inflater.inflate(R.layout.dialog_textinput, null);
    etNotes = (EditText) dialogView.findViewById(R.id.etexts_dialogs_textinput);
    ((TextView) dialogView.findViewById(R.id.tviews_dialogs_textinput)).setText("Notes");
    submitDialog =
        new AlertDialog.Builder(linearNavFragmentActivity)
            .setTitle("")
            .setView(dialogView)
            .setPositiveButton(
                "Submit",
                new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                    linearNavFragmentActivity.startLoading();
                    new SubmitNewLeaveRequest().start();
                  }
                })
            .setNegativeButton(
                "Close",
                new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                  }
                })
            .create();

    return view;
  }