public PreferencesRegistry putTime(TimePicker timePicker) {
   getEditor()
       .putInt("hour", timePicker.getCurrentHour())
       .putInt("minute", timePicker.getCurrentMinute())
       .commit();
   return this;
 }
示例#2
0
  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);
    }
  }
示例#3
0
  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);
  }
  @Override
  protected void onBindDialogView(View v) {
    super.onBindDialogView(v);

    picker.setCurrentHour(lastHour);
    picker.setCurrentMinute(lastMinute);
  }
 public LocalTime getTime() {
   if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
     return new LocalTime(mTimePicker.getHour(), mTimePicker.getMinute());
   } else {
     return new LocalTime(mTimePicker.getCurrentHour(), mTimePicker.getCurrentMinute());
   }
 }
示例#6
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.d(TAG, "onCreate Started");

    setContentView(R.layout.alarm_controller);

    prefs = PreferenceManager.getDefaultSharedPreferences(this);

    tpAlarm = (TimePicker) findViewById(R.id.tpAlarm);
    chkSnooze = (CheckBox) findViewById(R.id.chkSnooze);
    etxtSnoozeMin = (EditText) findViewById(R.id.etxtSnoozeMin);
    Button button = (Button) findViewById(R.id.btnSetAlarm);
    button.setOnClickListener(setAlarmListener);

    btnSetTone = (Button) findViewById(R.id.btnSetTone);
    btnSetTone.setOnClickListener(setTone);

    tpAlarm.setCurrentHour(prefs.getInt(M_HOUR, 0));
    tpAlarm.setCurrentMinute(prefs.getInt(M_MINT, 0));
    chkSnooze.setChecked(prefs.getBoolean(M_SNOOZE, false));
    etxtSnoozeMin.setText(prefs.getString(SNOOZE_T, "0"));

    Locale loc = new Locale("en");
    Log.i(TAG, Arrays.toString(loc.getAvailableLocales()));
  }
示例#7
0
  @Override
  protected void onResume() {
    Log.d(TAG, "onResume");
    super.onResume();

    tpAlarm.setCurrentHour(prefs.getInt(M_HOUR, 0));
    tpAlarm.setCurrentMinute(prefs.getInt(M_MINT, 0));
    chkSnooze.setChecked(prefs.getBoolean(M_SNOOZE, false));
    etxtSnoozeMin.setText(prefs.getString(SNOOZE_T, "0"));

    if (prefs.getString(TONE, null) != null) {
      String tone = prefs.getString(TONE, null);
      File f = new File("" + tone);
      btnSetTone.setText("Tone " + f.getName());
    } else btnSetTone.setText(getString(R.string.btn_SetAlarmTone));

    if (prefs.getBoolean(FIRST_LAUNCH, true)) {
      Intent checkIntent = new Intent();
      checkIntent.setAction(TextToSpeech.Engine.ACTION_CHECK_TTS_DATA);
      startActivityForResult(checkIntent, MY_DATA_CHECK_CODE);

      SharedPreferences.Editor editor = prefs.edit();

      editor.putBoolean(FIRST_LAUNCH, false);
      editor.commit();
    }
  }
