Android Open Source - Kite Client Facade






From Project

Back to project page Kite.

License

The source code is released under:

Apache License

If you think the Android project Kite listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package org.kite.wire;
/*from  w  w w.  jav  a  2s.  c  o  m*/
import android.util.SparseArray;

import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Map;
import java.util.Set;

/**
 * A helper class for injecting values.
 *
 * @author Nikolay Soroka
 */
class ClientFacade {

    private Map<Class<?>, Field> wired;
    private SparseArray<Method> asyncCallbacks;

    public static ClientFacade build(Class<?> targetClass) {
        ClientFacade clientFacade = new ClientFacade();
        clientFacade.wired = InterfaceFinder.findAllWired(targetClass);
        clientFacade.asyncCallbacks = InterfaceFinder.findAsyncCallbacks(targetClass);
        return clientFacade;
    }

    public Set<Class<?>> getWiredClasses(){
        return wired.keySet();
    }

    public SparseArray<Method> getAsyncCallbacks() {
        return asyncCallbacks;
    }

    public void fillWith(Object clientInstance, Class<?> type, Object value){
        Field field = wired.get(type);
        if (field != null){
            field.setAccessible(true);
            try {
                field.set(clientInstance, value);
            } catch (IllegalAccessException e) {
                // log this out
            }
        }

    }

    private ClientFacade(){
    }
}




Java Source Code List

org.kite.annotations.AsyncMethod.java
org.kite.annotations.AsyncResult.java
org.kite.annotations.Provided.java
org.kite.annotations.Wired.java
org.kite.async.AsyncHandler.java
org.kite.async.AsyncType.java
org.kite.async.MethodResult.java
org.kite.async.ResultQueue.java
org.kite.sample.CalcFragment.java
org.kite.sample.CalcInterface.java
org.kite.sample.Calculator.java
org.kite.sample.MainActivity.java
org.kite.sample.SampleService.java
org.kite.sample.Substractor.java
org.kite.services.CommandService.java
org.kite.services.MainThreadExecutor.java
org.kite.wire.ClientFacade.java
org.kite.wire.InterfaceFinder.java
org.kite.wire.ServiceFacade.java
org.kite.wire.WireBinder.java
org.kite.wire.WireCallback.java
org.kite.wire.Wire.java
org.kite.wire.WiredService.java
org.kite.wire.package-info.java