Commit dea1edbf authored by Mygod's avatar Mygod

Fix NPE yet again

parent 551bba31
...@@ -169,15 +169,18 @@ class CustomRulesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener, ...@@ -169,15 +169,18 @@ class CustomRulesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener,
inputLayout.error = message inputLayout.error = message
} }
override fun ret(which: Int) = if (which != DialogInterface.BUTTON_POSITIVE) null else { override fun ret(which: Int) = when (which) {
AclEditResult(editText.text.toString().let { text -> DialogInterface.BUTTON_POSITIVE, DialogInterface.BUTTON_NEUTRAL -> {
when (Template.values()[templateSelector.selectedItemPosition]) { AclEditResult(editText.text.toString().let { text ->
Template.Generic -> AclItem(text) when (Template.values()[templateSelector.selectedItemPosition]) {
Template.Domain -> AclItem(IDN.toASCII(text, IDN.ALLOW_UNASSIGNED or IDN.USE_STD3_ASCII_RULES) Template.Generic -> AclItem(text)
.replace(".", "\\.").let { "(^|\\.)$it\$" }) Template.Domain -> AclItem(IDN.toASCII(text, IDN.ALLOW_UNASSIGNED or IDN.USE_STD3_ASCII_RULES)
Template.Url -> AclItem(text, true) .replace(".", "\\.").let { "(^|\\.)$it\$" })
} Template.Url -> AclItem(text, true)
}, arg) }
}, arg)
}
else -> null
} }
override fun onClick(dialog: DialogInterface?, which: Int) { override fun onClick(dialog: DialogInterface?, which: Int) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment