validation – AlertDialog remains open when fields are empty – Kotlin

How do I get Kotlin to keep an AlertDialog open after verifying that the EditText is empty?
and the user tried to click OK.
I'm currently using the most basic method of closing AlertDialog.
And drop a toast …

Here is the code snippet:

Override fun on Click (view: View) {
if (view.id == R.id.floatAddTeacher) {
showFormTeacher ()
}
}

private fun showFormTeacher () {
val view: View = LayoutInflater.from (this) .inflate (R.layout.dialog_add_teacher, null)
AlertDialog.Builder (this)
.setTitle ("Add teacher")
.setView (view)
.setPositiveButton ("OK") {Dialog, which ->
// I am not sure if the code in this part should be checked
// The interesting thing was to use the isBlank () function to look up and add setError ().
}
.setNegativeButton (getString (R.string.cancel), null)
.show ()

}

Layout XML:









Any help, thank you

[ Politics ] Open question: Hey, stupid beta guy in the basement crying over Star Wars supporters and defeating Trump's witch hunt. What will you do now?

[ Politics ] Open question: Hey, stupid beta guy in the basement crying over Star Wars supporters and defeating Trump's witch hunt. What will you do now? ,

[ Politics ] Open question: Why do not Trump's followers see through his steady stream of lies and BS? Obviously he does not know what he is doing and he is a career maker !!!?

[ Politics ] Open question: Why do not Trump's followers see through his steady stream of lies and BS? Obviously he does not know what he is doing and he is a career maker !!!? ,

Design – What is a good way to fulfill the Open / Closed principle in this case?

I have a class that looks like this:

Class MyClass

# performs a series of actions
initialize def (actions)
@actions = actions
The End

def act
@ actions.each {| a | a.do}
The End
The End

class action

attr_reader: type
initialize def (function, type)
@type = type
@func = func
The End

do def
@func.call
The End
The End

So far, pretty easy. However. Depending on the type, the actions must be called in different order. For example, all actions with the type "Start" must be called before all actions with the type "End". The question is, where should this logic live?

The obvious answer to me was plot Method of MyClass. But this looks very awkward:

        def act
@ actions.select {| a | a.type == "start"}. every {| a | a.do}
@ actions.select {| a | a.type == "finish"}. every {| a | a.do}
The End 

Moreover, this is against the open / closed principle, as I understand it, because if there are new types, I have to change the code in plot Method.

What other options do I have?