use of butterknife.compiler.ButterKnifeProcessor in project butterknife by JakeWharton.
the class OnItemClickTest method onClickRootViewBinding.
@Test
public void onClickRootViewBinding() {
JavaFileObject source = JavaFileObjects.forSourceString("test.Test", "" + "package test;\n" + "import android.content.Context;\n" + "import android.widget.ListView;\n" + "import butterknife.OnItemClick;\n" + "public class Test extends ListView {\n" + " @OnItemClick void doStuff() {}\n" + " public Test(Context context) {\n" + " super(context);\n" + " }\n" + "}");
JavaFileObject bindingSource = JavaFileObjects.forSourceString("test/Test_ViewBinding", "" + "package test;\n" + "import android.support.annotation.CallSuper;\n" + "import android.support.annotation.UiThread;\n" + "import android.view.View;\n" + "import android.widget.AdapterView;\n" + "import butterknife.Unbinder;\n" + "import java.lang.IllegalStateException;\n" + "import java.lang.Override;\n" + "public class Test_ViewBinding implements Unbinder {\n" + " private Test target;\n" + " private View viewSource;\n" + " @UiThread\n" + " public Test_ViewBinding(Test target) {\n" + " this(target, target);\n" + " }\n" + " @UiThread\n" + " public Test_ViewBinding(final Test target, View source) {\n" + " this.target = target;\n" + " viewSource = source;\n" + " ((AdapterView<?>) source).setOnItemClickListener(new AdapterView.OnItemClickListener() {\n" + " @Override\n" + " public void onItemClick(AdapterView<?> p0, View p1, int p2, long p3) {\n" + " target.doStuff();\n" + " }\n" + " });\n" + " }\n" + " @Override\n" + " @CallSuper\n" + " public void unbind() {\n" + " if (target == null) throw new IllegalStateException(\"Bindings already cleared.\");\n" + " target = null;\n" + " ((AdapterView<?>) viewSource).setOnItemClickListener(null);\n" + " viewSource = null;\n" + " }\n" + "}");
assertAbout(javaSource()).that(source).withCompilerOptions("-Xlint:-processing").processedWith(new ButterKnifeProcessor()).compilesWithoutWarnings().and().generatesSources(bindingSource);
}
use of butterknife.compiler.ButterKnifeProcessor in project butterknife by JakeWharton.
the class OnItemClickTest method onItemClickBindingWithParameterSubset.
@Test
public void onItemClickBindingWithParameterSubset() {
JavaFileObject source = JavaFileObjects.forSourceString("test.Test", "" + "package test;\n" + "import android.view.View;\n" + "import android.widget.ListView;\n" + "import butterknife.OnItemClick;\n" + "public class Test {\n" + " @OnItemClick(1) void doStuff(\n" + " ListView parent,\n" + " int position\n" + " ) {}\n" + "}");
JavaFileObject bindingSource = JavaFileObjects.forSourceString("test/Test_ViewBinding", "" + "package test;\n" + "import android.support.annotation.CallSuper;\n" + "import android.support.annotation.UiThread;\n" + "import android.view.View;\n" + "import android.widget.AdapterView;\n" + "import android.widget.ListView;\n" + "import butterknife.Unbinder;\n" + "import butterknife.internal.Utils;\n" + "import java.lang.IllegalStateException;\n" + "import java.lang.Override;\n" + "public class Test_ViewBinding implements Unbinder {\n" + " private Test target;\n" + " private View view1;\n" + " @UiThread\n" + " public Test_ViewBinding(final Test target, View source) {\n" + " this.target = target;\n" + " View view;\n" + " view = Utils.findRequiredView(source, 1, \"method 'doStuff'\");\n" + " view1 = view;\n" + " ((AdapterView<?>) view).setOnItemClickListener(new AdapterView.OnItemClickListener() {\n" + " @Override\n" + " public void onItemClick(AdapterView<?> p0, View p1, int p2, long p3) {\n" + " target.doStuff(Utils.<ListView>castParam(p0, \"onItemClick\", 0, \"doStuff\", 0), p2);\n" + " }\n" + " });\n" + " }\n" + " @Override\n" + " @CallSuper\n" + " public void unbind() {\n" + " if (target == null) throw new IllegalStateException(\"Bindings already cleared.\");\n" + " target = null;\n" + " ((AdapterView<?>) view1).setOnItemClickListener(null);\n" + " view1 = null;\n" + " }\n" + "}");
assertAbout(javaSource()).that(source).withCompilerOptions("-Xlint:-processing").processedWith(new ButterKnifeProcessor()).compilesWithoutWarnings().and().generatesSources(bindingSource);
}
use of butterknife.compiler.ButterKnifeProcessor in project butterknife by JakeWharton.
the class OnItemClickTest method onClickRootViewAnyTypeBinding.
@Test
public void onClickRootViewAnyTypeBinding() {
JavaFileObject source = JavaFileObjects.forSourceString("test.Test", "" + "package test;\n" + "import butterknife.OnItemClick;\n" + "public class Test {\n" + " @OnItemClick void doStuff() {}\n" + "}");
JavaFileObject bindingSource = JavaFileObjects.forSourceString("test/Test_ViewBinding", "" + "package test;\n" + "import android.support.annotation.CallSuper;\n" + "import android.support.annotation.UiThread;\n" + "import android.view.View;\n" + "import android.widget.AdapterView;\n" + "import butterknife.Unbinder;\n" + "import java.lang.IllegalStateException;\n" + "import java.lang.Override;\n" + "public class Test_ViewBinding implements Unbinder {\n" + " private Test target;\n" + " private View viewSource;\n" + " @UiThread\n" + " public Test_ViewBinding(final Test target, View source) {\n" + " this.target = target;\n" + " viewSource = source;\n" + " ((AdapterView<?>) source).setOnItemClickListener(new AdapterView.OnItemClickListener() {\n" + " @Override\n" + " public void onItemClick(AdapterView<?> p0, View p1, int p2, long p3) {\n" + " target.doStuff();\n" + " }\n" + " });\n" + " }\n" + " @Override\n" + " @CallSuper\n" + " public void unbind() {\n" + " if (target == null) throw new IllegalStateException(\"Bindings already cleared.\");\n" + " target = null;\n" + " ((AdapterView<?>) viewSource).setOnItemClickListener(null);\n" + " viewSource = null;\n" + " }\n" + "}");
assertAbout(javaSource()).that(source).withCompilerOptions("-Xlint:-processing").processedWith(new ButterKnifeProcessor()).compilesWithoutWarnings().and().generatesSources(bindingSource);
}
use of butterknife.compiler.ButterKnifeProcessor in project butterknife by JakeWharton.
the class OnItemLongClickTest method itemLongClick.
@Test
public void itemLongClick() {
JavaFileObject source = JavaFileObjects.forSourceString("test.Test", "" + "package test;\n" + "import butterknife.OnItemLongClick;\n" + "public class Test {\n" + " @OnItemLongClick(1) boolean doStuff() { return false; }\n" + "}");
JavaFileObject bindingSource = JavaFileObjects.forSourceString("test/Test_ViewBinding", "" + "package test;\n" + "import android.support.annotation.CallSuper;\n" + "import android.support.annotation.UiThread;\n" + "import android.view.View;\n" + "import android.widget.AdapterView;\n" + "import butterknife.Unbinder;\n" + "import butterknife.internal.Utils;\n" + "import java.lang.IllegalStateException;\n" + "import java.lang.Override;\n" + "public class Test_ViewBinding implements Unbinder {\n" + " private Test target;\n" + " private View view1;\n" + " @UiThread\n" + " public Test_ViewBinding(final Test target, View source) {\n" + " this.target = target;\n" + " View view;\n" + " view = Utils.findRequiredView(source, 1, \"method 'doStuff'\");\n" + " view1 = view;\n" + " ((AdapterView<?>) view).setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {\n" + " @Override\n" + " public boolean onItemLongClick(AdapterView<?> p0, View p1, int p2, long p3) {\n" + " return target.doStuff();\n" + " }\n" + " });\n" + " }\n" + " @Override\n" + " @CallSuper\n" + " public void unbind() {\n" + " if (target == null) throw new IllegalStateException(\"Bindings already cleared.\");\n" + " target = null;\n" + " ((AdapterView<?>) view1).setOnItemLongClickListener(null);\n" + " view1 = null;\n" + " }\n" + "}");
assertAbout(javaSource()).that(source).withCompilerOptions("-Xlint:-processing").processedWith(new ButterKnifeProcessor()).compilesWithoutWarnings().and().generatesSources(bindingSource);
}
use of butterknife.compiler.ButterKnifeProcessor in project butterknife by JakeWharton.
the class OnItemSelectedTest method defaultMethod.
@Test
public void defaultMethod() {
JavaFileObject source = JavaFileObjects.forSourceString("test.Test", "" + "package test;\n" + "import butterknife.OnItemSelected;\n" + "public class Test {\n" + " @OnItemSelected(1) void doStuff() {}\n" + "}");
JavaFileObject bindingSource = JavaFileObjects.forSourceString("test/Test_ViewBinding", "" + "package test;\n" + "import android.support.annotation.CallSuper;\n" + "import android.support.annotation.UiThread;\n" + "import android.view.View;\n" + "import android.widget.AdapterView;\n" + "import butterknife.Unbinder;\n" + "import butterknife.internal.Utils;\n" + "import java.lang.IllegalStateException;\n" + "import java.lang.Override;\n" + "public class Test_ViewBinding implements Unbinder {\n" + " private Test target;\n" + " private View view1;\n" + " @UiThread\n" + " public Test_ViewBinding(final Test target, View source) {\n" + " this.target = target;\n" + " View view;\n" + " view = Utils.findRequiredView(source, 1, \"method 'doStuff'\");\n" + " view1 = view;\n" + " ((AdapterView<?>) view).setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n" + " @Override\n" + " public void onItemSelected(AdapterView<?> p0, View p1, int p2, long p3) {\n" + " target.doStuff();\n" + " }\n" + " @Override\n" + " public void onNothingSelected(AdapterView<?> p0) {\n" + " }\n" + " });\n" + " }\n" + " @Override\n" + " @CallSuper\n" + " public void unbind() {\n" + " if (target == null) throw new IllegalStateException(\"Bindings already cleared.\");\n" + " target = null;\n" + " ((AdapterView<?>) view1).setOnItemSelectedListener(null);\n" + " view1 = null;\n" + " }\n" + "}");
assertAbout(javaSource()).that(source).withCompilerOptions("-Xlint:-processing").processedWith(new ButterKnifeProcessor()).compilesWithoutWarnings().and().generatesSources(bindingSource);
}
Aggregations