コード例 #1
1
  private void InitState() {
    // title
    String sSubTitle = utils.GetResStr(R.string.titleDefaultAppointment);

    // date values
    dateStart = Calendar.getInstance();
    dateEndOn = Calendar.getInstance();

    dataRow.SetDuration(prefs.iMinutesDuration);

    // INSERT MODE
    if (GetStartMode() == StartMode.NEW) {
      sSubTitle = utils.GetResStr(R.string.titleNewAppointment);
      btnDelete.setVisibility(View.INVISIBLE);

      // initialize data
      SetStartDateByAgendaView(dateStart);
      updateStartDateTimeForNewAppointment(dateStart);
      SetStartTimeForDayAgendaView(dateStart);

      chkAllDay.setChecked(false);
      chkAlarm.setChecked(true);

      // repeat data
      iRepeatType = 0; // none
      iRepeatEvery = 1;
      dateEndOn.setTimeInMillis(0); // no end date
    }

    // EDIT MODE
    if (GetStartMode() == StartMode.EDIT) {
      sSubTitle = utils.GetResStr(R.string.titleEditAppointment);

      dateStart.setTimeInMillis(dataRow.GetStartDate().getTimeInMillis());

      btnDelete.setVisibility(View.VISIBLE);
      edSubject.setText(dataRow.GetSubject());
      chkAllDay.setChecked(dataRow.GetAllDay());
      chkAlarm.setChecked(dataRow.GetAlarm());

      // repeat data
      iRepeatType = dataRow.GetRepeat().GetRepeatTypeAsInt();
      iRepeatEvery = dataRow.GetRepeat().GetEvery();
      dateEndOn.setTimeInMillis(dataRow.GetRepeat().GetEndOnDate().getTimeInMillis());
    }

    restoreStateFromFreezeIfRequired();

    SetActivityTitle(sSubTitle);
    UpdateStartDateTimeView();

    UpdateRepeatInfo();

    // set focus to subject
    edSubject.requestFocus();
    if (GetStartMode() == StartMode.EDIT) edSubject.setSelection(edSubject.length());
  }
コード例 #2
1
 @Override
 protected void restoreStateFromFreeze() {
   edSubject.setText(freeze.getString("subject"));
   chkAlarm.setChecked(freeze.getBoolean("alarm"));
   dateStart.setTimeInMillis(freeze.getLong("dateStart"));
   chkAllDay.setChecked(freeze.getBoolean("allday"));
   iRepeatType = freeze.getInt("repeatType");
   iRepeatEvery = freeze.getInt("repeatEvery");
   dateEndOn.setTimeInMillis(freeze.getLong("dateEndOn"));
 }
コード例 #3
1
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    Bundle extras = CommonActivity.getIntentExtras(data);
    if (extras != null) {

      // check for repeat update
      if (ActivityAppointmentRepeat.GetActivityResult(requestCode, resultCode, extras)) {
        iRepeatType = ActivityAppointmentRepeat.getExtraRepeatType(extras);
        iRepeatEvery = ActivityAppointmentRepeat.getExtraRepeatEvery(extras);
        dateEndOn.setTimeInMillis(ActivityAppointmentRepeat.getExtraRepeatEndOnDate(extras));
        UpdateRepeatInfo();
        return;
      }

      // check for date widget edit request code
      if (requestCode == DateWidget.SELECT_DATE_REQUEST) {
        final long lDate =
            DateWidget.GetSelectedDateOnActivityResult(requestCode, resultCode, extras, dateStart);
        if (lDate != -1) {
          UpdateStartDateTimeView();
          return;
        }
      }

      // check for time widget edit request code
      if ((requestCode == TimeWidget.SELECT_TIME_REQUEST) && (resultCode == RESULT_OK)) {
        final int iHour =
            TimeWidget.GetSelectedTimeHourOnActivityResult(requestCode, resultCode, extras);
        final int iMinute =
            TimeWidget.GetSelectedTimeMinuteOnActivityResult(requestCode, resultCode, extras);
        dateStart.set(Calendar.HOUR_OF_DAY, iHour);
        dateStart.set(Calendar.MINUTE, iMinute);
        chkAllDay.setChecked(false);
        UpdateStartDateTimeView();
        return;
      }

      // get KeyboardWidget result
      if ((requestCode == KeyboardWidget.EDIT_TEXT_REQUEST) && (resultCode == RESULT_OK)) {
        String sText = KeyboardWidget.GetTextOnActivityResult(requestCode, resultCode, extras);
        edSubject.setText(sText);
        return;
      }
    }
  }