コード例 #1
0
  private static void bindDatePickerValue(final View view, final Object target, final Field f2) {
    f2.setAccessible(true);
    final GregorianCalendar cal = (GregorianCalendar) GregorianCalendar.getInstance();

    DatePicker dp = (DatePicker) view;
    cal.set(Calendar.DAY_OF_MONTH, dp.getDayOfMonth());
    cal.set(Calendar.MONTH, dp.getMonth());
    cal.set(Calendar.YEAR, dp.getYear());
    try {
      f2.set(target, cal.getTime());
    } catch (Exception e) {
      Log.e("CleanDroid", e.getMessage());
    }

    ((DatePicker) view)
        .init(
            dp.getYear(),
            dp.getMonth(),
            dp.getDayOfMonth(),
            new OnDateChangedListener() {

              @Override
              public void onDateChanged(
                  DatePicker view, int year, int monthOfYear, int dayOfMonth) {
                cal.set(Calendar.DAY_OF_MONTH, dayOfMonth);
                cal.set(Calendar.MONTH, monthOfYear);
                cal.set(Calendar.YEAR, year);
                try {
                  f2.set(target, cal.getTime());
                } catch (Exception e) {
                  Log.e("CleanDroid", e.getMessage());
                }
              }
            });
  }
コード例 #2
0
        @Override
        public void onClick(View v) {
          switch (v.getId()) {
            case R.id.cancelButton:
              if (onCancelClickListener != null) onCancelClickListener.onClick();

              getDialog().dismiss();
              break;
            case R.id.enterButton:
              if (onEnterClickListener != null) {

                DatePicker datePicker_1 = (DatePicker) getView().findViewById(R.id.datePicker_1);
                DatePicker datePicker_2 = (DatePicker) getView().findViewById(R.id.datePicker_2);

                onEnterClickListener.onClick(
                    datePicker_1.getYear(),
                    datePicker_1.getMonth() + 1,
                    datePicker_1.getDayOfMonth(),
                    datePicker_2.getYear(),
                    datePicker_2.getMonth() + 1,
                    datePicker_2.getDayOfMonth());
              }
              getDialog().dismiss();
              break;
          }
        }
コード例 #3
0
 public static String makeShortDate(DatePicker datePicker) {
   int month = datePicker.getMonth() + 1;
   String theDate =
       String.valueOf(datePicker.getYear())
           + "-"
           + (month < 10 ? "0" + month : String.valueOf(month))
           + "-"
           + (datePicker.getDayOfMonth() < 10
               ? "0" + datePicker.getDayOfMonth()
               : String.valueOf(datePicker.getDayOfMonth()));
   return theDate;
 }
コード例 #4
0
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    expenseData = new ExpenseContentProvider();

    // wire up interface
    dateToday = (DatePicker) findViewById(R.id.dateToday);
    spinnerExpenseType = (Spinner) findViewById(R.id.spinnerExpenseType);
    layoutNewType = (LinearLayout) findViewById(R.id.layoutNewType);
    layoutExpenseType = (LinearLayout) findViewById(R.id.layoutExpenseType);
    txtAmount = (EditText) findViewById(R.id.txtAmount);
    txtAddType = (EditText) findViewById(R.id.txtAddType);
    lblTodaysSpendValue = (TextView) findViewById(R.id.lblTodaysSpendValue);

    Button btnAddType = (Button) findViewById(R.id.btnAddType);
    Button btnSaveNewType = (Button) findViewById(R.id.btnSaveNewType);
    Button btnSave = (Button) findViewById(R.id.btnSave);

    btnAddType.setOnClickListener(lAddTypeClicked);
    btnSaveNewType.setOnClickListener(lSaveNewTypeClicked);
    btnSave.setOnClickListener(lSaveClicked);

    dateToday.init(
        dateToday.getYear(), dateToday.getMonth(), dateToday.getDayOfMonth(), lDateTodayChanged);

    // set up spinner
    bindExpenseTypeSpinner();

    // set up todays spend
    bindTodaysSpend();
  }
