moxy-community / Moxy

Moxy is MVP library for Android with incremental annotation processor and ktx features
MIT License
324 stars 33 forks source link

Generate view state providers for nested presenters #108

Closed Svechnikov closed 4 years ago

Svechnikov commented 4 years ago

Currently, moxy compiler doesn't generate correct ViewStateProvider classes for nested presenters, which leads to a NPE at runtime when trying to access view state.

By "nested" I mean defined in an interface or another class:

class SomeClass {
    class MainPresenter : MvpPresenter<MainView>() {
        ...
    }
}

or

interface SomeInterface {
    class MainPresenter : MvpPresenter<MainView>() {
        ...
    }
}

We can easily fix this by taking into account enclosing classes.

The proposed solution doesn't break anything and works for both nested and non-nested presenters.

This is a new pull request following the discussion in https://github.com/moxy-community/Moxy/pull/106 For some reason github wouldn't update my first pull request even though I updated my branch, hence I closed https://github.com/moxy-community/Moxy/pull/106 and created this new PR.