FAQ - moxy-community/Moxy GitHub Wiki
I use Fragments, and Presenter is not saved on configuration change (e.g. screen rotation).
Check for savedInstanceState
before executing your Fragment transaction:
class MyActivity {
fun onCreate(savedInstanceState: Bundle?) {
if (savedInstanceState == null) {
// execute fragment transaction
}
}
Problem
Presenter.getViewState()
always is null.
Solution
Check your Presenter is annotated with @InjectViewState
. If you don't want this annotation, then set ViewState manually using MvpPresenter<View extends MvpView>.setViewState(MvpViewState<View>)
.
Problem
Presenter annotated @InjectPresenter
is always null.
Solution
- Check Presenter has public default constructor
- Check Annotation Processor is enabled
- Check you use the same method for all annotation processors. In build.gradle file should be only one of words:
annotationProcessor
,apt
,kapt
- Check class, that contains it's field, calls
MvpDelegate
methods.MvpDelegate.onCreate(Bundle)
is required for presenter injection. (Or it can be inherited from MvpFragment or MvpActivity)
Problem
Executing gradlew assembleDebug will fail if android-apt version is 1.8 (most recent for now)
Solution
android-apt 1.8 needs in JDK 1.8. You can tell gradlew to use specific version of JDK by setting it up in gradle.properties or by adding parameter to the terminal command like:
gradlew -Dorg.gradle.java.home="path_to_jdk_home" assembleDebug
Problem
Need to use @InjectPresenter
inside ViewHolder
of RecyclerView
Solution
See these gist
Problem
Perfect tips for processing getMapAsync() callback in MapFragment
Solution
https://gist.github.com/terrakok/cd080a6a0213ef7430bdd72ebe92c9ef
Problem
Is it possible to inject presenter using Dagger instead of @InjectPresenter?