If alarm is staledata dismis snoozes it
This commit is contained in:
parent
82541a50e4
commit
837dcdb23b
|
@ -126,7 +126,9 @@ import info.nightscout.utils.Profiler;
|
|||
import info.nightscout.utils.Round;
|
||||
import info.nightscout.utils.SP;
|
||||
import info.nightscout.utils.ToastUtils;
|
||||
|
||||
//Added By Rumen for staledata alarm
|
||||
import info.nightscout.androidaps.plugins.Overview.Notification;
|
||||
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
||||
|
||||
public class OverviewFragment extends Fragment implements View.OnClickListener, CompoundButton.OnCheckedChangeListener {
|
||||
private static Logger log = LoggerFactory.getLogger(OverviewFragment.class);
|
||||
|
@ -744,6 +746,14 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
public void run() {
|
||||
scheduleUpdateGUI("refreshLoop");
|
||||
sLoopHandler.postDelayed(sRefreshLoop, 60 * 1000L);
|
||||
// Added by Rumen for STALE DATA ALARM
|
||||
boolean isThereStaleData = Notification.isAlarmForStaleData();
|
||||
log.debug("isThereIsStaleData: "+isThereStaleData);
|
||||
if(isThereStaleData){
|
||||
Notification notification = new Notification(Notification.NSALARM, getString(R.string.nsalarm_staledata), Notification.URGENT);
|
||||
MainApp.bus().post(new EventNewNotification(notification));
|
||||
}
|
||||
// end of insert
|
||||
}
|
||||
};
|
||||
sLoopHandler.postDelayed(sRefreshLoop, 60 * 1000L);
|
||||
|
@ -1802,6 +1812,14 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
if (notification.nsAlarm != null) {
|
||||
BroadcastAckAlarm.handleClearAlarm(notification.nsAlarm, MainApp.instance().getApplicationContext(), 60 * 60 * 1000L);
|
||||
}
|
||||
// Adding current time to snooze if we got staleData
|
||||
log.debug("Notification text is: "+notification.text);
|
||||
if(notification.text == MainApp.sResources.getString(R.string.nsalarm_staledata)){
|
||||
NotificationStore nstore = getPlugin().notificationStore;
|
||||
long msToSnooze = SP.getInt("nsalarm_staledatavalue",15)*60*1000L;
|
||||
log.debug("snooze nsalarm_staledatavalue in minutes is "+SP.getInt("nsalarm_staledatavalue",15)+"\n in ms is: "+msToSnooze+" currentTimeMillis is: "+System.currentTimeMillis());
|
||||
nstore.snoozeTo(System.currentTimeMillis()+(SP.getInt("nsalarm_staledatavalue",15)*60*1000L));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1816,6 +1834,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
public void run() {
|
||||
NotificationStore nstore = getPlugin().notificationStore;
|
||||
nstore.removeExpired();
|
||||
nstore.unSnooze();
|
||||
if (nstore.store.size() > 0) {
|
||||
RecyclerViewAdapter adapter = new RecyclerViewAdapter(nstore.store);
|
||||
notificationsView.setAdapter(adapter);
|
||||
|
|
Loading…
Reference in a new issue