I'm having trouble with coming up with a idea how to solve the problem :
I'm having the following abstract class :
abstract class BasePresenter<T : BaseView>{
private lateinit var view : T
fun attachView(view : T){
this.view = view
}
fun getView() = view
}
The problem I currently have is that with this approach I have to write presenter.attachView(this) each time in an Activity, which produces boiler code .
for example
class SplashActivity : BaseActivity(), SplashActivityView {
@Inject
lateinit var splashActivityPresenter: SplashActivityPresenter
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
splashActivityPresenter.attachView(this)
splashActivityPresenter.getUser()
}
How can I solve it so that my Activities automatically call the function attachView in onCreate() ?
Aucun commentaire:
Enregistrer un commentaire