Android Open Source - android H T T P Response






From Project

Back to project page android.

License

The source code is released under:

Copyright (c) 2013 ApiBootstraper Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Sof...

If you think the Android project android 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 com.apibootstraper.mobile.http;
/*w  ww. jav a 2  s .  c  o  m*/
import org.json.JSONArray;
import org.json.JSONObject;

public class HTTPResponse<T> {

    /**
     * Fired when the request is started, override to handle in your own code
     */
    public void onStart() {}

    /**
     * Fired in all cases when the request is finished, after both success and failure, override to handle in your own code
     */
    public void onFinish() {}

    /**
     * 
     * @param object
     */
    public void onSuccess(T object) {}

    /**
     * 
     * @param object
     * @param total
     */
    public void onSuccess(T object, int total) {
        onSuccess(object);
    }

    /**
     * 
     * @param object
     * @param response
     */
    public void onSuccess(T object, JSONObject response) {
        onSuccess(object);
    }

    /**
     * 
     * @param object
     * @param response
     */
    public void onSuccess(T object, JSONArray response) {
        onSuccess(object);
    }

    /**
     * 
     * @param statusCode
     * @param object
     */
    public void onSuccess(int statusCode, T object) {
        onSuccess(object);
    }

    /**
     * 
     * @param statusCode
     * @param object
     * @param total
     */
    public void onSuccess(int statusCode, T object, int total) {
        onSuccess(object, total);
    }

    /**
     * 
     * @param statusCode
     * @param object
     * @param response
     */
    public void onSuccess(int statusCode, T object, JSONObject response) {
        onSuccess(object, response);
    }

    /**
     * 
     * @param statusCode
     * @param object
     * @param response
     */
    public void onSuccess(int statusCode, T object, JSONArray response) {
        onSuccess(object, response);
    }

    /**
     * Fired when a request fails to complete, override to handle in your own code
     * 
     * @param error the underlying cause of the failure
     * @deprecated use {@link #onFailure(Throwable, JSONObject)} or {@link #onFailure(Throwable, JSONArray)}
     */
    public void onFailure(Throwable e) {}

    /**
     * Fired when a request fails to complete, override to handle in your own code
     * 
     * @param error the underlying cause of the failure
     * @param content the response body, if any
     */
    @SuppressWarnings("deprecation")
    public void onFailure(Throwable e, JSONObject errorResponse) {
        // By default, call the deprecated onFailure(Throwable) for compatibility
        onFailure(e);
    }

    /**
     * 
     * @param e
     * @param errorResponse
     */
    @SuppressWarnings("deprecation")
    public void onFailure(Throwable e, JSONArray errorResponse) {
        // By default, call the deprecated onFailure(Throwable) for compatibility
        onFailure(e);
    }
}




Java Source Code List

com.apibootstraper.core.Entity.java
com.apibootstraper.core.Todo.java
com.apibootstraper.core.User.java
com.apibootstraper.mobile.TodoApplication.java
com.apibootstraper.mobile.activity.MainActivity.java
com.apibootstraper.mobile.activity.TodoActivity.java
com.apibootstraper.mobile.activity.TodoFormActivity.java
com.apibootstraper.mobile.http.EntityManager.java
com.apibootstraper.mobile.http.HTTPClient.java
com.apibootstraper.mobile.http.HTTPResponse.java
com.apibootstraper.mobile.http.JsonHttpResponseHandler.java
com.apibootstraper.mobile.repository.TodoRepository.java
com.apibootstraper.mobile.repository.UserRepository.java
com.apibootstraper.mobile.util.AppConfig.java
com.apibootstraper.mobile.util.DateUtils.java
com.apibootstraper.mobile.view.TodoArrayAdapter.java