Created
May 27, 2017 09:42
-
-
Save whalemare/8477f07c66504cdafc2e4bbe519b8aff to your computer and use it in GitHub Desktop.
MvpPresenter, Kotlin: how avoid check isViewAttached()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ru.whalemare.vkbirthday.mvp.presenter.base | |
import com.hannesdorfmann.mosby.mvp.MvpBasePresenter | |
import com.hannesdorfmann.mosby.mvp.MvpView | |
/** | |
* @since 2017 | |
* @author Anton Vlasov - whalemare | |
*/ | |
open class BaseMvpPresenterK<V : MvpView> : MvpBasePresenter<V>() { | |
fun isActive(body: (v: V) -> Unit) { | |
if (isViewAttached) { | |
body(view!!) | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @since 2017 | |
* @author Anton Vlasov - whalemare | |
*/ | |
class NoteMakerPresenterImpl : BaseMvpPresenterK<NoteMakerView>(), NoteMakerPresenter { | |
override fun onClickNoteView() { | |
isActive { it.showKeyboard() } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment