Compiler error in generated code when using BindView and OnClick annotations in the same class both for View.No_ID
#839 opened on Jan 3, 2017
Description
With the following Class:
public class TestClass {
@BindView(View.NO_ID)View view;
public TestClass(View view){
ButterKnife.bind(this,view);
}
@OnClick(View.NO_ID)
public void onClick(View view){
}
}
The code generated by butterknife contains the following constructor:
@UiThread
public TestClass_ViewBinding(final T target, View source) {
this.target = target;
target.view = view;
viewSource = source;
source.setOnClickListener(new DebouncingOnClickListener() {
@Override
public void doClick(View p0) {
target.onClick(p0);
}
});
}
which does not compile since view is not defined. Based on the correctly generated code for when either @BindView or @OnClick are removed or given an id, It should be source
This also occurs if @OnClick is given no arguments (AFAIK since the default id for @OnClick is View.No_ID anyway)
Am I correct in thinking that giving @BindView and @OnClick View.No_ID as the view id means they will be applied to the root of the view given to ButterKnife.bind? If so, can you please make View.No_ID the default value for @BindView like it is for @OnClick? I expected this to be the case after reading #318
Since giving @OnClick no id or View.NO_ID binds it to the root view, can you please make that also true for @BindView or make an @BindRootView or similar?