コード例 #5
0
  public void onDateSet(DatePicker view, int year, int month, int day) {

    // String dates = date.getText().toString();

    GregorianCalendar GC =
        new GregorianCalendar(view.getYear(), view.getMonth(), view.getDayOfMonth());

    String newDate =
        GC.getDisplayName(GregorianCalendar.DAY_OF_WEEK, GregorianCalendar.SHORT, Locale.UK)
            + " "
            + GC.get(GregorianCalendar.DAY_OF_MONTH)
            + " "
            + GC.getDisplayName(GregorianCalendar.MONTH, GregorianCalendar.SHORT, Locale.UK);

    if (this.button.getId() == R.id.get_check_in) {
      TextView date1 = (TextView) getActivity().findViewById(R.id.startDate1);
      TextView date2 = (TextView) getActivity().findViewById(R.id.startDate2);
      String S1 = newDate;
      String S2 = Integer.toString(GC.get(GregorianCalendar.YEAR));
      date1.setText(S1);
      date2.setText(S2);
    }
    if (this.button.getId() == R.id.get_check_out) {
      TextView date1 = (TextView) getActivity().findViewById(R.id.endDate1);
      TextView date2 = (TextView) getActivity().findViewById(R.id.endDate2);
      String S1 = newDate;
      String S2 = Integer.toString(GC.get(GregorianCalendar.YEAR));
      date1.setText(S1);
      date2.setText(S2);
    }
  }
コード例 #6
0
ファイル: AddSubTask.java プロジェクト: sadanandu/BuJo
  public void AddSubTaskToDB(View view) {
    // Intent intent = new Intent(this, Today.class);
    if (SUB_TASK_CREATED == true) {
      String name = taskName.getText().toString();
      String desc = taskDescription.getText().toString();
      long milliseconds = 0;
      year = taskDatePicker.getYear();
      month = taskDatePicker.getMonth() + 1;
      day = taskDatePicker.getDayOfMonth();
      hour = taskTimePicker.getCurrentHour();
      minute = taskTimePicker.getCurrentMinute();
      try {
        String dateToParse = day + "-" + month + "-" + year + " " + hour + ":" + minute;
        SimpleDateFormat dateFormatter = new SimpleDateFormat("d-M-yyyy hh:mm");
        Date date = dateFormatter.parse(dateToParse);
        milliseconds = date.getTime();
      } catch (ParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      } // You will need try/catch around this

      BujoDbHandler taskHandler = new BujoDbHandler(view.getContext());
      currentSubTask = new SubTask(name, desc, currentTask.get_id(), milliseconds);
      taskHandler.addSubTask(currentSubTask);
    }
  }
コード例 #7
0
  private static void bindTimePickerValue(final View view, final Object target, final Field f2) {

    f2.setAccessible(true);
    final GregorianCalendar cal = (GregorianCalendar) GregorianCalendar.getInstance();

    DatePicker dp = (DatePicker) view;
    cal.set(Calendar.DAY_OF_MONTH, dp.getDayOfMonth());
    cal.set(Calendar.MONTH, dp.getMonth());
    cal.set(Calendar.YEAR, dp.getYear());
    try {
      f2.set(target, cal.getTime());
    } catch (Exception e) {
      Log.e("CleanDroid", e.getMessage(), e);
    }

    ((TimePicker) view)
        .setOnTimeChangedListener(
            new OnTimeChangedListener() {

              @Override
              public void onTimeChanged(TimePicker view, int hourOfDay, int minute) {
                cal.set(Calendar.HOUR_OF_DAY, hourOfDay);
                cal.set(Calendar.HOUR, hourOfDay);
                cal.set(Calendar.MINUTE, minute);
                try {
                  f2.set(target, cal.getTime());
                } catch (Exception e) {
                  Log.e("CleanDroid", e.getMessage(), e);
                }
              }
            });
  }
