Android Open Source - RestLib Rest Result Receiver






From Project

Back to project page RestLib.

License

The source code is released under:

MIT License

If you think the Android project RestLib 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 github.crazymumu.restlib;
/*from   w  w w. j  a v a2 s.c o  m*/
import android.os.Bundle;
import android.os.Handler;
import android.os.ResultReceiver;

/**
 * Declares a RestResult receiver as one of the activity's member. RestResult
 * receivers enable activity to receive results from the RestService.
 * 
 * @author Crazy MuMu
 */
public class RestResultReceiver extends ResultReceiver {
  private RestResult receiver;
  
  public RestResultReceiver() {
    super(new Handler());
  }
  
  public RestResultReceiver(Handler handler) {
    super(handler);
  }
  
  public void setReceiver(RestResult receiver) {
    this.receiver = receiver;
  }

  @Override
  protected void onReceiveResult(int resultCode, Bundle resultData) {
    if (receiver != null && resultData != null) {
      RestResponse response = resultData.getParcelable(RestService.RESULT);
      receiver.onReceiveRestResult(response);
    }
  }
}




Java Source Code List

github.crazymumu.restlib.RestRequest.java
github.crazymumu.restlib.RestResponse.java
github.crazymumu.restlib.RestResultReceiver.java
github.crazymumu.restlib.RestResult.java
github.crazymumu.restlib.RestService.java
github.crazymumu.restlib.core.CustomSSLSocketFactory.java
github.crazymumu.restlib.core.HttpsClient.java
github.crazymumu.restlib.core.SSLContextAlgorithm.java
github.crazymumu.restlib.http.RequestMethod.java
github.crazymumu.restlib.http.StatusCode.java
github.crazymumu.restlib.http.UserAgent.java
github.crazymumu.restlib.sample.MainActivity.java