From 7c4845718e128abb52ec6eaed26940b53e1c5ee8 Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Fri, 3 May 2019 18:10:29 +0300 Subject: [PATCH] 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 --- app/src/main/java/net/ktnx/mobileledger/utils/MLDB.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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) { -- 2.39.5