예제 #1
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);
  }
 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());
   }
 }
 public PreferencesRegistry putTime(TimePicker timePicker) {
   getEditor()
       .putInt("hour", timePicker.getCurrentHour())
       .putInt("minute", timePicker.getCurrentMinute())
       .commit();
   return this;
 }
예제 #4
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 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;
  }
예제 #6
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);
    }
  }
예제 #7
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);
 }
예제 #8
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));
  }
예제 #9
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();
            }
          }
        });
  }
예제 #10
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);
 }
예제 #11
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);
     }
   }
 }
예제 #12
0
 @Override
 protected void onDialogClosed(boolean positiveResult) {
   if (positiveResult) {
     if (isPersistent()) {
       persistString(
           valueToString(
               getContext(),
               Pair.create(timePicker.getCurrentHour(), timePicker.getCurrentMinute())));
     }
     callChangeListener(positiveResult);
   }
 }
예제 #13
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);
    }
  }
예제 #14
0
  @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();
      }
    }
  }
예제 #15
0
  public String responseString() {
    String answer = "";
    try {
      String hour = String.valueOf(picker.getCurrentHour());
      String minute = String.valueOf(picker.getCurrentMinute());
      answer = hour + ":" + minute;
    } catch (Exception e) {
      Log.e(TAG, "Unable to get response");
      e.printStackTrace();
    }

    if (answer == null | answer.equals("")) answer = NO_RESPONSE;
    return answer;
  }
예제 #16
0
 @Override
 public void onClick(DialogInterface dialog, int which) {
   switch (which) {
     case DialogInterface.BUTTON_POSITIVE:
       timePicker.clearFocus();
       result = timePicker.getCurrentHour() + "-" + timePicker.getCurrentMinute();
       persistString(result);
       callChangeListener(result);
       dialog.dismiss();
       break;
     case DialogInterface.BUTTON_NEGATIVE:
       dialog.dismiss();
       break;
   }
 }
예제 #17
0
  @Override
  protected void onDialogClosed(boolean positiveResult) {
    super.onDialogClosed(positiveResult);

    if (positiveResult) {
      calendar.set(Calendar.HOUR_OF_DAY, picker.getCurrentHour());
      calendar.set(Calendar.MINUTE, picker.getCurrentMinute());

      setSummary(getSummary());
      if (callChangeListener(calendar.getTimeInMillis())) {
        persistLong(calendar.getTimeInMillis());
        notifyChanged();
      }
    }
  }
