Source:
private void showCreateEditDialog(@Nullable Category editCategory) { boolean isEdit = editCategory != null; final BetterDialogBuilder innerBuilder = new BetterDialogBuilder(getActivity()); final LinearLayout layout = new LinearLayout(getActivity()); layout.setOrientation(LinearLayout.VERTICAL); layout.setGravity(Gravity.BOTTOM); layout.setPadding(6, 6, 6, 6); final TextView nameLabel = new TextView(getActivity()); nameLabel.setText(R.string.item_name); final EditText nameBox = new EditText(getActivity()); nameBox.setText(isEdit ? editCategory.getName() : ""); final TextView codeLabel = new TextView(getActivity()); codeLabel.setText(R.string.item_code); final EditText codeBox = new EditText(getActivity()); codeBox.setText(isEdit ? editCategory.getCode() : ""); layout.addView(nameLabel); layout.addView(nameBox); layout.addView(codeLabel); layout.addView(codeBox); innerBuilder.setTitle(isEdit ? R.string.dialog_category_edit : R.string.dialog_category_add) .setView(layout) .setCancelable(true) .setPositiveButton(isEdit ? R.string.update : R.string.add, (dialog, which) -> { final String newName = nameBox.getText().toString(); final String newCode = codeBox.getText().toString(); final CategoryBuilderFactory categoryBuilderFactory = new CategoryBuilderFactory() .setName(newName) .setCode(newCode) .setCustomOrderId(isEdit ? editCategory.getCustomOrderId() : Long.MAX_VALUE); if (isEdit) categoryBuilderFactory.setUuid(editCategory.getUuid()); final Category category = categoryBuilderFactory.build(); if (isEdit) { categoriesTableController.update(editCategory, category, new DatabaseOperationMetadata()); } else { categoriesTableController.insert(category, new DatabaseOperationMetadata()); scrollToEnd(); } }) .setNegativeButton(android.R.string.cancel, (dialog, which) -> dialog.cancel()) .show(); }

Target:
private void showCreateEditDialog(@Nullable Category editCategory) { boolean isEdit = editCategory != null; final BetterDialogBuilder innerBuilder = new BetterDialogBuilder(getActivity()); final LinearLayout layout = new LinearLayout(getActivity()); layout.setOrientation(LinearLayout.VERTICAL); layout.setGravity(Gravity.BOTTOM); layout.setPadding(6, 6, 6, 6); final TextView nameLabel = new TextView(getActivity()); nameLabel.setText(R.string.item_name); final EditText nameBox = new EditText(getActivity()); nameBox.setText(isEdit ? editCategory.getName() : ""); final TextView codeLabel = new TextView(getActivity()); codeLabel.setText(R.string.item_code); final EditText codeBox = new EditText(getActivity()); codeBox.setText(isEdit ? editCategory.getCode() : ""); layout.addView(nameLabel); layout.addView(nameBox); layout.addView(codeLabel); layout.addView(codeBox); innerBuilder.setTitle(isEdit ? R.string.dialog_category_edit : R.string.dialog_category_add) .setView(layout) .setCancelable(true) .setPositiveButton(isEdit ? R.string.update : R.string.add, (dialog, which) -> { final String newName = nameBox.getText().toString(); final String newCode = codeBox.getText().toString(); final CategoryBuilderFactory categoryBuilderFactory = new CategoryBuilderFactory() .setName(newName) .setCode(newCode) .setCustomOrderId(isEdit ? editCategory.getCustomOrderId() : Long.MAX_VALUE); if (isEdit) { categoryBuilderFactory.setUuid(editCategory.getUuid()); } final Category category = categoryBuilderFactory.build(); if (isEdit) { categoriesTableController.update(editCategory, category, new DatabaseOperationMetadata()); } else { categoriesTableController.insert(category, new DatabaseOperationMetadata()); scrollToEnd(); } }) .setNegativeButton(android.R.string.cancel, (dialog, which) -> dialog.cancel()) .show(); }