コード例 #8
0
ファイル: AddLentOut.java プロジェクト: mikebal/MyVinyls
 private String getDateFromDatePicker(DatePicker datePicker) {
   String date;
   date = String.valueOf(datePicker.getMonth() + 1) + "/";
   date += String.valueOf(datePicker.getDayOfMonth()) + "/";
   date += String.valueOf(datePicker.getYear());
   return date;
 }
コード例 #9
0
ファイル: HomeActivity.java プロジェクト: sajit/ihack2012
  public void findParking(final View aButton) {
    DatePicker datePicker = (DatePicker) findViewById(R.id.date_picker_id);

    TimePicker timepicker = (TimePicker) findViewById(R.id.timePicker1);

    EditText addressText = (EditText) findViewById(R.id.editText1);
    String address = addressText.getText().toString();
    EditText durationText = (EditText) findViewById(R.id.editText2);
    String duration = durationText.getText().toString();
    Intent findParkingIntent = new Intent(this, FindParking.class);
    findParkingIntent.putExtra("address", address);
    findParkingIntent.putExtra("duration", Integer.valueOf(duration));
    // DateTimeFormatter parser1 =
    //    DateTimeFormat.forPattern("dd/MMM/yyyy:HH:mm:ss Z");
    // String dayOfMonthString = (datePicker.getDayOfMonth()<10)?"0"
    String dateAsString =
        datePicker.getYear()
            + "-"
            + datePicker.getMonth()
            + 1
            + "-"
            + datePicker.getDayOfMonth()
            + "T"
            + timepicker.getCurrentHour()
            + ":"
            + timepicker.getCurrentMinute()
            + "Z";
    //		Date date = new Date(datePicker.getYear() - 1900, datePicker.getMonth(),
    // datePicker.getDayOfMonth(),
    //				timepicker.getCurrentHour(),timepicker.getCurrentMinute(),0);
    findParkingIntent.putExtra("date", dateAsString);
    Log.i(TAG, dateAsString);
    startActivity(findParkingIntent);
  }
コード例 #10
0
  private ContentValues getContent() {
    ContentValues content = new ContentValues();
    EditText aux;

    Long id = getId();
    if (id != -1) {
      content.put("_id", id);
    }

    // date
    DatePicker dp = (DatePicker) findViewById(R.id.date);
    GregorianCalendar date = new GregorianCalendar(dp.getYear(), dp.getMonth(), dp.getDayOfMonth());
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    content.put("date", sdf.format(date.getTime()));

    // km
    aux = (EditText) findViewById(R.id.km);
    content.put("odometer", Float.parseFloat(aux.getText().toString()));

    // liters
    aux = (EditText) findViewById(R.id.liters);
    content.put("liters", Float.parseFloat(aux.getText().toString()));

    // type
    RadioGroup aux2 = (RadioGroup) findViewById(R.id.type);
    RadioButton aux3 = (RadioButton) findViewById(aux2.getCheckedRadioButtonId());
    content.put("fuel", aux3.getText().toString());

    return content;
  }
コード例 #11
0
  @Override
  protected void onDialogClosed(boolean positiveResult) {
    // When the user selects "OK", persist the new value

    if (positiveResult) {
      int day = picker.getDayOfMonth();
      int month = picker.getMonth();
      int year = picker.getYear();

      String date = "";
      if (day < 10) {
        date += "0" + day + "/";
      } else {
        date += day + "/";
      }

      if (month < 10) {
        date += "0" + month + "/";
      } else {
        date += month + "/";
      }

      date += "" + year;

      persistString(date);
      setSummary(date);
    }
  }
