X-Git-Url: https://git.ktnx.net/?p=mobile-ledger.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fnet%2Fktnx%2Fmobileledger%2Fmodel%2FData.java;h=15d78ac034e475fde08bbf5724282189b98c6dd1;hp=24e3042ad193de358adec2ee48680187d4e53850;hb=fac0809065787fb473646db5770f4f2fae0d1e8f;hpb=25cd3a8bb9b8196cddd1f66b7757cadc8248a37f diff --git a/app/src/main/java/net/ktnx/mobileledger/model/Data.java b/app/src/main/java/net/ktnx/mobileledger/model/Data.java index 24e3042a..15d78ac0 100644 --- a/app/src/main/java/net/ktnx/mobileledger/model/Data.java +++ b/app/src/main/java/net/ktnx/mobileledger/model/Data.java @@ -17,21 +17,16 @@ package net.ktnx.mobileledger.model; -import android.database.Cursor; -import android.database.sqlite.SQLiteDatabase; - import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.lifecycle.LifecycleOwner; import androidx.lifecycle.MutableLiveData; import androidx.lifecycle.Observer; -import net.ktnx.mobileledger.App; import net.ktnx.mobileledger.async.RetrieveTransactionsTask; import net.ktnx.mobileledger.utils.LockHolder; import net.ktnx.mobileledger.utils.Locker; import net.ktnx.mobileledger.utils.Logger; -import net.ktnx.mobileledger.utils.MLDB; import java.text.NumberFormat; import java.text.ParseException; @@ -93,11 +88,9 @@ public final class Data { backgroundTasksRunning.postValue(cnt > 0); } public static void setCurrentProfile(@NonNull MobileLedgerProfile newProfile) { - MLDB.setLongOption(MLDB.OPT_PROFILE_ID, newProfile.getId()); profile.setValue(newProfile); } public static void postCurrentProfile(@NonNull MobileLedgerProfile newProfile) { - MLDB.setLongOption(MLDB.OPT_PROFILE_ID, newProfile.getId()); profile.postValue(newProfile); } public static int getProfileIndex(MobileLedgerProfile profile) { @@ -129,21 +122,6 @@ public final class Data { return -1; } } - public static int retrieveCurrentThemeIdFromDb() { - long profileId = MLDB.getLongOption(MLDB.OPT_PROFILE_ID, 0); - if (profileId == 0) - return -1; - - SQLiteDatabase db = App.getDatabase(); - try (Cursor c = db.rawQuery("SELECT theme from profiles where id=?", - new String[]{String.valueOf(profileId)})) - { - if (c.moveToNext()) - return c.getInt(0); - } - - return -1; - } @Nullable public static MobileLedgerProfile getProfile(long profileId) { MobileLedgerProfile profile; @@ -211,19 +189,6 @@ public final class Data { Observer observer) { profile.observe(lifecycleOwner, observer); } - public synchronized static MobileLedgerProfile initProfile() { - MobileLedgerProfile currentProfile = profile.getValue(); - if (currentProfile != null) - return currentProfile; - - long profileId = MLDB.getLongOption(MLDB.OPT_PROFILE_ID, 0); - MobileLedgerProfile startupProfile = getProfile(profileId); - if (startupProfile != null) - setCurrentProfile(startupProfile); - Logger.debug("profile", "initProfile() returning " + startupProfile); - return startupProfile; - } - public static void removeProfileObservers(LifecycleOwner owner) { profile.removeObservers(owner); }