In some Fragments and other classes (in Java) I have a public interface ISomeActions
with functions that I then call from some other parts in that class, to denote actions. So, I have a ISomeListener listener
that I set in the constructor, or right after I create an object of SomeClass
. How can I achieve this in Kotlin?
Example:
public class SomeClass{
public ISomeListener listener;
public interface ISomeListener{
public void doSomething();
}
void actuallyDoSomething(){
listener.doSomething();
}
}
I think I can use a lateinit var listener : SomeListener
, but I don't know if that would be adequate. The member is an Interface, and not an implementation of that Interface in case it's called after the Activity finishes.