コード例 #12
0
ファイル: PromptInput.java プロジェクト: neojski/gecko-dev
 @Override
 public Object getValue() {
   if (Versions.preHC && mType.equals("date")) {
     // We can't use the custom DateTimePicker with a sdk older than 11.
     // Fallback on the native DatePicker.
     DatePicker dp = (DatePicker) mView;
     GregorianCalendar calendar =
         new GregorianCalendar(dp.getYear(), dp.getMonth(), dp.getDayOfMonth());
     return formatDateString("yyyy-MM-dd", calendar);
   } else if (mType.equals("time")) {
     TimePicker tp = (TimePicker) mView;
     GregorianCalendar calendar =
         new GregorianCalendar(0, 0, 0, tp.getCurrentHour(), tp.getCurrentMinute());
     return formatDateString("HH:mm", calendar);
   } else {
     DateTimePicker dp = (DateTimePicker) mView;
     GregorianCalendar calendar = new GregorianCalendar();
     calendar.setTimeInMillis(dp.getTimeInMillis());
     if (mType.equals("date")) {
       return formatDateString("yyyy-MM-dd", calendar);
     } else if (mType.equals("week")) {
       return formatDateString("yyyy-'W'ww", calendar);
     } else if (mType.equals("datetime-local")) {
       return formatDateString("yyyy-MM-dd HH:mm", calendar);
     } else if (mType.equals("datetime")) {
       calendar.set(GregorianCalendar.ZONE_OFFSET, 0);
       calendar.setTimeInMillis(dp.getTimeInMillis());
       return formatDateString("yyyy-MM-dd HH:mm", calendar);
     } else if (mType.equals("month")) {
       return formatDateString("yyyy-MM", calendar);
     }
   }
   return super.getValue();
 }
コード例 #13
0
ファイル: MainActivity.java プロジェクト: chrgro/TowLog
  // Refresh the view when going back
  protected void onResume() {
    super.onResume();
    Log.e("MAIN", "onResume() called");

    today = Calendar.getInstance();

    // Day log loader, check if we already have a log for the current date
    dayLogFileNameSuffix =
        String.valueOf(datepicker.getYear())
            + "_"
            + String.valueOf(datepicker.getMonth() + 1)
            + "_"
            + String.valueOf(datepicker.getDayOfMonth());
    if (loadDayLog()) {
      found_daylog = true;
      resumeDayButton.setVisibility(View.VISIBLE);

      // Jump straight to daylog if we are currently on the shown date from a clean startup
      int day = datepicker.getDayOfMonth();
      int month = datepicker.getMonth();
      int year = datepicker.getYear();
      Calendar date_picked = Calendar.getInstance();
      date_picked.set(year, month, day);

      if (autoLoadLog
          && date_picked.get(Calendar.YEAR) == today.get(Calendar.YEAR)
          && date_picked.get(Calendar.DAY_OF_YEAR) == today.get(Calendar.DAY_OF_YEAR)) {
        resumeDayButton.callOnClick();
      }
    } else {
      found_daylog = false;
      resumeDayButton.setVisibility(View.INVISIBLE);
    }

    // Subsequent resumes will autoload logs again
    autoLoadLog = true;

    // Reload the contact list
    contactlistmanager = new ContactListManager(this);
    towPilotNameIn.setAdapter(contactlistmanager.getContactNameListAdapter());

    // Set the daylog dialog
    daylogdialog = getPrevLogsAlertDialog();

    // To avoid focus going to the text fields
    datepicker.requestFocus();
  }
コード例 #14
0
 public void onClick(View arg0) {
   _init.setYear(_datePicker.getYear() - 1900);
   _init.setMonth(_datePicker.getMonth());
   _init.setDate(_datePicker.getDayOfMonth());
   _init.setHours(_timePicker.getCurrentHour());
   _init.setMinutes(_timePicker.getCurrentMinute());
   sendResult(_callback, _init, _opaque);
 }
