XDRIP: fix passing array
This commit is contained in:
parent
009cec2eb1
commit
9e4e122573
3 changed files with 10 additions and 7 deletions
|
@ -150,21 +150,21 @@ class DataSyncSelectorXdripImpl @Inject constructor(
|
|||
|
||||
private fun sendEntries(force: Boolean, progress: String) {
|
||||
if (preparedEntries.isNotEmpty() && (preparedEntries.size >= 100 || force)) {
|
||||
xdripPlugin.sendToXdrip("entries", preparedEntries, progress)
|
||||
xdripPlugin.sendToXdrip("entries", preparedEntries.toList(), progress)
|
||||
preparedEntries.clear()
|
||||
}
|
||||
}
|
||||
|
||||
private fun sendTreatments(force: Boolean, progress: String) {
|
||||
if (preparedTreatments.isNotEmpty() && (preparedTreatments.size >= 100 || force)) {
|
||||
xdripPlugin.sendToXdrip("treatments", preparedTreatments, progress)
|
||||
xdripPlugin.sendToXdrip("treatments", preparedTreatments.toList(), progress)
|
||||
preparedTreatments.clear()
|
||||
}
|
||||
}
|
||||
|
||||
private fun sendFoods(force: Boolean, progress: String) {
|
||||
if (preparedFoods.isNotEmpty() && (preparedFoods.size >= 100 || force)) {
|
||||
xdripPlugin.sendToXdrip("food", preparedFoods, progress)
|
||||
xdripPlugin.sendToXdrip("food", preparedFoods.toList(), progress)
|
||||
preparedFoods.clear()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package info.nightscout.plugins.sync.xdrip
|
||||
|
||||
import android.os.Bundle
|
||||
import android.os.Handler
|
||||
import android.os.HandlerThread
|
||||
import android.view.LayoutInflater
|
||||
import android.view.Menu
|
||||
import android.view.MenuInflater
|
||||
|
@ -48,6 +50,7 @@ class XdripFragment : DaggerFragment(), MenuProvider, PluginFragment {
|
|||
override var plugin: PluginBase? = null
|
||||
|
||||
private val disposable = CompositeDisposable()
|
||||
private var handler = Handler(HandlerThread(this::class.simpleName + "Handler").also { it.start() }.looper)
|
||||
|
||||
private var _binding: XdripFragmentBinding? = null
|
||||
|
||||
|
@ -78,7 +81,7 @@ class XdripFragment : DaggerFragment(), MenuProvider, PluginFragment {
|
|||
context?.let { context ->
|
||||
OKDialog.showConfirmation(
|
||||
context, rh.gs(R.string.ns_client), rh.gs(R.string.full_sync_comment),
|
||||
Thread { dataSyncSelector.resetToNextFullSync() }
|
||||
Runnable { handler.post { dataSyncSelector.resetToNextFullSync() } }
|
||||
)
|
||||
}
|
||||
true
|
||||
|
|
|
@ -362,7 +362,7 @@ class XdripPlugin @Inject constructor(
|
|||
|
||||
private fun sendEntries(dataPairs: List<DataSyncSelector.DataPair>, progress: String) {
|
||||
val array = JSONArray()
|
||||
for (dataPair in dataPairs.toList()) {
|
||||
for (dataPair in dataPairs) {
|
||||
val data = (dataPair as DataSyncSelector.PairGlucoseValue).value.toXdripJson()
|
||||
array.put(data)
|
||||
}
|
||||
|
@ -376,7 +376,7 @@ class XdripPlugin @Inject constructor(
|
|||
|
||||
private fun sendFood(dataPairs: List<DataSyncSelector.DataPair>, progress: String) {
|
||||
val array = JSONArray()
|
||||
for (dataPair in dataPairs.toList()) {
|
||||
for (dataPair in dataPairs) {
|
||||
val data = (dataPair as DataSyncSelector.PairFood).value.toJson(true)
|
||||
array.put(data)
|
||||
}
|
||||
|
@ -390,7 +390,7 @@ class XdripPlugin @Inject constructor(
|
|||
|
||||
private fun sendTreatments(dataPairs: List<DataSyncSelector.DataPair>, progress: String) {
|
||||
val array = JSONArray()
|
||||
for (dataPair in dataPairs.toList()) {
|
||||
for (dataPair in dataPairs) {
|
||||
when (dataPair) {
|
||||
is DataSyncSelector.PairBolus -> dataPair.value.toJson(true, dateUtil)
|
||||
is DataSyncSelector.PairCarbs -> dataPair.value.toJson(true, dateUtil)
|
||||
|
|
Loading…
Reference in a new issue