Automatic stopping of NDA timer after 24 hours now working - there may be an issue with re-starting it by selecting the NDA logging settings check box though - crash to do with starting foreground service...
This commit is contained in:
@@ -1104,7 +1104,9 @@ public class LogManager {
|
|||||||
.getDefaultSharedPreferences(mContext);
|
.getDefaultSharedPreferences(mContext);
|
||||||
mNDATimerStartTime = SP.getLong("NDATimerStartTime", 0);
|
mNDATimerStartTime = SP.getLong("NDATimerStartTime", 0);
|
||||||
if (mNDATimerStartTime == 0) {
|
if (mNDATimerStartTime == 0) {
|
||||||
mNDATimerStartTime = new Time(Time.getCurrentTimezone()).toMillis(true);
|
Time timeNow = new Time(Time.getCurrentTimezone());
|
||||||
|
timeNow.setToNow();
|
||||||
|
mNDATimerStartTime = timeNow.toMillis(true);
|
||||||
SharedPreferences.Editor editor = SP.edit();
|
SharedPreferences.Editor editor = SP.edit();
|
||||||
editor.putLong("NDATimerStartTime", mNDATimerStartTime);
|
editor.putLong("NDATimerStartTime", mNDATimerStartTime);
|
||||||
editor.apply();
|
editor.apply();
|
||||||
@@ -1245,7 +1247,7 @@ public class LogManager {
|
|||||||
*/
|
*/
|
||||||
private class NDATimer extends CountDownTimer {
|
private class NDATimer extends CountDownTimer {
|
||||||
// FIXME - NDA Log Period hard coded!
|
// FIXME - NDA Log Period hard coded!
|
||||||
private double mNDALogPeriodHours = 0.1;
|
private double mNDALogPeriodHours = 24.0;
|
||||||
|
|
||||||
public NDATimer(long startTime, long interval) {
|
public NDATimer(long startTime, long interval) {
|
||||||
super(startTime, interval);
|
super(startTime, interval);
|
||||||
@@ -1261,8 +1263,11 @@ public class LogManager {
|
|||||||
Log.d(TAG, "mNDATimer - onFinish - Recording a Normal Daily Activity Event");
|
Log.d(TAG, "mNDATimer - onFinish - Recording a Normal Daily Activity Event");
|
||||||
createNDAEvent();
|
createNDAEvent();
|
||||||
// Check if we have been logging NDA events for more than the set limit.
|
// Check if we have been logging NDA events for more than the set limit.
|
||||||
long tNow = new Time(Time.getCurrentTimezone()).toMillis(true);
|
Time timeNow = new Time(Time.getCurrentTimezone());
|
||||||
double tDiffHrs = (tNow - mNDATimerStartTime) / (3600.*1000.);
|
timeNow.setToNow();
|
||||||
|
long tNow = timeNow.toMillis(true);
|
||||||
|
long tDiffMillis = (tNow - mNDATimerStartTime);
|
||||||
|
double tDiffHrs = tDiffMillis / (3600.*1000.);
|
||||||
if (tDiffHrs >= mNDALogPeriodHours) {
|
if (tDiffHrs >= mNDALogPeriodHours) {
|
||||||
Log.i(TAG, "mNDATimer - onFinish - NDA logging period completed - switching off NDA Logging");
|
Log.i(TAG, "mNDATimer - onFinish - NDA logging period completed - switching off NDA Logging");
|
||||||
SharedPreferences SP = PreferenceManager
|
SharedPreferences SP = PreferenceManager
|
||||||
@@ -1273,7 +1278,7 @@ public class LogManager {
|
|||||||
editor.apply();
|
editor.apply();
|
||||||
} else {
|
} else {
|
||||||
// Restart this timer.
|
// Restart this timer.
|
||||||
Log.i(TAG,"NDATimer - tdiffHrs = "+tDiffHrs+ ", tnow="+tNow+", tstrt="+mNDATimerStartTime+", NDALogPeriod="+mNDALogPeriodHours);
|
Log.i(TAG,"NDATimer - tDiffMillis="+tDiffMillis+", tdiffHrs = "+tDiffHrs+ ", tnow="+tNow+", tstart="+mNDATimerStartTime+", NDALogPeriod="+mNDALogPeriodHours);
|
||||||
Log.i(TAG,"NDATimer - re-starting NDA timer");
|
Log.i(TAG,"NDATimer - re-starting NDA timer");
|
||||||
start();
|
start();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user