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 =
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());
}
else {
profileId.setValue(NO_PROFILE_ID);
+ orderNo.setValue(-1);
profileName.setValue(null);
url.setValue(HTTPS_URL_START);
postingPermitted.setValue(true);
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());
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);