コード例 #15
0
  @UiThreadTest
  public void testAccessDate() {
    DatePicker datePicker = createDatePicker();

    /* The month display uses 1-12 but our internal state stores it
     * 0-11 so add one when setting the display.
     */
    MockOnDateChangedListener onDateChangedListener = new MockOnDateChangedListener();
    datePicker.init(2000, 10, 15, onDateChangedListener);
    assertEquals(2000, datePicker.getYear());
    assertEquals(10, datePicker.getMonth());
    assertEquals(15, datePicker.getDayOfMonth());

    datePicker.updateDate(1989, 9, 19);
    assertEquals(1989, datePicker.getYear());
    assertEquals(9, datePicker.getMonth());
    assertEquals(19, datePicker.getDayOfMonth());
  }
コード例 #16
0
 /**
  * Called whenever the user clicks on a button. Invokes {@link #onDateChanged(DatePicker, int,
  * int, int)} and {@link #onDialogClosed(boolean)}. Be sure to call the super when overriding.
  */
 @SuppressWarnings("deprecation")
 @Override
 public void onClick(DialogInterface dialog, int which) {
   super.onClick(dialog, which);
   datePicker.clearFocus();
   onDateChanged(
       datePicker, datePicker.getYear(), datePicker.getMonth(), datePicker.getDayOfMonth());
   onDialogClosed(which == DialogInterface.BUTTON1); // OK?
 }
コード例 #17
0
  // gets the user entered date from the DatePicker
  public int[] getDateTimeFromPickers() {
    DatePicker dp = (DatePicker) findViewById(R.id.agenda_edit_datePicker);

    int month = dp.getMonth();
    int day = dp.getDayOfMonth();
    int year = dp.getYear();

    return new int[] {month, day, year};
  }
コード例 #18
0
 /** {@inheritDoc} */
 @Override
 public String getAnswer() {
   if (!isViewActive()) return answer;
   else {
     dateAnswer = new Date(dp.getYear(), dp.getMonth(), dp.getDayOfMonth());
     SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
     return sdf.format(dateAnswer);
   }
 }
コード例 #19
0
ファイル: GDateU.java プロジェクト: hiroozawa/GINROB-AS
  public static Calendar createCalendarFromDatePicker(DatePicker dp) {

    Calendar cal = Calendar.getInstance();
    cal.set(Calendar.DAY_OF_MONTH, dp.getDayOfMonth());
    cal.set(Calendar.MONTH, dp.getMonth());
    cal.set(Calendar.YEAR, dp.getYear());

    return cal;
  }
コード例 #20
0
  public void onDateChanged(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
    // 获得日历实例
    Calendar calendar = Calendar.getInstance();

    calendar.set(datePicker.getYear(), datePicker.getMonth(), datePicker.getDayOfMonth());
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

    dateTime = sdf.format(calendar.getTime());
    ad.setTitle(dateTime);
  }
コード例 #21
0
  private void saveSelectedDateTime() {

    // save beg date
    mBegDateTime.setYear(datetime_picker_date.getYear());
    mBegDateTime.setMonth(datetime_picker_date.getMonth());
    mBegDateTime.setDay(datetime_picker_date.getDayOfMonth());

    // save end date
    mEndDateTime.setYear(datetime_picker_date.getYear());
    mEndDateTime.setMonth(datetime_picker_date.getMonth());
    mEndDateTime.setDay(datetime_picker_date.getDayOfMonth());

    switch (mCurrButton.getId()) {
      case R.id.path_begtime:
        // // date
        // mBegDateTime.setYear(datetime_picker_date.getYear());
        // mBegDateTime.setMonth(datetime_picker_date.getMonth());
        // mBegDateTime.setDay(datetime_picker_date.getDayOfMonth());
        // time
        mBegDateTime.setHours(datetime_picker_time.getCurrentHour());
        mBegDateTime.setMinutes(datetime_picker_time.getCurrentMinute());
        // // set
        // mCurrButton.setText(mBegDateTime.toString(mDateTimeFormat));
        break;
      case R.id.path_endtime:
        // // date
        // mEndDateTime.setYear(datetime_picker_date.getYear());
        // mEndDateTime.setMonth(datetime_picker_date.getMonth());
        // mEndDateTime.setDay(datetime_picker_date.getDayOfMonth());
        // time
        mEndDateTime.setHours(datetime_picker_time.getCurrentHour());
        mEndDateTime.setMinutes(datetime_picker_time.getCurrentMinute());
        // // set
        // mCurrButton.setText(mEndDateTime.toString(mDateTimeFormat));
        break;
    }

    // set
    mBtnBegTime.setText(mBegDateTime.toString(mDateTimeFormat));

    // set
    mBtnEndTime.setText(mEndDateTime.toString(mDateTimeFormat));
  }
