|
@@ -49,10 +49,10 @@ public class AlarmReceiver extends BroadcastReceiver {
|
|
|
if (ListUtils.isEmpty(beans)) return;
|
|
if (ListUtils.isEmpty(beans)) return;
|
|
|
boolean isOK = false;
|
|
boolean isOK = false;
|
|
|
for (Signin e : beans) {
|
|
for (Signin e : beans) {
|
|
|
- if (time.compareTo(e.getUtime()) < 0 && time.compareTo(e.getUsigmin()) > 0) {
|
|
|
|
|
|
|
+ if (time.compareTo(e.getUtime()) < 0 && time.compareTo(e.getUsigmin()) > 0) {//当前时间在该打卡范围
|
|
|
isOK = isSignined(e.getUsigmin(), e.getUtime(), array);
|
|
isOK = isSignined(e.getUsigmin(), e.getUtime(), array);
|
|
|
break;
|
|
break;
|
|
|
- } else if (time.compareTo(e.getDtime()) > 0 && time.compareTo(e.getDsigmin()) < 0) {
|
|
|
|
|
|
|
+ } else if (time.compareTo(e.getDtime()) > 0 && time.compareTo(e.getDsigmin()) < 0) {//当前时间在该打卡范围
|
|
|
isOK = isSignined(e.getDsigmin(), e.getDtime(), array);
|
|
isOK = isSignined(e.getDsigmin(), e.getDtime(), array);
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
@@ -140,7 +140,8 @@ public class AlarmReceiver extends BroadcastReceiver {
|
|
|
builder.setContentIntent(pendingIntent);
|
|
builder.setContentIntent(pendingIntent);
|
|
|
mNotificationManager.notify(1000, builder.build());
|
|
mNotificationManager.notify(1000, builder.build());
|
|
|
//设置签到提醒
|
|
//设置签到提醒
|
|
|
- initArmmanager(context);
|
|
|
|
|
|
|
+ if (CommonUtil.getSharedPreferencesBoolean(context, "ALARMA_CLICK", false))
|
|
|
|
|
+ initArmmanager(context);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private int getMin(String chche) {
|
|
private int getMin(String chche) {
|
|
@@ -162,21 +163,21 @@ public class AlarmReceiver extends BroadcastReceiver {
|
|
|
//获取提前和往后提醒时间
|
|
//获取提前和往后提醒时间
|
|
|
int uTime = getMin(CommonUtil.getSharedPreferences(ct, AlarmaActivity.KEY_ALAR_TIME));
|
|
int uTime = getMin(CommonUtil.getSharedPreferences(ct, AlarmaActivity.KEY_ALAR_TIME));
|
|
|
int dTime = getMin(CommonUtil.getSharedPreferences(ct, AlarmaActivity.KEY_UALAR_TIME));
|
|
int dTime = getMin(CommonUtil.getSharedPreferences(ct, AlarmaActivity.KEY_UALAR_TIME));
|
|
|
- Log.i("gongpengming", "uTime=" + uTime);
|
|
|
|
|
- Log.i("gongpengming", "dTime=" + dTime);
|
|
|
|
|
- long utime = (uTime * 60 * 1000) + (10 * 60 * 1000);//与上班时间提前的时间
|
|
|
|
|
- long dtime = (dTime * 60 * 1000) + (10 * 60 * 1000);//与下班时间延后的时间
|
|
|
|
|
|
|
+ long distcan = (10 * 60 * 1000);
|
|
|
|
|
+ long utime = (uTime * 60 * 1000);//与上班时间提前的时间
|
|
|
|
|
+ long dtime = (dTime * 60 * 1000);//与下班时间延后的时间
|
|
|
long chche = 0;//时间毫秒数
|
|
long chche = 0;//时间毫秒数
|
|
|
boolean isOk = false;
|
|
boolean isOk = false;
|
|
|
long chchelong = -1;
|
|
long chchelong = -1;
|
|
|
for (Signin e : signins) {
|
|
for (Signin e : signins) {
|
|
|
- Log.i("gongpengming", "e.getDtime()=" + e.getDtime() + " e.getUtime()" + e.getUtime());
|
|
|
|
|
- //如果上班时间-提前时间小于当前时间 说明已经过期
|
|
|
|
|
chche = TimeUtils.f_str_2_long(TimeUtils.s_long_2_str(System.currentTimeMillis()) + " " + e.getUtime() + ":00") - utime;
|
|
chche = TimeUtils.f_str_2_long(TimeUtils.s_long_2_str(System.currentTimeMillis()) + " " + e.getUtime() + ":00") - utime;
|
|
|
- if (newTime < chche) {
|
|
|
|
|
- if (chchelong != -1 && chchelong > chche) {
|
|
|
|
|
- chchelong = chche;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if (chchelong == -1) {//把最早上班时间保存下来
|
|
|
|
|
+ chchelong = chche;
|
|
|
|
|
+ } else if (chchelong > chche) {
|
|
|
|
|
+ chchelong = chche;
|
|
|
|
|
+ }
|
|
|
|
|
+ //如果上班时间-提前时间小于当前时间 说明已经过期
|
|
|
|
|
+ if (newTime < (chche - distcan)) {
|
|
|
//符合提醒
|
|
//符合提醒
|
|
|
isOk = true;
|
|
isOk = true;
|
|
|
//TODO 提醒该时间
|
|
//TODO 提醒该时间
|
|
@@ -184,7 +185,7 @@ public class AlarmReceiver extends BroadcastReceiver {
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
chche = TimeUtils.f_str_2_long(TimeUtils.s_long_2_str(System.currentTimeMillis()) + " " + e.getDtime() + ":00") + dtime;
|
|
chche = TimeUtils.f_str_2_long(TimeUtils.s_long_2_str(System.currentTimeMillis()) + " " + e.getDtime() + ":00") + dtime;
|
|
|
- if (newTime < chche) {
|
|
|
|
|
|
|
+ if (newTime < (chche - distcan)) {
|
|
|
//TODO 提醒该时间
|
|
//TODO 提醒该时间
|
|
|
isOk = true;
|
|
isOk = true;
|
|
|
setArmmanager(ct, chche);
|
|
setArmmanager(ct, chche);
|
|
@@ -201,6 +202,7 @@ public class AlarmReceiver extends BroadcastReceiver {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void setArmmanager(Context ct, long time) {
|
|
private void setArmmanager(Context ct, long time) {
|
|
|
|
|
+ Log.i("gongpengming", TimeUtils.f_long_2_str(time));
|
|
|
//操作:发送一个广播,广播接收后Toast提示定时操作完成
|
|
//操作:发送一个广播,广播接收后Toast提示定时操作完成
|
|
|
Intent intent = new Intent(ct, AlarmReceiver.class);
|
|
Intent intent = new Intent(ct, AlarmReceiver.class);
|
|
|
intent.setAction("ALARMA_ACTION");
|
|
intent.setAction("ALARMA_ACTION");
|
|
@@ -209,5 +211,4 @@ public class AlarmReceiver extends BroadcastReceiver {
|
|
|
calendar.setTimeInMillis(time);
|
|
calendar.setTimeInMillis(time);
|
|
|
alarm.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), PendingIntent.getBroadcast(ct, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT));
|
|
alarm.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), PendingIntent.getBroadcast(ct, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT));
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
}
|
|
}
|