From: Damyan Ivanov Date: Fri, 3 May 2019 15:10:29 +0000 (+0300) Subject: off-load option setting DB update to the background work queue X-Git-Tag: v0.10.0~57 X-Git-Url: https://git.ktnx.net/?a=commitdiff_plain;h=7c4845718e128abb52ec6eaed26940b53e1c5ee8;p=mobile-ledger.git off-load option setting DB update to the background work queue such an update may have to wait for the DB to complete any reads, like while loading transaction data or even transaction data retrieval. that would lead to UI freeze delaying the update has no ill effects, since the data is needed only the next time the app is run --- diff --git a/app/src/main/java/net/ktnx/mobileledger/utils/MLDB.java b/app/src/main/java/net/ktnx/mobileledger/utils/MLDB.java index 9089b9e5..b3e1bf9f 100644 --- a/app/src/main/java/net/ktnx/mobileledger/utils/MLDB.java +++ b/app/src/main/java/net/ktnx/mobileledger/utils/MLDB.java @@ -34,6 +34,7 @@ import android.widget.AutoCompleteTextView; import android.widget.FilterQueryProvider; import android.widget.SimpleCursorAdapter; +import net.ktnx.mobileledger.async.DbOpQueue; import net.ktnx.mobileledger.async.DescriptionSelectedCallback; import net.ktnx.mobileledger.model.Data; import net.ktnx.mobileledger.model.MobileLedgerProfile; @@ -114,8 +115,7 @@ public final class MLDB { } static public void setOption(String name, String value) { debug("option", String.format("%s := %s", name, value)); - SQLiteDatabase db = MLDB.getDatabase(); - db.execSQL("insert or replace into options(profile, name, value) values(?, ?, ?);", + DbOpQueue.add("insert or replace into options(profile, name, value) values(?, ?, ?);", new String[]{NO_PROFILE, name, value}); } static public void setLongOption(String name, long value) {