结对项目:一寸时光APP(日程管理)三

日程倒计时界面:主界面主要实现的是倒计时的功能,输入倒计时的时间后点击确定按钮,下方的方块即会显示倒计时时间,时间到后手机会震动及振铃。点击方块后取消提醒。

图片:

int hour = 0, minute = 0, second = 0;
if (!TextUtils.isEmpty(etHour.getText().toString())) {
hour = Integer.valueOf(etHour.getText().toString());
}
if (!TextUtils.isEmpty(etMinute.getText().toString())) {
minute = Integer.valueOf(etMinute.getText().toString());
}
if (!TextUtils.isEmpty(etSecond.getText().toString())) {
second = Integer.valueOf(etSecond.getText().toString());
}
int sum = hour * 1000 * 3600 + minute * 1000 * 60 + second * 1000;
if (sum == 0) {
Toast.makeText(getActivity(), "请输入倒计时时间!", Toast.LENGTH_SHORT).show();
} else {
mc = new MyCount(sum, 1000);
mc.start();
}
etMinute.setText("");
etHour.setText("");
etSecond.setText("");

通知栏提醒界面:主界面主要实现的是在日程提醒的状态下通知栏展示提醒的日程,点击该通知栏后可进入日程查看界面。

图片:

Notification.Builder builder = new Notification.Builder(this);
notificationManager = (NotificationManager) this
.getSystemService(NOTIFICATION_SERVICE);
Intent clickIntent = new Intent(NotificationService.this, MyReceiver.class);
clickIntent.putExtra("id", id);
PendingIntent pendingIntent = PendingIntent.getBroadcast(NotificationService.this, 1, clickIntent, PendingIntent.FLAG_CANCEL_CURRENT);
builder.setTicker("您有设定日程已到时间").setDefaults(Notification.DEFAULT_VIBRATE).setContentIntent(pendingIntent).setSmallIcon(R.mipmap.android).setContentTitle("日程提示")
.setContentText("点击查看日程: " + title);
Notification notification = builder.build();
notificationManager.notify(1, notification);

posted @ 2017-06-15 16:48  费尼克斯基  阅读(229)  评论(1编辑  收藏  举报