DSpotDevelopers / declex

DecleX - Declarative Framework for Android, easier and faster coding.
Other
168 stars 25 forks source link

@Export should support "onlyIn" parameter #238

Open smaugho opened 6 years ago

smaugho commented 6 years ago

The @Export annotation should permit to specify in which classes it should Export the method. For instance, commonly some methods are intended to be used only in an activity, but the class itself can be used in many different classes (Fragments, ViewModels), for instance:

    @Export
    @RunWith("onActivityResult")
    public void facebookLoginOnActivityResult(int requestCode, int resultCode, Intent data) {
        if (callbackManager != null) {
            callbackManager.onActivityResult(requestCode, resultCode, data);
        }
    }

Currently, if you inject a class which has this into another class (ie: a ViewModel), it will try to export the "facebookLoginOnActivityResult" method there (even if it is not used). This causes unnecessary grow of the generated code.

It would be good to have something like:

@Export(onlyIn={Activity.class, SomeOther.class})
...

So, it will export the method only for the given classes or its subclasses.