예제 #18
0
 public String getValue() {
   if (mType.equals("checkbox")) {
     CheckBox checkbox = (CheckBox) mView;
     return checkbox.isChecked() ? "true" : "false";
   } else if (mType.equals("textbox") || mType.equals("password")) {
     EditText edit = (EditText) mView;
     return edit.getText().toString();
   } else if (mType.equals("menulist")) {
     Spinner spinner = (Spinner) mView;
     return Integer.toString(spinner.getSelectedItemPosition());
   } else if (mType.equals("time")) {
     TimePicker tp = (TimePicker) mView;
     GregorianCalendar calendar =
         new GregorianCalendar(0, 0, 0, tp.getCurrentHour(), tp.getCurrentMinute());
     return formatDateString("kk:mm", calendar);
   } else if (mType.equals("label")) {
     return "";
   } else if (android.os.Build.VERSION.SDK_INT < 11 && 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 {
     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 kk:mm", calendar);
     } else if (mType.equals("datetime")) {
       calendar.set(GregorianCalendar.ZONE_OFFSET, 0);
       calendar.setTimeInMillis(dp.getTimeInMillis());
       return formatDateString("yyyy-MM-dd kk:mm", calendar);
     } else if (mType.equals("month")) {
       return formatDateString("yyyy-MM", calendar);
     }
   }
   return "";
 }
  private void updateRounds(final Patients p) {
    final Dialog in_d = new Dialog(getActivity());
    in_d.setTitle("Update Hospital Details");
    in_d.setContentView(R.layout.input_rounds_schedule);

    Calendar c = Calendar.getInstance();
    final EditText h_name = (EditText) in_d.findViewById(R.id.hospital_name_next);
    final EditText h_room = (EditText) in_d.findViewById(R.id.hospital_room_next);
    TimePicker timePicker = (TimePicker) in_d.findViewById(R.id.round_schedule);
    final View amPmView = ((ViewGroup) timePicker.getChildAt(0)).getChildAt(3);
    save = (Button) in_d.findViewById(R.id.save_rounds_setup);
    Button cancel_rounds_setup = (Button) in_d.findViewById(R.id.cancel_rounds_setup);
    save.setEnabled(false);

    c.setTimeInMillis(p.getTime());
    h_name.setText(p.getHosp_name());
    h_room.setText(p.getHosp_room());
    timePicker.setCurrentHour(c.get(Calendar.HOUR_OF_DAY));
    timePicker.setCurrentMinute(c.get(Calendar.MINUTE));

    mHour = timePicker.getCurrentHour();
    mMin = timePicker.getCurrentMinute();

    timePicker.setOnTimeChangedListener(
        new TimePicker.OnTimeChangedListener() {

          public void onTimeChanged(TimePicker view, int hourOfDay, int minute) {
            mHour = hourOfDay;
            mMin = minute;
            save.setEnabled(true);
          }
        });

    h_name.addTextChangedListener(this);
    h_room.addTextChangedListener(this);

    save.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            AlertDialog.Builder build = new AlertDialog.Builder(getActivity());
            build.setMessage("Are all edits Correct?");
            build.setCancelable(false);
            build.setPositiveButton(
                "Yes",
                new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int which) {
                    // Temporary Workaround bug on timepicker
                    if (amPmView instanceof NumberPicker) {
                      if (((NumberPicker) amPmView).getValue() == 1) {
                        if (mHour >= 12) mHour = mHour - 12;
                        mHour = mHour + 12;
                      }

                      if (((NumberPicker) amPmView).getValue() == 0) {
                        if (mHour >= 12) mHour = mHour - 12;
                      }
                    }

                    // Toast.makeText(getActivity(), "Time of this record is:
                    // "+formatTime(timeInMills), Toast.LENGTH_LONG).show();

                    Time time = new Time();
                    time.hour = mHour;
                    time.minute = mMin;
                    time.second = 0;
                    timeInMills = time.toMillis(false);

                    Patients patients = p;

                    patients.setHosp_name(h_name.getText().toString());
                    patients.setHosp_room(h_room.getText().toString());

                    patients.setLocation(
                        h_name.getText().toString() + " - " + h_room.getText().toString());
                    patients.setTime(timeInMills);

                    Toast.makeText(getActivity(), "Rounds Schedule Updated!", Toast.LENGTH_SHORT)
                        .show();
                    help.update(patients, Helper.UPDATE_SCHEDULE);
                    // Helper.scheduleRepeatingAlarm(getActivity(), patients,
                    // patients.getRequestCode(), patients.getTime());
                    loadPatientMasterList();
                    loadPatientList(1);
                    in_d.cancel();
                  }
                });
            build.setNegativeButton(
                "No",
                new DialogInterface.OnClickListener() {

                  public void onClick(DialogInterface dialog, int which) {
                    dialog.cancel();
                  }
                });

            AlertDialog alert = build.create();
            alert.show();
          }
        });

    cancel_rounds_setup.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            in_d.cancel();
          }
        });

    in_d.show();
  }
예제 #20
0
        @Override
        public void onClick(View v) {

          Calendar cal = Calendar.getInstance();
          cal.setTimeInMillis(System.currentTimeMillis());
          cal.add(Calendar.SECOND, cal.get(Calendar.SECOND) * -1);

          int alarmMint = tpAlarm.getCurrentMinute();
          int alarmHour = tpAlarm.getCurrentHour();
          int currentHour = cal.get(Calendar.HOUR_OF_DAY);
          int currentMint = cal.get(Calendar.MINUTE);
          int toAddMint = 0;
          int toAddHour = 0;

          if (currentMint > alarmMint) toAddMint = (60 - currentMint) + alarmMint;
          else toAddMint = alarmMint - currentMint;

          if (currentHour > alarmHour) {
            toAddHour = (24 - currentHour) + alarmHour;
          } else if (currentHour == alarmHour) {
            if (currentMint > alarmMint) toAddHour = 23;
            else if (currentMint == alarmMint) toAddHour = 24;
            else toAddHour = 0;
          } else toAddHour = alarmHour - currentHour;

          cal.add(Calendar.MINUTE, toAddMint);
          cal.add(Calendar.HOUR_OF_DAY, toAddHour);

          Intent intent = new Intent(getApplicationContext(), AlarmReceiver.class);
          PendingIntent sender = PendingIntent.getBroadcast(getApplicationContext(), 0, intent, 0);

          AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);

          if (!chkSnooze.isChecked() && !etxtSnoozeMin.getText().toString().equals("")) {

            am.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), sender);

          } else {

            int elapseTime = Integer.parseInt(etxtSnoozeMin.getText().toString());
            am.setRepeating(
                AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), elapseTime * 60000, sender);
          }

          SharedPreferences.Editor editor = prefs.edit();

          editor.putInt(M_HOUR, alarmHour);
          editor.putInt(M_MINT, alarmMint);
          editor.putBoolean(M_SNOOZE, chkSnooze.isChecked());
          editor.putString(SNOOZE_T, etxtSnoozeMin.getText().toString());

          editor.commit();

          if (mToast != null) {
            mToast.cancel();
          }
          mToast =
              Toast.makeText(
                  TalarkamActivity.this,
                  "Alarm scheduled for "
                      + toAddHour
                      + " hour/s and "
                      + toAddMint
                      + " minute/s from now",
                  Toast.LENGTH_LONG);
          mToast.show();

          TalarkamActivity.this.finish();
        }
 /**
  * Internal function which will create a {@code TimeShort} from a passed TimePicker object.
  *
  * @param timePicker the timepicker from which to get the time from
  * @return TimeShort
  */
 private TimeShort getTime(TimePicker timePicker) {
   TimeShort result;
   result = new TimeShort(timePicker.getCurrentHour(), timePicker.getCurrentMinute());
   return result;
 }