示例#8
0
 @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();
 }
  private void showPickerDialog(String title, String strDatetime) {
    if (mDialog == null) {
      mDialog = new PopupWindowDialog(mPathActivity);
      mDialog.setContentView(R.layout.datetime_picker);
    }

    View view = mDialog.getContentView();
    {
      view.findViewById(R.id.datetime_picker_close).setOnClickListener(this);
      view.findViewById(R.id.datetime_picker_cancel).setOnClickListener(this);
      view.findViewById(R.id.datetime_picker_submit).setOnClickListener(this);
    }

    TextView lblTitle = (TextView) view.findViewById(R.id.datetime_picker_title);
    datetime_picker_date = (DatePicker) view.findViewById(R.id.datetime_picker_date);
    datetime_picker_time = (TimePicker) view.findViewById(R.id.datetime_picker_time);
    lblTitle.setText(title);

    DateTime datetime = DateTime.from(strDatetime, "yyyy-MM-dd HH:mm");

    datetime_picker_date.init(
        datetime.getYear(), datetime.getMonth(), datetime.getDay(), null); // date.getDay()

    // pkrTime.setIs24HourView(true);// 24小时制
    datetime_picker_time.setCurrentHour(datetime.getHours()); // 设置当前小时。
    datetime_picker_time.setCurrentMinute(datetime.getMinutes()); // 当前分钟
    // datetime_picker_time.setOnTimeChangedListener(null);
    mDialog.show();
  }
  private void updateModelFromLayout() {
    alarmDetails.timeMinute = timePicker.getCurrentMinute().intValue();
    alarmDetails.timeHour = timePicker.getCurrentHour().intValue();
    /*
    alarmDetails.name = edtName.getText().toString();
    alarmDetails.repeatWeekly = chkWeekly.isChecked();
    alarmDetails.setRepeatingDay(AlarmModel.SUNDAY, chkSunday.isChecked());
    alarmDetails.setRepeatingDay(AlarmModel.MONDAY, chkMonday.isChecked());
    alarmDetails.setRepeatingDay(AlarmModel.TUESDAY, chkTuesday.isChecked());
    alarmDetails.setRepeatingDay(AlarmModel.WEDNESDAY, chkWednesday.isChecked());
    alarmDetails.setRepeatingDay(AlarmModel.THURSDAY, chkThursday.isChecked());
    alarmDetails.setRepeatingDay(AlarmModel.FRIDAY, chkFriday.isChecked());
    alarmDetails.setRepeatingDay(AlarmModel.SATURDAY, chkSaturday.isChecked());
    alarmDetails.isEnabled = true;

          */
    alarmDetails.name = "alarm";
    alarmDetails.repeatWeekly = true;
    alarmDetails.setRepeatingDay(AlarmModel.SUNDAY, true);
    alarmDetails.setRepeatingDay(AlarmModel.MONDAY, true);
    alarmDetails.setRepeatingDay(AlarmModel.TUESDAY, true);
    alarmDetails.setRepeatingDay(AlarmModel.WEDNESDAY, true);
    alarmDetails.setRepeatingDay(AlarmModel.THURSDAY, true);
    alarmDetails.setRepeatingDay(AlarmModel.FRIDAY, true);
    alarmDetails.setRepeatingDay(AlarmModel.SATURDAY, true);
    alarmDetails.isEnabled = true;
  }
示例#11
0
  /** @see Widget.setProperty. */
  @Override
  public boolean setProperty(String property, String value)
      throws PropertyConversionException, InvalidPropertyValueException {
    if (super.setProperty(property, value)) {
      return true;
    }

    TimePicker timePicker = (TimePicker) getView();

    if (property.equals(IX_WIDGET.MAW_TIME_PICKER_CURRENT_HOUR)) {
      int hour = IntConverter.convert(value);
      if (hour < 0 || hour > 23) {
        throw new InvalidPropertyValueException(property, value);
      }
      timePicker.setCurrentHour(IntConverter.convert(value));
    } else if (property.equals(IX_WIDGET.MAW_TIME_PICKER_CURRENT_MINUTE)) {
      int minute = IntConverter.convert(value);
      if (minute < 0 || minute > 59) {
        throw new InvalidPropertyValueException(property, value);
      }
      timePicker.setCurrentMinute(IntConverter.convert(value));
    } else {
      return false;
    }
    return true;
  }
    @Override
    public void onClick(View v) {

      /*TimePickerDialog timeDialog = new TimePickerDialog(TaskDetailActivity.this, new TimePickerDialog.OnTimeSetListener()
      {
          @Override
          public void onTimeSet(TimePicker view, int hourOfDay, int minute)
          {
              TaskDetailActivity.this.alarm.setTime(Utils.getCalendar(hourOfDay, minute));
              TaskDetailActivity.this.updateView();
          }
      }, TaskDetailActivity.this.alarm.getHour(), TaskDetailActivity.this.alarm.getMinute(), true);
      timeDialog.show();*/
      final TimePicker timePicker = new TimePicker(TaskDetailActivity.this);
      timePicker.setIs24HourView(true);
      timePicker.setCurrentHour(TaskDetailActivity.this.editAlarm.getHour());
      timePicker.setCurrentMinute(TaskDetailActivity.this.editAlarm.getMinute());
      new AlertDialog.Builder(TaskDetailActivity.this)
          .setTitle(TaskDetailActivity.this.getString(R.string.alertDialogTimeChoose_title))
          .setIcon(android.R.drawable.ic_dialog_info)
          .setView(timePicker)
          .setPositiveButton(
              TaskDetailActivity.this.getString(R.string.alertDialog_positive),
              new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                  TaskDetailActivity.this.editAlarm.setTime(
                      timePicker.getCurrentHour(), timePicker.getCurrentMinute());
                  TaskDetailActivity.this.txtTimeView.setText(
                      TaskDetailActivity.this.editAlarm.getTimeStr(TaskDetailActivity.this));
                }
              })
          .setNegativeButton(TaskDetailActivity.this.getString(R.string.alertDialog_negative), null)
          .show();
    }
 private void initTimePicker(Date crimeDate) {
   Calendar calendar = Calendar.getInstance();
   calendar.setTime(crimeDate);
   int hour = calendar.get(Calendar.HOUR_OF_DAY);
   int minute = calendar.get(Calendar.MINUTE);
   mTimePicker.setCurrentHour(hour);
   mTimePicker.setCurrentMinute(minute);
 }