コード例 #22
0
  public static long getTimeMsFromDatePicker(DatePicker datePicker, boolean addOneDay) {
    Calendar calendar = Calendar.getInstance();
    calendar.set(Calendar.YEAR, datePicker.getYear());
    calendar.set(Calendar.MONTH, datePicker.getMonth());
    calendar.set(Calendar.DATE, datePicker.getDayOfMonth());
    clearCalendarValuesUnder(calendar, Calendar.DATE);
    if (addOneDay) calendar.add(Calendar.DATE, 1);

    return calendar.getTimeInMillis();
  }
コード例 #23
0
ファイル: BaseHelper.java プロジェクト: final60/geoalertapp
  public static java.util.Date getDateFromDatePicker(DatePicker datePicker) {
    int day = datePicker.getDayOfMonth();
    int month = datePicker.getMonth();
    int year = datePicker.getYear();

    Calendar calendar = Calendar.getInstance();
    calendar.set(year, month, day);

    return calendar.getTime();
  }
コード例 #24
0
  private String extractDatePickerDateString(DatePicker datePicker) {
    final char separator = '-';

    return new StringBuilder()
        .append(datePicker.getYear())
        .append(separator)
        .append(datePicker.getMonth() + 1) // Why is this off by one?
        .append(separator)
        .append(datePicker.getDayOfMonth())
        .toString();
  }
コード例 #25
0
 @Override
 public void onDateChanged(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
   Calendar calendar = Calendar.getInstance();
   calendar.set(
       datePicker.getYear(),
       datePicker.getMonth(),
       datePicker.getDayOfMonth(),
       timePicker.getCurrentHour(),
       timePicker.getCurrentMinute());
   nowDateTime = formatDateTime(calendar.getTime(), DF_YYYY_MM_DD_HH_MM_SS);
   dialog.setTitle(nowDateTime);
 }
コード例 #26
0
  /** Answer to search button, go to next activity to do a search */
  public void searchPatient() {
    Intent intent = new Intent(this, FoundPatientsActivity.class);

    // Passing data to next activity
    EditText editFirstName = (EditText) findViewById(R.id.edit_first_name);
    if (editFirstName.getText().length() == 0) {
      intent.putExtra(EXTRA_FIRST_NAME, "");
    } else {
      String first_name = editFirstName.getText().toString();
      intent.putExtra(EXTRA_FIRST_NAME, first_name);
    }

    EditText editLastName = (EditText) findViewById(R.id.edit_last_name);
    if (editLastName.getText().length() == 0) {
      Toast.makeText(this, R.string.invalidFamilyName, Toast.LENGTH_LONG).show();
      return;
    } else {
      String last_name = editLastName.getText().toString();
      intent.putExtra(EXTRA_LAST_NAME, last_name);
    }

    // Check value of Gender Radio Group
    RadioButton maleButton = (RadioButton) findViewById(R.id.radio0);
    RadioButton femaleButton = (RadioButton) findViewById(R.id.radio1);

    if (maleButton.isChecked()) {
      intent.putExtra(EXTRA_GENDER, "t");
    } else if (femaleButton.isChecked()) {
      intent.putExtra(EXTRA_GENDER, "f");
    } else {
      intent.putExtra(EXTRA_GENDER, "");
    }

    if (SEND_DATE) {
      // Getting date of birth
      DatePicker birth = (DatePicker) findViewById(R.id.datePicker);
      String born_on =
          DateUtils.dateString(birth.getDayOfMonth(), birth.getMonth(), birth.getYear());

      intent.putExtra(EXTRA_BORN_ON, born_on);
    } else {
      intent.putExtra(EXTRA_BORN_ON, "");
    }

    intent.putExtra(EXTRA_VILLAGE_ID, village_id);

    // Avoid the Activity finish when back key is pressed in next Activity
    intent.putExtra(EXTRA_FINISH_ACTIVITY, false);

    // Starting new activity and hoping a result for finish by itself
    startActivityForResult(intent, 0);
  }