예제 #22
0
 private long calculateTime(DatePicker d, TimePicker t) {
   Calendar calendar = Calendar.getInstance();
   calendar.set(
       d.getYear(), d.getMonth(), d.getDayOfMonth(), t.getCurrentHour(), t.getCurrentMinute(), 0);
   return calendar.getTimeInMillis();
 }
  private void updateRounds(final Patients p) {
    final Dialog in_d = new Dialog(getActivity());
    in_d.setTitle("Update Hospital Details");
    in_d.setContentView(R.layout.input_rounds_schedule);

    Calendar c = Calendar.getInstance();
    final EditText h_name = (EditText) in_d.findViewById(R.id.hospital_name_next);
    final EditText h_room = (EditText) in_d.findViewById(R.id.hospital_room_next);
    TimePicker timePicker = (TimePicker) in_d.findViewById(R.id.round_schedule);
    final View amPmView = ((ViewGroup) timePicker.getChildAt(0)).getChildAt(3);
    Button add_rounds_setup = (Button) in_d.findViewById(R.id.save_rounds_setup);
    Button cancel_rounds_setup = (Button) in_d.findViewById(R.id.cancel_rounds_setup);

    c.setTimeInMillis(p.getTime());
    h_name.setText(p.getHosp_name());
    h_room.setText(p.getHosp_room());
    timePicker.setCurrentHour(c.get(Calendar.HOUR_OF_DAY));
    timePicker.setCurrentMinute(c.get(Calendar.MINUTE));

    mHour = timePicker.getCurrentHour();
    mMin = timePicker.getCurrentMinute();

    timePicker.setOnTimeChangedListener(
        new TimePicker.OnTimeChangedListener() {

          public void onTimeChanged(TimePicker view, int hourOfDay, int minute) {
            mHour = hourOfDay;
            mMin = minute;
          }
        });

    add_rounds_setup.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            // Temporary Workaround bug on timepicker
            if (amPmView instanceof NumberPicker) {
              if (((NumberPicker) amPmView).getValue() == 1) {
                if (mHour >= 12) mHour = mHour - 12;
                mHour = mHour + 12;
              }

              if (((NumberPicker) amPmView).getValue() == 0) {
                if (mHour >= 12) mHour = mHour - 12;
              }
            }

            // Toast.makeText(getActivity(), "Time of this record is: "+formatTime(timeInMills),
            // Toast.LENGTH_LONG).show();
            Time time = new Time();
            time.hour = mHour;
            time.minute = mMin;
            timeInMills = time.toMillis(false);

            Patients patients = p;

            patients.setHosp_name(h_name.getText().toString());
            patients.setHosp_room(h_room.getText().toString());

            patients.setLocation(h_name.getText().toString() + " - " + h_room.getText().toString());
            patients.setTime(timeInMills);

            Toast.makeText(getActivity(), "Rounds Schedule Updated!", Toast.LENGTH_SHORT).show();
            help.update(patients, Helper.UPDATE_SCHEDULE);
            loadPatientMasterList();
            loadPatientList(1);
            in_d.cancel();
          }
        });

    cancel_rounds_setup.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            in_d.cancel();
          }
        });

    in_d.show();
  }
 public int getCurrentMinute() {
   return timePicker.getCurrentMinute();
 }
  private void showAppWidget() {

    int mAppWidgetId = AppWidgetManager.INVALID_APPWIDGET_ID;
    Intent intent = getIntent();
    Bundle extras = intent.getExtras();
    if (extras != null) {
      mAppWidgetId = extras.getInt(EXTRA_APPWIDGET_ID, INVALID_APPWIDGET_ID);

      if (mAppWidgetId == INVALID_APPWIDGET_ID) {
        Log.w("WidgetAdd", "Cannot continue. Widget ID incorrect");
        return;
      }

      DatePicker date = (DatePicker) findViewById(R.id.datePicker);
      TimePicker time = (TimePicker) findViewById(R.id.timePicker);
      CheckBox checkBox = (CheckBox) findViewById(R.id.checkBoxTime);
      EditText eventName = (EditText) findViewById(R.id.eventName);
      CheckBox checkProgressBar = (CheckBox) findViewById(R.id.chkProgressBar);
      SharedPreferences prefs =
          PreferenceManager.getDefaultSharedPreferences(getApplicationContext());

      Calendar end = Calendar.getInstance();
      prefs.edit().putLong("widget." + mAppWidgetId + ".start", end.getTimeInMillis()).apply();

      if (checkBox.isChecked()) {
        time.clearFocus();
        end.set(
            date.getYear(),
            date.getMonth(),
            date.getDayOfMonth(),
            time.getCurrentHour(),
            time.getCurrentMinute(),
            0);
      } else {
        end.set(date.getYear(), date.getMonth(), date.getDayOfMonth());
      }
      Log.i("addend", String.valueOf(end.getTimeInMillis()));

      prefs.edit().putLong("widget." + mAppWidgetId + ".end", end.getTimeInMillis()).apply();
      prefs
          .edit()
          .putBoolean("widget." + mAppWidgetId + ".onlyDays", !checkBox.isChecked())
          .apply();
      prefs
          .edit()
          .putBoolean("widget." + mAppWidgetId + ".showProgressBar", !checkProgressBar.isChecked())
          .apply();
      prefs
          .edit()
          .putString("widget." + mAppWidgetId + ".eventName", eventName.getText().toString())
          .apply();

      Intent startService = new Intent(ConfigurationActivity.this, CountdownWidget.class);
      startService.putExtra(EXTRA_APPWIDGET_ID, mAppWidgetId);
      startService.setAction("FROM CONFIGURATION ACTIVITY");
      setResult(RESULT_OK, startService);
      startService(startService);
      finish();
    }

    if (mAppWidgetId == INVALID_APPWIDGET_ID) {
      Log.e("Invalid app widget id", "Invalid app widget id");
      finish();
    }
  }
