This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Bindings | Listeners | |
---|---|---|
BindAnim | OnCheckedChanged | |
BindArray | OnClick | |
BindBitmap | OnEditorAction | |
BindBool | OnFocusChange | |
BindColor | OnItemClick | |
BindDimen | OnItemLongClick | |
BindDrawable | OnItemSelected | |
BindFloat | OnLongClick | |
BindFont | OnPageChange |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
JavaFile brewJava(int sdk, boolean debuggable) { | |
return JavaFile.builder(bindingClassName.packageName(), createType(sdk, debuggable)) | |
.addFileComment("Generated code from Butter Knife. Do not modify!") | |
.build(); | |
} | |
private TypeSpec createType(int sdk, boolean debuggable) { | |
TypeSpec.Builder result = TypeSpec.classBuilder(bindingClassName.simpleName()) | |
.addModifiers(PUBLIC); | |
if (isFinal) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public final class FinalRClassBuilder { | |
... | |
private static final String[] SUPPORTED_TYPES = { | |
"anim", "array", "attr", "bool", "color", "dimen", "drawable", "id", "integer", "layout", "menu", "plurals", | |
"string", "style", "styleable" | |
}; | |
... | |
public static void brewJava(File rFile, File outputDir, String packageName, String className) | |
throws Exception { | |
CompilationUnit compilationUnit = JavaParser.parse(rFile); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyActivity extends Activity { | |
@BindView(R.id.my_text_view) TextView myTextView; | |
private Unbinder unbinder; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
// instead of reflection using |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static Unbinder createBinding(@NonNull Object target, @NonNull View source) { | |
Class<?> targetClass = target.getClass(); | |
... | |
Constructor<? extends Unbinder> constructor = findBindingConstructorForClass(targetClass); | |
... | |
try { | |
return constructor.newInstance(target, source); | |
} | |
... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void parseListenerAnnotation(Class<? extends Annotation> annotationClass, Element element, | |
Map<TypeElement, BindingSet.Builder> builderMap, Set<TypeElement> erasedTargetNames) | |
throws Exception { | |
... | |
ExecutableElement executableElement = (ExecutableElement) element; | |
TypeElement enclosingElement = (TypeElement) element.getEnclosingElement(); | |
// Assemble information on the method. | |
Annotation annotation = element.getAnnotation(annotationClass); | |
Method annotationValue = annotationClass.getDeclaredMethod("value"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
public class MainActivity_ViewBinding implements Unbinder { | |
private MainActivity target; | |
@UiThread | |
public MainActivity_ViewBinding(MainActivity target) { | |
this(target, target.getWindow().getDecorView()); | |
} | |
@UiThread |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void parseBindView(Element element, Map<TypeElement, BindingSet.Builder> builderMap, | |
Set<TypeElement> erasedTargetNames) { | |
TypeElement enclosingElement = (TypeElement) element.getEnclosingElement(); | |
... | |
// Assemble information on the field. | |
int id = element.getAnnotation(BindView.class).value(); | |
BindingSet.Builder builder = builderMap.get(enclosingElement); | |
QualifiedId qualifiedId = elementToQualifiedId(element, id); | |
if (builder != null) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BindAnim | |
BindArray | |
BindBitmap | |
BindBool | |
BindColor | |
BindDimen | |
BindDrawable | |
BindFloat | |
BindFont | |
BindInt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.your.packagename.here; | |
import android.content.Context; | |
import android.util.AttributeSet; | |
import android.view.View; | |
import android.view.ViewGroup; | |
import android.widget.FrameLayout; | |
import java.util.ArrayList; |
NewerOlder