コード例 #27
0
  @UiThreadTest
  public void testUpdateDate() {
    DatePicker datePicker = createDatePicker();

    // Test normal input values
    /* The month display uses 1-12 but our internal state stores it
     * 0-11 so add one when setting the display.
     */
    datePicker.updateDate(1989, 9, 19);
    assertEquals(1989, datePicker.getYear());
    assertEquals(9, datePicker.getMonth());
    assertEquals(19, datePicker.getDayOfMonth());
  }
コード例 #28
0
 /**
  * Fonction événementielle appelée en cas de changement de date : mise à jour de l'affichage de la
  * qte
  */
 private void dat_clic() {
   final DatePicker uneDate = (DatePicker) findViewById(R.id.datRepas);
   uneDate.init(
       uneDate.getYear(),
       uneDate.getMonth(),
       uneDate.getDayOfMonth(),
       new DatePicker.OnDateChangedListener() {
         @Override
         public void onDateChanged(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
           valoriserProprietes();
         }
       });
 }
コード例 #29
0
  public void onDateChanged(DatePicker picker, int year, int monthOfYear, int dayOfMonth) {
    // TIMOB-19192 There seems to be a bug that calls onDateChanged twice on Android 5.0.X.
    // This checks if the previous date and changed date is the same before firing any changes.
    // If the dates are the same, nothing has changed, hence it is returned.
    if ((picker.getYear() == currentYear)
        && (picker.getMonth() == currentMonth)
        && (picker.getDayOfMonth() == currentDayOfMonth)
        && (Build.VERSION.SDK_INT == Build.VERSION_CODES.LOLLIPOP)) {
      return;
    } else {
      currentYear = picker.getYear();
      currentMonth = picker.getMonth();
      currentDayOfMonth = picker.getDayOfMonth();
    }

    Calendar targetCalendar = Calendar.getInstance();
    targetCalendar.set(Calendar.YEAR, year);
    targetCalendar.set(Calendar.MONTH, monthOfYear);
    targetCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
    targetCalendar.set(Calendar.HOUR_OF_DAY, 0);
    targetCalendar.set(Calendar.MINUTE, 0);
    targetCalendar.set(Calendar.SECOND, 0);
    targetCalendar.set(Calendar.MILLISECOND, 0);

    if ((null != minDate) && (targetCalendar.getTime().before(minDate))) {
      targetCalendar.setTime(minDate);
      setValue(minDate.getTime(), true);
    }
    if ((null != maxDate) && (targetCalendar.getTime().after(maxDate))) {
      targetCalendar.setTime(maxDate);
      setValue(maxDate.getTime(), true);
    }
    if (!suppressChangeEvent) {
      KrollDict data = new KrollDict();
      data.put("value", targetCalendar.getTime());
      fireEvent("change", data);
    }
    proxy.setProperty("value", targetCalendar.getTime());
  }
コード例 #30
0
 /** Sur le changement de date : mise a jour de l'affichage de la qte */
 private void dat_clic() {
   final DatePicker uneDate = (DatePicker) findViewById(R.id.datNuitee); // recuération de la vue
   uneDate.init(
       uneDate.getYear(),
       uneDate.getMonth(),
       uneDate.getDayOfMonth(),
       new OnDateChangedListener() {
         @Override
         public void onDateChanged(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
           valoriseProprietes(); // mise a jour de l'affichage de la qte en fonction de la date
         }
       });
 }