示例#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);
 }
  /** Sets the timePicker to the current time. Used on page load */
  private void setCurrentTimeOnView() {
    final Calendar cal = Calendar.getInstance();
    int hour = cal.get(Calendar.HOUR_OF_DAY);
    int minute = cal.get(Calendar.MINUTE);

    scheduleTimePicker.setCurrentHour(hour);
    scheduleTimePicker.setCurrentMinute(minute);
  }
示例#16
0
    public View getView(Context context) throws UnsupportedOperationException {
      if (mType.equals("date")) {
        try {
          DateTimePicker input =
              new DateTimePicker(context, "yyyy-MM-dd", mValue, DateTimePicker.PickersState.DATE);
          input.toggleCalendar(true);
          mView = (View) input;
        } catch (UnsupportedOperationException ex) {
          // We can't use our custom version of the DatePicker widget because the sdk is too old.
          // But we can fallback on the native one.
          DatePicker input = new DatePicker(context);
          try {
            if (!TextUtils.isEmpty(mValue)) {
              GregorianCalendar calendar = new GregorianCalendar();
              calendar.setTime(new SimpleDateFormat("yyyy-MM-dd").parse(mValue));
              input.updateDate(
                  calendar.get(Calendar.YEAR),
                  calendar.get(Calendar.MONTH),
                  calendar.get(Calendar.DAY_OF_MONTH));
            }
          } catch (Exception e) {
            Log.e(LOGTAG, "error parsing format string: " + e);
          }
          mView = (View) input;
        }
      } else if (mType.equals("week")) {
        DateTimePicker input =
            new DateTimePicker(context, "yyyy-'W'ww", mValue, DateTimePicker.PickersState.WEEK);
        mView = (View) input;
      } else if (mType.equals("time")) {
        TimePicker input = new TimePicker(context);
        input.setIs24HourView(DateFormat.is24HourFormat(context));

        GregorianCalendar calendar = new GregorianCalendar();
        if (!TextUtils.isEmpty(mValue)) {
          try {
            calendar.setTime(new SimpleDateFormat("HH:mm").parse(mValue));
          } catch (Exception e) {
          }
        }
        input.setCurrentHour(calendar.get(GregorianCalendar.HOUR_OF_DAY));
        input.setCurrentMinute(calendar.get(GregorianCalendar.MINUTE));
        mView = (View) input;
      } else if (mType.equals("datetime-local") || mType.equals("datetime")) {
        DateTimePicker input =
            new DateTimePicker(
                context, "yyyy-MM-dd HH:mm", mValue, DateTimePicker.PickersState.DATETIME);
        input.toggleCalendar(true);
        mView = (View) input;
      } else if (mType.equals("month")) {
        DateTimePicker input =
            new DateTimePicker(context, "yyyy-MM", mValue, DateTimePicker.PickersState.MONTH);
        mView = (View) input;
      }
      return mView;
    }
示例#17
0
 @Override
 protected void onClick() {
   int h = getHour();
   int m = getMinute();
   if (h >= 0 && m >= 0) {
     timePicker.setCurrentHour(h);
     timePicker.setCurrentMinute(m);
   }
   dialog.show();
 }
示例#18
0
 /**
  * Produces a TimePicker set to the time produced by {@link #getTime()}. When overriding be sure
  * to call the super.
  *
  * @return a DatePicker with the date set
  */
 @Override
 protected View onCreateDialogView() {
   TimePicker timePicker = new TimePicker(getContext());
   timePicker.setIs24HourView(android.text.format.DateFormat.is24HourFormat(getContext()));
   Calendar calendar = getTime();
   timePicker.setCurrentHour(calendar.get(Calendar.HOUR_OF_DAY));
   timePicker.setCurrentMinute(calendar.get(Calendar.MINUTE));
   timePicker.setOnTimeChangedListener(this);
   return timePicker;
 }
