Android Open Source - Kite Result Queue






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.async;
/*from   w w w .j av a2s.  co  m*/
import java.util.LinkedList;
import java.util.Queue;

/**
 * Queue for getting results of methods invocation.
 *
 * @author Nikolay Soroka
 */
public class ResultQueue {

    public boolean isNotEmpty() {
        return !isEmpty();
    }

    private boolean isEmpty() {
        return queue.isEmpty();
    }

    public static interface ResultListener {
        void onResultAdded(ResultQueue resultQueue);
    }

    public synchronized void postResult(MethodResult r){
        queue.add(r);
        notifyListener();
    }

    public synchronized MethodResult peekResult(){
        return queue.poll();
    }

    public ResultListener getListener() {
        return listener;
    }

    public void setListener(ResultListener listener) {
        this.listener = listener;
    }

    private ResultListener listener;

    private void notifyListener() {
        if (listener != null){
            listener.onResultAdded(this);
        }
    }

    private Queue<MethodResult> queue = new LinkedList<MethodResult>();
}




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