Skip to content

Instantly share code, notes, and snippets.

@johncarl81
johncarl81 / apdebug.sh
Created May 1, 2017 21:28
Debug annotation processor via Maven
export MAVEN_OPTS="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"
git branch --merged | egrep -v "(^\*|master|dev)" | xargs git branch -d &&
git remote prune origin &&
git gc
#!/bin/bash
countLines(){
totalCount=0;
for file in `find . -name *.java`; do
numLines=`cat $file | sed -r ':a; s%(.*)/\*.*\*/%\1%; ta; /\/\*/ !b; N; ba' | sed '/^\s*$/d' | sed '/^import/ d' | sed '/^package/ d' | wc -l`;
totalCount=$(( $totalCount + $numLines ));
done
echo $totalCount
}
package org.androidtransfuse.adapter;
import org.androidtransfuse.adapter.classes.ASTClassFactory;
import org.junit.Test;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.lang.reflect.TypeVariable;
import java.util.HashMap;
import java.util.Map;
@johncarl81
johncarl81 / RBridgeExample.java
Last active May 7, 2016 16:36
RBridge Example
// Referencing the given R class kicks off the annotaion processor to generate an RBridge:
@Bridge(R.class)
// Input R:
public final class R {
public static final class layout {
public static int example_layout=0x7f030000;
}
}
@johncarl81
johncarl81 / SubjectTest.java
Last active May 3, 2016 04:01
Testing BehaviorSubject
package test;
import rx.Observable;
import rx.Subscriber;
import rx.Subscription;
import rx.functions.Action1;
import rx.functions.Func0;
import rx.subjects.BehaviorSubject;
import rx.subjects.PublishSubject;
john@john-desktop:~/dev/transfuse-project/examples/gradle$ ./gradlew clean assembleDebug
Parallel execution is an incubating feature.
Incremental java compilation is an incubating feature.
extractDebugAnnotations is incompatible with java 8 sources and has been disabled.
extractReleaseAnnotations is incompatible with java 8 sources and has been disabled.
:testlibrary:clean
:GradleTransfuse:clean
:GradleTransfuse:preBuild UP-TO-DATE
:GradleTransfuse:preDebugBuild UP-TO-DATE
:GradleTransfuse:checkDebugManifest
@Factory
public insterface ZumperApiUtilFactory {
ZumperApiUtil get();
}
//usage:
ZumperApiUtil util = Factories.get(ZumperApiUtilFactory.class).get();
public class RXTest {
public static void main(String[] args){
ExecutorService oneExecutor = Executors.newSingleThreadExecutor();
ExecutorService twoExecutor = Executors.newSingleThreadExecutor();
ExecutorService threeExecutor = Executors.newSingleThreadExecutor();
Scheduler one = Schedulers.from(oneExecutor);
Scheduler two = Schedulers.from(twoExecutor);
public class AnnotationProcessorOutputAssertion {
public @interface Target {}
public interface TestTarget {
String get();
}
@Test
public void testCompileAnnotationProcessorOutput() throws InstantiationException, IllegalAccessException, ClassNotFoundException, IOException {