final ViewModelStoreOwner viewModelStoreOwner =
controller.getViewModelStoreOwner(R.id.template_list_navigation);
mViewModel = new ViewModelProvider(viewModelStoreOwner).get(TemplateDetailsViewModel.class);
- mViewModel.setDefaultPatternName(getString(R.string.unnamed_template));
+ mViewModel.setDefaultTemplateName(getString(R.string.unnamed_template));
Logger.debug("flow", "PatternDetailsFragment.onCreateView(): model=" + mViewModel);
b = TemplateDetailsFragmentBinding.inflate(inflater);
import net.ktnx.mobileledger.db.TemplateWithAccounts;
import net.ktnx.mobileledger.model.TemplateDetailsItem;
import net.ktnx.mobileledger.utils.Logger;
+import net.ktnx.mobileledger.utils.Misc;
import java.util.ArrayList;
import java.util.Collections;
new MutableLiveData<>(Collections.emptyList());
private final AtomicInteger syntheticItemId = new AtomicInteger(0);
private Long mPatternId;
- private String mDefaultPatternName;
+ private String mDefaultTemplateName;
private boolean itemsLoaded = false;
- public String getDefaultPatternName() {
- return mDefaultPatternName;
+ public String getDefaultTemplateName() {
+ return mDefaultTemplateName;
}
- public void setDefaultPatternName(String name) {
- mDefaultPatternName = name;
+ public void setDefaultTemplateName(String name) {
+ mDefaultTemplateName = name;
}
public void resetItems() {
if (srcList.size() < 1) {
final TemplateDetailsItem.Header header = TemplateDetailsItem.createHeader();
- header.setName(mDefaultPatternName);
header.setId(0);
newList.add(header);
changes = true;
TemplateDetailsItem.Header modelHeader = list.get(0)
.asHeaderItem();
+ modelHeader.setName(Misc.trim(modelHeader.getName()));
+ if (modelHeader.getName().isEmpty())
+ modelHeader.setName(getDefaultTemplateName());
TemplateHeaderDAO headerDAO = DB.get()
.getTemplateDAO();
TemplateHeader dbHeader = modelHeader.toDBO();