]> git.ktnx.net Git - mobile-ledger.git/commitdiff
save profile's order when editing a profile
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Sat, 24 Apr 2021 17:02:06 +0000 (17:02 +0000)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Sun, 25 Apr 2021 17:07:58 +0000 (17:07 +0000)
app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfileDetailModel.java

index a00ec9454b756083d0fe7d8f2df6632ad9c86d7e..2460b2e0938eb8855e1e9b000679bd819b55daec 100644 (file)
@@ -50,6 +50,7 @@ import static net.ktnx.mobileledger.db.Profile.NO_PROFILE_ID;
 public class ProfileDetailModel extends ViewModel {
     private static final String HTTPS_URL_START = "https://";
     private final MutableLiveData<String> profileName = new MutableLiveData<>();
+    private final MutableLiveData<Integer> orderNo = new MutableLiveData<>();
     private final MutableLiveData<Boolean> postingPermitted = new MutableLiveData<>(true);
     private final MutableLiveData<String> defaultCommodity = new MutableLiveData<>(null);
     private final MutableLiveData<FutureDates> futureDates =
@@ -231,6 +232,7 @@ public class ProfileDetailModel extends ViewModel {
         if (mProfile != null) {
             profileId.setValue(mProfile.getId());
             profileName.setValue(mProfile.getName());
+            orderNo.setValue(mProfile.getOrderNo());
             postingPermitted.setValue(mProfile.permitPosting());
             showCommentsByDefault.setValue(mProfile.getShowCommentsByDefault());
             showCommodityByDefault.setValue(mProfile.getShowCommodityByDefault());
@@ -256,6 +258,7 @@ public class ProfileDetailModel extends ViewModel {
         }
         else {
             profileId.setValue(NO_PROFILE_ID);
+            orderNo.setValue(-1);
             profileName.setValue(null);
             url.setValue(HTTPS_URL_START);
             postingPermitted.setValue(true);
@@ -273,6 +276,7 @@ public class ProfileDetailModel extends ViewModel {
     void updateProfile(Profile mProfile) {
         mProfile.setId(profileId.getValue());
         mProfile.setName(profileName.getValue());
+        mProfile.setOrderNo(orderNo.getValue());
         mProfile.setUrl(url.getValue());
         mProfile.setPermitPosting(postingPermitted.getValue());
         mProfile.setShowCommentsByDefault(showCommentsByDefault.getValue());