コード例 #1
0
  public Alarm getLBAlarm() {
    for (AlarmPre preference : preferences) {
      switch (preference.getKey()) {
        case ALARM_ACTIVE:
          alarm.setAlarmActive((Boolean) preference.getValue());
          break;
        case ALARM_NAME:
          alarm.setAlarmName((String) preference.getValue());
          break;
        case ALARM_TIME:
          alarm.setAlarmTime((String) preference.getValue());
          break;
        case ALARM_TONE:
          alarm.setAlarmTonePath((String) preference.getValue());
          break;
        case ALARM_VIBRATE:
          alarm.setVibrate((Boolean) preference.getValue());
          break;
        case ALARM_REPEAT:
          alarm.setDays((Alarm.Day[]) preference.getValue());
          break;
      }
    }

    return alarm;
  }
コード例 #2
0
  public void setLBAlarm(Alarm alarm) {
    this.alarm = alarm;
    preferences.clear();
    preferences.add(
        new AlarmPre(
            AlarmPre.Key.ALARM_ACTIVE, "Active", null, null, alarm.getAlarmActive(), Type.BOOLEAN));
    preferences.add(
        new AlarmPre(
            AlarmPre.Key.ALARM_NAME,
            "Detail",
            alarm.getAlarmName(),
            null,
            alarm.getAlarmName(),
            Type.STRING));
    preferences.add(
        new AlarmPre(
            AlarmPre.Key.ALARM_TIME,
            "Time",
            alarm.getAlarmTimeString(),
            null,
            alarm.getAlarmTime(),
            Type.TIME));
    preferences.add(
        new AlarmPre(
            AlarmPre.Key.ALARM_REPEAT,
            "Repeat",
            alarm.getRepeatDaysString(),
            repeatDays,
            alarm.getDays(),
            Type.MULTIPLE_LIST));

    Uri alarmToneUri = Uri.parse(alarm.getAlarmTonePath());

    Ringtone alarmTone = RingtoneManager.getRingtone(getContext(), alarmToneUri);

    if (alarmTone instanceof Ringtone && !alarm.getAlarmTonePath().equalsIgnoreCase("")) {
      preferences.add(
          new AlarmPre(
              AlarmPre.Key.ALARM_TONE,
              "Ringtone",
              alarmTone.getTitle(getContext()),
              alarmTones,
              alarm.getAlarmTonePath(),
              Type.LIST));
    } else {
      preferences.add(
          new AlarmPre(
              AlarmPre.Key.ALARM_TONE,
              "Ringtone",
              getAlarmTones()[0],
              alarmTones,
              null,
              Type.LIST));
    }

    preferences.add(
        new AlarmPre(
            AlarmPre.Key.ALARM_VIBRATE, "Vibrate", null, null, alarm.getVibrate(), Type.BOOLEAN));
  }