]> git.ktnx.net Git - mobile-ledger.git/blobdiff - app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfileDetailFragment.java
more pronounced day/month delimiters in the transaction list
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / ui / profiles / ProfileDetailFragment.java
index 9b0b43a13b09a68fc862d382c275e0dfd362de29..99934543e7b544bf876fcc0010282d9cb373801e 100644 (file)
@@ -19,8 +19,8 @@ package net.ktnx.mobileledger.ui.profiles;
 
 import android.app.Activity;
 import android.app.AlertDialog;
+import android.app.backup.BackupManager;
 import android.graphics.Typeface;
-import android.os.AsyncTask;
 import android.os.Bundle;
 import android.text.Editable;
 import android.text.TextWatcher;
@@ -46,6 +46,7 @@ import com.google.android.material.textfield.TextInputLayout;
 
 import net.ktnx.mobileledger.BuildConfig;
 import net.ktnx.mobileledger.R;
+import net.ktnx.mobileledger.dao.BaseDAO;
 import net.ktnx.mobileledger.dao.ProfileDAO;
 import net.ktnx.mobileledger.databinding.ProfileDetailBinding;
 import net.ktnx.mobileledger.db.DB;
@@ -126,10 +127,11 @@ public class ProfileDetailFragment extends Fragment {
             dao.getById(profileId)
                .observe(getViewLifecycleOwner(), profile -> {
                    if (profile != null)
-                       AsyncTask.execute(() -> {
-                           dao.deleteSync(profile);
-                           dao.updateOrderSync(dao.getAllOrderedSync());
-                       });
+                       BaseDAO.runAsync(() -> DB.get()
+                                                .runInTransaction(() -> {
+                                                    dao.deleteSync(profile);
+                                                    dao.updateOrderSync(dao.getAllOrderedSync());
+                                                }));
                });
 
             final FragmentActivity activity = getActivity();
@@ -339,6 +341,9 @@ public class ProfileDetailFragment extends Fragment {
             if (itemId == R.id.api_version_menu_html) {
                 apiVer = API.html;
             }
+            else if (itemId == R.id.api_version_menu_1_23) {
+                apiVer = API.v1_23;
+            }
             else if (itemId == R.id.api_version_menu_1_19_1) {
                 apiVer = API.v1_19_1;
             }
@@ -399,7 +404,7 @@ public class ProfileDetailFragment extends Fragment {
         Profile profile = new Profile();
         model.updateProfile(profile);
         if (profile.getId() > 0) {
-            dao.update(profile, null);
+            dao.update(profile);
             debug("profiles", "profile stored in DB");
 //                debug("profiles", String.format("Selected item is %d", mProfile.getThemeHue()));
         }
@@ -407,6 +412,8 @@ public class ProfileDetailFragment extends Fragment {
             dao.insertLast(profile, null);
         }
 
+        BackupManager.dataChanged(BuildConfig.APPLICATION_ID);
+
         Activity activity = getActivity();
         if (activity != null)
             activity.finish();