Skip to content

Instantly share code, notes, and snippets.

@VovaStelmashchuk
Last active September 12, 2019 12:16
Show Gist options
  • Save VovaStelmashchuk/6d0da4c22dd0d7b1b87dce41b83fd379 to your computer and use it in GitHub Desktop.
Save VovaStelmashchuk/6d0da4c22dd0d7b1b87dce41b83fd379 to your computer and use it in GitHub Desktop.
//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