Finish reading WoringNote.setAlertDate

zhengkunpeng_branch
parent 176ce2e8c3
commit 9d222dac4b

@ -229,12 +229,22 @@ public class WorkingNote {
mNoteSettingStatusListener = l;
}
//TODO add comments of this method
/**
* @Method setAlertDate
* @Date 2023/12/13 11:43
* @param date
* @param set
* @Author lenovo
* @Return void
* @Description
*/
public void setAlertDate(long date, boolean set) {
// 更新便签项中的提醒日期
if (date != mAlertDate) {
mAlertDate = date;
mNote.setNoteValue(NoteColumns.ALERTED_DATE, String.valueOf(mAlertDate));
}
// 设置提醒的监听事件
if (mNoteSettingStatusListener != null) {
mNoteSettingStatusListener.onClockAlertChanged(date, set);
}

@ -295,15 +295,32 @@ public class NoteEditActivity extends Activity implements OnClickListener,
showAlertHeader();
}
/**
* @Method showAlertHeader
* @Date 2023/12/13 11:32
* @Author lenovo
* @Return void
* @Description 便
*/
private void showAlertHeader() {
if (mWorkingNote.hasClockAlert()) {
long time = System.currentTimeMillis();
if (time > mWorkingNote.getAlertDate()) {
// 闹钟时间大于当前时间, 显示 "Expired" 闹钟失效
mNoteHeaderHolder.tvAlertDate.setText(R.string.note_alert_expired);
} else {
// 显示正常闹钟信息
mNoteHeaderHolder.tvAlertDate.setText(DateUtils.getRelativeTimeSpanString(
mWorkingNote.getAlertDate(), time, DateUtils.MINUTE_IN_MILLIS));
}
/**
* setVisibility()
*
* VISIBLE
* INVISIBLE
* GNONE
* lenovo 2023/12/13 11:28
*/
mNoteHeaderHolder.tvAlertDate.setVisibility(View.VISIBLE);
mNoteHeaderHolder.ivAlertIcon.setVisibility(View.VISIBLE);
} else {
@ -603,6 +620,15 @@ public class NoteEditActivity extends Activity implements OnClickListener,
return NotesPreferenceActivity.getSyncAccountName(this).trim().length() > 0;
}
/**
* @Method onClockAlertChanged
* @Date 2023/12/13 9:52
* @param date
* @param set 0 1
* @Author lenovo
* @Return void
* @Description
*/
public void onClockAlertChanged(long date, boolean set) {
/**
* User could set clock to an unsaved note, so before setting the
@ -618,8 +644,10 @@ public class NoteEditActivity extends Activity implements OnClickListener,
AlarmManager alarmManager = ((AlarmManager) getSystemService(ALARM_SERVICE));
showAlertHeader();
if(!set) {
// 取消监听事件
alarmManager.cancel(pendingIntent);
} else {
// 设置监听事件,到时间启动提醒
alarmManager.set(AlarmManager.RTC_WAKEUP, date, pendingIntent);
}
} else {

Loading…
Cancel
Save