示例#19
0
 private void setEndTime(final TimeObject startTime) {
   LinearLayout layout = new LinearLayout(PlayBackActivity.this);
   layout.setOrientation(LinearLayout.VERTICAL);
   layout.setBackgroundColor(getResources().getColor(R.color.white));
   final TimePicker mTimePicker = new TimePicker(PlayBackActivity.this);
   final DatePicker mDatePicker = new DatePicker(PlayBackActivity.this);
   mTimePicker.setDescendantFocusability(TimePicker.FOCUS_BLOCK_DESCENDANTS);
   mTimePicker.setIs24HourView(true);
   mDatePicker.setDescendantFocusability(DatePicker.FOCUS_BLOCK_DESCENDANTS);
   final TextView tv = new TextView(PlayBackActivity.this);
   String time = String.format("%02d:%02d", startTime.getHour(), startTime.getMinute());
   String date =
       String.valueOf(startTime.getYear())
           + "年"
           + String.format("%02d", startTime.getMonth())
           + "月"
           + String.format("%02d", startTime.getDay())
           + "日";
   tv.setText("开始时间:" + date + "  " + time);
   int version = Integer.valueOf(android.os.Build.VERSION.SDK);
   if (version >= 11) mDatePicker.setCalendarViewShown(false);
   layout.addView(tv, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
   layout.addView(
       mDatePicker, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
   layout.addView(
       mTimePicker, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
   new AlertDialog.Builder(PlayBackActivity.this)
       .setTitle("请选择结束时间:")
       .setView(layout)
       .setPositiveButton(
           android.R.string.ok,
           new DialogInterface.OnClickListener() {
             @Override
             public void onClick(DialogInterface arg0, int arg1) {
               TimeObject endTime =
                   new TimeObject(
                       mTimePicker.getCurrentMinute(),
                       mTimePicker.getCurrentHour(),
                       mDatePicker.getDayOfMonth(),
                       mDatePicker.getMonth() + 1,
                       mDatePicker.getYear());
               System.out.println("时间:" + endTime.getMinute() + "  " + startTime.getMinute());
               onTimeSearch(startTime, endTime);
             }
           })
       .setNegativeButton(
           android.R.string.cancel,
           new DialogInterface.OnClickListener() {
             @Override
             public void onClick(DialogInterface arg0, int arg1) {}
           })
       .create()
       .show();
 }
示例#20
0
  /** Called when the activity is first created. */
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    TimePicker tp = (TimePicker) this.findViewById(R.id.timePicker);
    tp.setIs24HourView(true);

    // открываем подключение к БД
    db = new DB(this);
    db.open();
    refreshCursor();
  }
示例#21
0
  @Override
  protected View onCreateDialogView() {
    value = getPersistedValue();

    timePicker = new TimePicker(getContext());
    timePicker.setIs24HourView(true);
    timePicker.setCurrentHour(value.first);
    timePicker.setCurrentMinute(value.second);

    return timePicker;
  }
示例#22
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.new_alarm_layout);

    this.taskNameView = (EditText) findViewById(R.id.taskNameView);
    this.datePicker = (DatePicker) findViewById(R.id.datePicker);
    this.timePicker = (TimePicker) findViewById(R.id.timePicker);
    this.setTaskBtn = (Button) findViewById(R.id.setTaskBtn);

    timePicker.setCurrentMinute(timePicker.getCurrentMinute() + 1);

    this.setTaskBtn.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {

            if (taskNameView.getText().toString().trim().length() < 1) {
              // create alert show no task name given
              AlertDialog alert =
                  new Builder(NewAlarmActivity.this)
                      .setTitle("Ups!")
                      .setMessage("Task name is empty")
                      .setNeutralButton("OK", null)
                      .create();
              alert.show();
            } else {
              // get name of the task new alarm , or something else ...
              Intent intent = new Intent(NewAlarmActivity.this, NewAlarmReciever.class);
              intent.putExtra("ALARM_NAME", taskNameView.getText().toString().trim());
              PendingIntent toReciever =
                  PendingIntent.getBroadcast(
                      NewAlarmActivity.this,
                      new Random().nextInt(65000),
                      intent,
                      PendingIntent.FLAG_ONE_SHOT);

              Calendar calendar = Calendar.getInstance();
              calendar.setTimeInMillis(System.currentTimeMillis());
              calendar.clear();
              calendar.set(
                  datePicker.getYear(),
                  datePicker.getMonth(),
                  datePicker.getDayOfMonth(),
                  timePicker.getCurrentHour(),
                  timePicker.getCurrentMinute());
              AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
              alarmManager.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), toReciever);

              Toast.makeText(getApplicationContext(), "Alarm set", Toast.LENGTH_SHORT).show();
            }
          }
        });
  }
