Last active
September 12, 2019 12:16
-
-
Save VovaStelmashchuk/6d0da4c22dd0d7b1b87dce41b83fd379 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
//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