X-Git-Url: https://git.ktnx.net/?a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fnet%2Fktnx%2Fmobileledger%2Fui%2Fprofiles%2FProfileDetailModel.java;h=09b0a067a66256b30565fa90191b870505445915;hb=HEAD;hp=a00ec9454b756083d0fe7d8f2df6632ad9c86d7e;hpb=349a5a3aca6dab475eada68d99d59d0dff9378b3;p=mobile-ledger.git diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfileDetailModel.java b/app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfileDetailModel.java index a00ec945..09b0a067 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfileDetailModel.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfileDetailModel.java @@ -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 profileName = new MutableLiveData<>(); + private final MutableLiveData orderNo = new MutableLiveData<>(); private final MutableLiveData postingPermitted = new MutableLiveData<>(true); private final MutableLiveData defaultCommodity = new MutableLiveData<>(null); private final MutableLiveData 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()); @@ -334,8 +338,9 @@ public class ProfileDetailModel extends ViewModel { if (m.matches()) { int major = Integer.parseInt(Objects.requireNonNull(m.group(1))); int minor = Integer.parseInt(Objects.requireNonNull(m.group(2))); - final boolean hasPatch = m.groupCount() >= 3; - int patch = hasPatch ? Integer.parseInt(Objects.requireNonNull(m.group(3))) : 0; + final String patchText = m.group(3); + final boolean hasPatch = patchText != null; + int patch = hasPatch ? Integer.parseInt(patchText) : 0; return hasPatch ? new HledgerVersion(major, minor, patch) : new HledgerVersion(major, minor);