Search in sources :

Example 1 with SupposeBackground

use of org.androidannotations.annotations.SupposeBackground in project androidannotations by androidannotations.

the class SupposeBackgroundHandler method process.

@Override
public void process(Element element, EComponentHolder holder) throws Exception {
    ExecutableElement executableElement = (ExecutableElement) element;
    JMethod delegatingMethod = codeModelHelper.overrideAnnotatedMethod(executableElement, holder);
    AbstractJClass bgExecutor = getJClass(BackgroundExecutor.class);
    SupposeBackground annotation = element.getAnnotation(SupposeBackground.class);
    String[] serial = annotation.serial();
    JInvocation invocation = bgExecutor.staticInvoke(METHOD_CHECK_BG_THREAD);
    for (String s : serial) {
        invocation.arg(lit(s));
    }
    JBlock body = delegatingMethod.body();
    body.pos(0);
    body.add(invocation);
    body.pos(body.getContents().size());
}
Also used : ExecutableElement(javax.lang.model.element.ExecutableElement) SupposeBackground(org.androidannotations.annotations.SupposeBackground) JBlock(com.helger.jcodemodel.JBlock) AbstractJClass(com.helger.jcodemodel.AbstractJClass) JInvocation(com.helger.jcodemodel.JInvocation) JMethod(com.helger.jcodemodel.JMethod)

Aggregations

AbstractJClass (com.helger.jcodemodel.AbstractJClass)1 JBlock (com.helger.jcodemodel.JBlock)1 JInvocation (com.helger.jcodemodel.JInvocation)1 JMethod (com.helger.jcodemodel.JMethod)1 ExecutableElement (javax.lang.model.element.ExecutableElement)1 SupposeBackground (org.androidannotations.annotations.SupposeBackground)1