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