Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
//View interface
interface MainView : MvpView {
@StateStrategyType(AddToEndSingleStrategy::class)
fun printLog(msg: String)
}
//View implementation
class MainActivity : MvpAppCompatActivity(), MainView {
@InjectPresenter
internal lateinit var presenter: MainPresenter
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
}
override fun printLog(msg: String) {
Log.e(TAG, "$msg activity hash code ${hashCode()}")
}
companion object {
const val TAG = "MoxyDebug"
}
}
//Presenter implementation
@InjectViewState
class MainPresenter : MvpPresenter<MainView>() {
override fun onFirstViewAttach() {
super.onFirstViewAttach()
Log.e("TAG", "presenter hash code : ${hashCode()}")
viewState.printLog("TEST")
}
}
//Logs
E: presenter hash code: 147558861
E: TEST activity hash code: 196819896
//rotate screen
E: TEST activity hash code: 20903448
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.