allow revert objective
This commit is contained in:
parent
034c16690f
commit
c23794fa6e
|
@ -225,8 +225,9 @@ class ObjectivesFragment : Fragment() {
|
|||
SntpClient.ntpTime(object : SntpClient.Callback() {
|
||||
override fun run() {
|
||||
log.debug("NTP time: $time System time: ${DateUtil.now()}")
|
||||
SystemClock.sleep(300)
|
||||
if (!networkConnected) {
|
||||
RxBus.send(EventNtpStatus(MainApp.gs(R.string.notconnected), 100))
|
||||
RxBus.send(EventNtpStatus(MainApp.gs(R.string.notconnected), 99))
|
||||
} else if (success) {
|
||||
if (objective.isCompleted(time)) {
|
||||
objective.accomplishedOn = time
|
||||
|
@ -236,10 +237,10 @@ class ObjectivesFragment : Fragment() {
|
|||
SystemClock.sleep(100)
|
||||
scrollToCurrentObjective()
|
||||
} else {
|
||||
RxBus.send(EventNtpStatus(MainApp.gs(R.string.requirementnotmet), 100))
|
||||
RxBus.send(EventNtpStatus(MainApp.gs(R.string.requirementnotmet), 99))
|
||||
}
|
||||
} else {
|
||||
RxBus.send(EventNtpStatus(MainApp.gs(R.string.failedretrievetime), 100))
|
||||
RxBus.send(EventNtpStatus(MainApp.gs(R.string.failedretrievetime), 99))
|
||||
}
|
||||
}
|
||||
}, NetworkChangeReceiver.isConnected())
|
||||
|
@ -261,26 +262,29 @@ class ObjectivesFragment : Fragment() {
|
|||
SntpClient.ntpTime(object : SntpClient.Callback() {
|
||||
override fun run() {
|
||||
log.debug("NTP time: $time System time: ${DateUtil.now()}")
|
||||
SystemClock.sleep(300)
|
||||
if (!networkConnected) {
|
||||
RxBus.send(EventNtpStatus(MainApp.gs(R.string.notconnected), 100))
|
||||
RxBus.send(EventNtpStatus(MainApp.gs(R.string.notconnected), 99))
|
||||
} else if (success) {
|
||||
objective.startedOn = time
|
||||
RxBus.send(EventNtpStatus(MainApp.gs(R.string.success), 100))
|
||||
SystemClock.sleep(1000)
|
||||
RxBus.send(EventObjectivesUpdateGui())
|
||||
SystemClock.sleep(100)
|
||||
scrollToCurrentObjective()
|
||||
objective.startedOn = time
|
||||
RxBus.send(EventNtpStatus(MainApp.gs(R.string.success), 100))
|
||||
SystemClock.sleep(1000)
|
||||
RxBus.send(EventObjectivesUpdateGui())
|
||||
SystemClock.sleep(100)
|
||||
scrollToCurrentObjective()
|
||||
} else {
|
||||
RxBus.send(EventNtpStatus(MainApp.gs(R.string.failedretrievetime), 100))
|
||||
RxBus.send(EventNtpStatus(MainApp.gs(R.string.failedretrievetime), 99))
|
||||
}
|
||||
}
|
||||
}, NetworkChangeReceiver.isConnected())
|
||||
}.start()
|
||||
}
|
||||
holder.unStart.setOnClickListener {
|
||||
objective.startedOn = 0
|
||||
scrollToCurrentObjective()
|
||||
RxBus.send(EventObjectivesUpdateGui())
|
||||
OKDialog.showConfirmation(activity, MainApp.gs(R.string.doyouwantresetstart)) {
|
||||
objective.startedOn = 0
|
||||
scrollToCurrentObjective()
|
||||
RxBus.send(EventObjectivesUpdateGui())
|
||||
}
|
||||
}
|
||||
holder.unFinish.setOnClickListener {
|
||||
objective.accomplishedOn = 0
|
||||
|
|
|
@ -42,6 +42,7 @@ class NtpProgressDialog : DialogFragment() {
|
|||
overview_bolusprogress_status.setText(state)
|
||||
overview_bolusprogress_progressbar.setMax(100)
|
||||
overview_bolusprogress_progressbar.setProgress(percent)
|
||||
overview_bolusprogress_stop.text = MainApp.gs(R.string.close)
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
|
|
|
@ -16,12 +16,16 @@ package info.nightscout.androidaps.utils;
|
|||
*/
|
||||
|
||||
import android.os.SystemClock;
|
||||
import android.util.Log;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.net.DatagramPacket;
|
||||
import java.net.DatagramSocket;
|
||||
import java.net.InetAddress;
|
||||
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
|
||||
/**
|
||||
* {@hide}
|
||||
* <p>
|
||||
|
@ -35,7 +39,7 @@ import java.net.InetAddress;
|
|||
* </pre>
|
||||
*/
|
||||
public class SntpClient {
|
||||
private static final String TAG = "SntpClient";
|
||||
private static Logger log = LoggerFactory.getLogger(L.CORE);
|
||||
|
||||
//private static final int REFERENCE_TIME_OFFSET = 16;
|
||||
private static final int ORIGINATE_TIME_OFFSET = 24;
|
||||
|
@ -76,8 +80,10 @@ public class SntpClient {
|
|||
}
|
||||
|
||||
static void doNtpTime(final Callback callback) {
|
||||
log.debug("Time detection started");
|
||||
callback.success = requestTime("time.google.com", 5000);
|
||||
callback.time = getNtpTime() + SystemClock.elapsedRealtime() - getNtpTimeReference();
|
||||
log.debug("Time detection ended: " + callback.success + " " + DateUtil.dateAndTimeString(getNtpTime()));
|
||||
callback.run();
|
||||
}
|
||||
|
||||
|
@ -138,7 +144,7 @@ public class SntpClient {
|
|||
mNtpTimeReference = responseTicks;
|
||||
mRoundTripTime = roundTripTime;
|
||||
} catch (Exception e) {
|
||||
Log.d(TAG, "request time failed: " + e);
|
||||
log.debug("request time failed: " + e);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -1634,5 +1634,6 @@
|
|||
<string name="objectives_button_unfinish">Clear finished</string>
|
||||
<string name="objectives_button_unstart">Clear started</string>
|
||||
<string name="timedetection">Time detection</string>
|
||||
<string name="doyouwantresetstart">Do you want reset objective start? You may lose your progress.</string>
|
||||
|
||||
</resources>
|
||||
|
|
Loading…
Reference in a new issue