예제 #26
0
 public MTime(TimePicker tp) {
   hour = tp.getCurrentHour();
   minute = tp.getCurrentMinute();
 }
예제 #27
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_cancel) {
      Intent intent = new Intent(this, TasksList.class);
      startActivity(intent);
      return true;
    } else if (id == R.id.action_delete) {
      DBHandlerSingleton.getInstance(getApplicationContext()).deleteTask(task_id);
      Intent intent = new Intent(this, TasksList.class);
      startActivity(intent);
      return true;
    } else if (id == R.id.action_modify) {
      EditText editTextName = (EditText) findViewById(R.id.editTextTaskName);
      EditText editTextDesc = (EditText) findViewById(R.id.editTextTaskDescription);
      DatePicker datePicker = (DatePicker) findViewById(R.id.datePickerTask);
      TimePicker time = (TimePicker) findViewById(R.id.timePickerTask);
      CheckBox checkBox = (CheckBox) findViewById(R.id.checkBoxTaskDetail);
      task_name = editTextName.getText().toString();
      task_desc = editTextDesc.getText().toString();
      int currentapiVersion = android.os.Build.VERSION.SDK_INT;
      if (currentapiVersion >= Build.VERSION_CODES.M) {
        task_limitedate =
            Integer.toString(datePicker.getYear())
                + "-"
                + Integer.toString(datePicker.getMonth() + 1)
                + "-"
                + Integer.toString(datePicker.getDayOfMonth())
                + "-"
                + Integer.toString(time.getHour())
                + ":"
                + Integer.toString(time.getMinute());
      } else {
        task_limitedate =
            Integer.toString(datePicker.getYear())
                + "-"
                + Integer.toString(datePicker.getMonth() + 1)
                + "-"
                + Integer.toString(datePicker.getDayOfMonth())
                + "-"
                + Integer.toString(time.getCurrentHour())
                + ":"
                + Integer.toString(time.getCurrentMinute());
      }

      DBHandlerSingleton.getInstance(getApplicationContext())
          .updateTask(task_id, task_name, task_desc, task_limitedate);
      DBHandlerSingleton.getInstance(getApplicationContext()).setColorTask(task_id, task_color);
      DBHandlerSingleton.getInstance(getApplicationContext()).setTaskDone(task_id, task_done);
      Intent intent = new Intent(this, TasksList.class);
      startActivity(intent);
      return true;
    } else if (id == R.id.action_logout) {
      MainUserSingleton.getInstance().disconnect(getApplicationContext());
      Intent intent = new Intent(this, MainActivity.class);
      startActivity(intent);
      return true;
    }
    return super.onOptionsItemSelected(item);
  }