yatatsu / AutoBundle

AutoBundle generates boilerplate code for field binding with android.os.Bundle
Apache License 2.0
135 stars 13 forks source link

My field has other Annotaions, but the generated source is gone #19

Closed hacket closed 7 years ago

hacket commented 7 years ago

I defined a @IntDef anntations @FROM_LOADING:

public class LoadingDemoActivity extends AppCompatActivity {

    @FROM_LOADING
    @AutoBundleField
    int mFrom;

    private static final int FROM_HOME_LOADING = 1;
    private static final int FROM_OTHER_LOADING = 2;

    @IntDef({FROM_HOME_LOADING, FROM_OTHER_LOADING})
    @Retention(RetentionPolicy.SOURCE)
    public @interface FROM_LOADING {
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_loading_demo);
        AutoBundle.bind(this);

        switch (mFrom) {
            case FROM_HOME_LOADING:
                // TODO: 2016/12/9  
                break;
            case FROM_OTHER_LOADING:
                // TODO: 2016/12/9  
                break;
            default:
                break;
        }
    }

}

but the createIntentBuilder(int mFrom) has not the @FROM_LOADING

// ...
public static LoadingDemoActivityAutoBundle.IntentBuilder createIntentBuilder(int mFrom) {
    return new LoadingDemoActivityAutoBundle.IntentBuilder(mFrom);
 }
// ...
public static final class IntentBuilder {
    final Bundle args;
    public IntentBuilder(int mFrom) {
      this.args = new Bundle();
      this.args.putInt("mFrom", mFrom);
    }
    // ...
}

I expected the generated source:

// ...
public static LoadingDemoActivityAutoBundle.IntentBuilder createIntentBuilder(@FROM_LOADING int mFrom) {
    return new LoadingDemoActivityAutoBundle.IntentBuilder(mFrom);
 }
// ...
public static final class IntentBuilder {
    final Bundle args;
    public IntentBuilder(@FROM_LOADING int mFrom) {
      this.args = new Bundle();
      this.args.putInt("mFrom", mFrom);
    }
    // ...
}

can you add the annotation to generated sources?

yatatsu commented 7 years ago

Sorry, any annotations are not supported now. I will think about it, but it seems to be difficult.

yatatsu commented 7 years ago

Released in 4.0.0. Please try it!