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 ViewStateProvider for presenters in nested classes #106

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.

Svechnikov commented 4 years ago

Hi Alexey!

You should add a unit test for the new feature you're proposing

Will do.

Why did you delete MainPresnter.kt?

Sorry, I was experimenting and I deleted it by accident :) I'll bring it back.