示例#23
0
  /** Show time picker */
  public void showTimer() {
    MainActivity me = MainActivity.this;
    Context context = me;
    Animation anim;

    anim = AnimationUtils.loadAnimation(context, R.anim.push_down_in);

    anim.setAnimationListener(me);
    mTimePicker.startAnimation(anim);
    mTimePicker.setVisibility(TimePicker.VISIBLE);
  }
示例#24
0
 @Override
 protected void onDialogClosed(boolean positiveResult) {
   if (positiveResult) {
     if (isPersistent()) {
       persistString(
           valueToString(
               getContext(),
               Pair.create(timePicker.getCurrentHour(), timePicker.getCurrentMinute())));
     }
     callChangeListener(positiveResult);
   }
 }
示例#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
 @Override
 protected void onDialogClosed(boolean positiveResult) {
   super.onDialogClosed(positiveResult);
   if (positiveResult) {
     lastHour = picker.getCurrentHour();
     lastMinute = picker.getCurrentMinute();
     String time = String.valueOf(lastHour) + ":" + String.valueOf(lastMinute);
     if (callChangeListener(time)) {
       persistString(time);
     }
   }
 }
示例#27
0
  /** @see Widget.getProperty. */
  @Override
  public String getProperty(String property) {
    TimePicker timePicker = (TimePicker) getView();

    if (property.equals(IX_WIDGET.MAW_TIME_PICKER_CURRENT_HOUR)) {
      return Integer.toString(timePicker.getCurrentHour());
    } else if (property.equals(IX_WIDGET.MAW_TIME_PICKER_CURRENT_MINUTE)) {
      return Integer.toString(timePicker.getCurrentMinute());
    } else {
      return super.getProperty(property);
    }
  }
  @Override
  protected void onDialogClosed(boolean positiveResult) {
    super.onDialogClosed(positiveResult);

    if (positiveResult) {
      m_minutes = m_picker.getCurrentHour() * 60 + m_picker.getCurrentMinute();

      if (callChangeListener(m_minutes)) {
        persistInt(m_minutes);
        notifyChanged();
      }
    }
  }
  public PilihWaktu(Context context, Handler handler) {
    super(context);
    mHandler = handler;
    setTitle("Pilih Waktu : ");

    setContentView(R.layout.monitoring_waktu);

    TimePicker time1 = (TimePicker) findViewById(R.id.monitoringTime1);
    time1.setIs24HourView(true);

    TimePicker time2 = (TimePicker) findViewById(R.id.monitoringTime2);
    time2.setIs24HourView(true);
  }
  private void showDialog_Layout(Context context, String text, int src) {
    LayoutInflater inflater = LayoutInflater.from(this);

    final int currentSelect = src;
    final View timeSetView = inflater.inflate(R.layout.time_dialog, null);
    final TextView tv = (TextView) this.findViewById(src);

    final TimePicker timePicker = (TimePicker) timeSetView.findViewById(R.id.timePicker);
    int index = rId2Index.get(Integer.valueOf(src));
    timePicker.setCurrentHour(hour[index]);
    timePicker.setCurrentMinute(minute[index]);

    final AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setCancelable(false);
    // builder.setIcon(R.drawable.icon); customize icon
    builder.setTitle(text);
    builder.setView(timeSetView);
    builder.setPositiveButton(
        "确认",
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int whichButton) {
            int hour = timePicker.getCurrentHour();
            int minute = timePicker.getCurrentMinute();
            int index = rId2Index.get(Integer.valueOf(currentSelect));

            if (minute < 10) {
              tv.setText(Constants.PREFIX[index] + hour + ":" + "0" + minute);
            } else {
              tv.setText(Constants.PREFIX[index] + hour + ":" + minute);
            }

            Message msg = mHandler.obtainMessage(MSG_UI_UPDATE_TIME);
            Bundle bundle = new Bundle();
            bundle.putInt("index", index);
            bundle.putInt("src", currentSelect);
            bundle.putInt("hour", hour);
            bundle.putInt("minute", minute);
            msg.setData(bundle);

            msg.sendToTarget();
          }
        });
    builder.setNegativeButton(
        "取消",
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int whichButton) {
            setTitle("");
          }
        });
    builder.show();
  }