mythos
A simple Model-View-Presenter library for Android apps.
Setup
Core requirements for the basic implementation:
repositories {
maven { url "https://jitpack.io" }
}
dependencies {
implementation "com.github.jhavatar.mythos:mvp:1.2.0"
}
For a ViewModel based implementation, also include
implementation "com.github.jhavatar.mythos:viewmodel:1.2.0"
Introduction
Mythos is a tiny library that simplifies managing an Android-UI MVP pattern. Each MVP relationship requires:
- implementing interface Presenter
- implementing interface Vu (named to not confuse with all Android's "View" class)
- and calling a MVPDispatcher<Presenter, Vu> instance from the basic UI lifecycle callbacks.
Optional prefab implementations of MVPActivity, MVPFragment and MVPLayout are also available.
See the Kotlin or Java example in the project for a guide.
Life cycles
MVPDispatcher typical life cycle
- restorePresenterState()
- createVu()
- linkPresenter()
- unlinkPresenter()
- destroyVu()
- savePresenterState()
- destroyPresenterIfRequired()
Presenter callbacks
- onLink()
- onUnlink()
- onSaveState()
- onDestroy()
Vu callbacks
- onCreate()
- onDestroy()
Change log
v1.2.0
- Switch from support lib to AndroidX
v1.1.6
- Removed deprecated
PresenterLoad
andPresenterCacheLoaderCallback
- Libary updates
v1.1.5
- Added helper method
getViewModelPresenterCache
onPesenterCacheViewModel
to easily create and get PresenterCache associated with activity or fragment - Added method
firstLinkWithVu
onPresenter
- Library updates
v1.1.4
- Added
PresenterCacheViewModel
which uses Android architecture'sViewModel
- Added
PresenterCacheLazy
which lazy-loads thePresenter
- Removed
FragmentWrapper
since standardFragment
has been deprecated. - Deprecated
PresenterLoad
andPresenterCacheLoaderCallback
- Libary updates