Skip to content

Instantly share code, notes, and snippets.

View ChaitanyaPramod's full-sized avatar

Chaitanya Pramod ChaitanyaPramod

View GitHub Profile
@ChaitanyaPramod
ChaitanyaPramod / index.html
Created July 3, 2013 10:01
Gist to test the bug due to which node-webkit 0.6.1 doesn't show tooltip popup with the content of the `title` attribute
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Title test</title>
<style>
#block {
background-color: lightblue;
height: 200px;
width: 200px;
def toCamelCase(String string) {
String result = ""
string.findAll("[^\\W]+") { String word ->
result += word.capitalize()
}
return result
}
afterEvaluate { project ->
Configuration runtimeConfiguration = project.configurations.getByName('compile')
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;
@ChaitanyaPramod
ChaitanyaPramod / Annotations
Last active March 26, 2018 04:52
Demystifying Butterknife snippets
BindAnim
BindArray
BindBitmap
BindBool
BindColor
BindDimen
BindDrawable
BindFloat
BindFont
BindInt
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) {
...
public class MainActivity_ViewBinding implements Unbinder {
private MainActivity target;
@UiThread
public MainActivity_ViewBinding(MainActivity target) {
this(target, target.getWindow().getDecorView());
}
@UiThread
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");
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);
}
...
}
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
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);