fix objectives fragment

This commit is contained in:
Milos Kozak 2019-10-24 21:36:44 +02:00
parent 2a7a004afd
commit e84e59b4ca

View file

@ -208,48 +208,60 @@ class ObjectivesFragment : Fragment() {
holder.verify.setOnClickListener { holder.verify.setOnClickListener {
holder.verify.visibility = View.INVISIBLE holder.verify.visibility = View.INVISIBLE
NetworkChangeReceiver.fetch() NetworkChangeReceiver.fetch()
SntpClient.ntpTime(object : SntpClient.Callback() { if (objectives_fake.isChecked) {
override fun run() { objective.accomplishedOn = DateUtil.now()
activity?.runOnUiThread { notifyDataSetChanged()
holder.verify.visibility = View.VISIBLE scrollToCurrentObjective()
log.debug("NTP time: $time System time: ${DateUtil.now()}") startUpdateTimer()
if (!networkConnected && !objectives_fake.isChecked) { } else
ToastUtils.showToastInUiThread(context, R.string.notconnected) SntpClient.ntpTime(object : SntpClient.Callback() {
} else if (success) { override fun run() {
if (objective.isCompleted(time) || objectives_fake.isChecked) { activity?.runOnUiThread {
objective.accomplishedOn = time holder.verify.visibility = View.VISIBLE
notifyDataSetChanged() log.debug("NTP time: $time System time: ${DateUtil.now()}")
scrollToCurrentObjective() if (!networkConnected) {
startUpdateTimer() ToastUtils.showToastInUiThread(context, R.string.notconnected)
} else if (success) {
if (objective.isCompleted(time)) {
objective.accomplishedOn = time
notifyDataSetChanged()
scrollToCurrentObjective()
startUpdateTimer()
} else {
ToastUtils.showToastInUiThread(context, R.string.requirementnotmet)
}
} else { } else {
ToastUtils.showToastInUiThread(context, R.string.requirementnotmet) ToastUtils.showToastInUiThread(context, R.string.failedretrievetime)
} }
} else {
ToastUtils.showToastInUiThread(context, R.string.failedretrievetime)
} }
} }
} }, NetworkChangeReceiver.isConnected())
}, NetworkChangeReceiver.isConnected())
} }
holder.start.setOnClickListener { holder.start.setOnClickListener {
holder.start.visibility = View.INVISIBLE holder.start.visibility = View.INVISIBLE
NetworkChangeReceiver.fetch() NetworkChangeReceiver.fetch()
SntpClient.ntpTime(object : SntpClient.Callback() { SntpClient.ntpTime(object : SntpClient.Callback() {
override fun run() { override fun run() {
activity?.runOnUiThread { if (objectives_fake.isChecked) {
holder.start.visibility = View.VISIBLE objective.startedOn = time
log.debug("NTP time: $time System time: ${DateUtil.now()}") notifyDataSetChanged()
if (!networkConnected && !objectives_fake.isChecked) { scrollToCurrentObjective()
ToastUtils.showToastInUiThread(context, R.string.notconnected) startUpdateTimer()
} else if (success) { } else
objective.startedOn = time activity?.runOnUiThread {
notifyDataSetChanged() holder.start.visibility = View.VISIBLE
scrollToCurrentObjective() log.debug("NTP time: $time System time: ${DateUtil.now()}")
startUpdateTimer() if (!networkConnected) {
} else { ToastUtils.showToastInUiThread(context, R.string.notconnected)
ToastUtils.showToastInUiThread(context, R.string.failedretrievetime) } else if (success) {
objective.startedOn = time
notifyDataSetChanged()
scrollToCurrentObjective()
startUpdateTimer()
} else {
ToastUtils.showToastInUiThread(context, R.string.failedretrievetime)
}
} }
}
} }
}, NetworkChangeReceiver.isConnected()) }, NetworkChangeReceiver.isConnected())
} }