UdhayaBalaji / androidannotations

Automatically exported from code.google.com/p/androidannotations
0 stars 0 forks source link

Warnings with OnXXXListeners in @EViewGroup generated subclasses #144

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Warnings with OnXXXListeners in @EViewGroup generated subclasses

Code example:

@EViewGroup(R.layout.component)
public class MyEnhancedLayout extends FrameLayout {

    @Click
    public void title() {
    }

}

*****************
Generated code:

public final class BasicComponent_
    extends BasicComponent
{

    public BasicComponent_(Context context, int i) {
        super(context, i);
    }

    private void afterSetContentView_() {

        {
            View view = findViewById(id.title);
            if (view!= null) {
                view.setOnClickListener(new OnClickListener() {

                    public void onClick(View view) {
                        title();
                    }

                }
                );
            }
        }
    }

    @Override
    public void onFinishInflate() {
        inflate(getContext(), layout.component, this);
        afterSetContentView_();
        super.onFinishInflate();
    }

}

CodeModel adds an import to "import android.view.View.OnClickListener;" in the 
generated code. OnClickListener is an inner class of View, and since a 
ViewGroup extends View, this import is not needed, because OnClickListener is 
visible from any View subclass.

Therefore, we have the following warning in the generated class :

The import android.view.View.OnClickListener is never used

Same thing for @LongClick, @Touch, etc.

We'll have to dig through CodeModel source to see if we can do anything about 
that (maybe using reflection...), or if we should submit a patch to CodeModel.

Original issue reported on code.google.com by py.ricau on 8 Dec 2011 at 11:23

GoogleCodeExporter commented 8 years ago
https://github.com/excilys/androidannotations/issues/21

Original comment by py.ricau on 6 Jan 2012 at 11:06