Android Open Source - android Json Http Response Handler






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

/**
 * //from  w  w w.  j  a  v a2  s.com
 */
package com.apibootstraper.mobile.http;

import org.json.JSONArray;
import org.json.JSONObject;

import android.util.Log;

/**
 * @author nicolas
 *
 */
public class JsonHttpResponseHandler<T> extends com.loopj.android.http.JsonHttpResponseHandler {

    protected final HTTPResponse<T> response;

    public JsonHttpResponseHandler(HTTPResponse<T> response) {
        this.response = response;
    }

    //
    // Callbacks to be overridden, typically anonymously
    //

    @Override
    public void onStart() {
        this.response.onStart();
    }

    @Override
    public void onFinish() {
        this.response.onFinish();
    }


    @Override
    public void onSuccess(JSONObject object) {}

    @Override
    public void onSuccess(JSONArray array) {}

    @Override
    public void onSuccess(int statusCode, JSONObject response) {
        onSuccess(response);
    }

    @Override
    public void onSuccess(int statusCode, JSONArray response) {
        onSuccess(response);
    }


    @Override
    public void onFailure(Throwable e, JSONObject errorResponse) {
        e.printStackTrace();
        Log.e("HTTPResponse", e.getMessage());
        Log.e("HTTPResponse", errorResponse.toString());
        this.response.onFailure(e, errorResponse);
    }

    @Override
    public void onFailure(Throwable e, JSONArray errorResponse) {
        e.printStackTrace();
        Log.e("HTTPResponse", e.getMessage());
        Log.e("HTTPResponse", errorResponse.toString());
        this.response.onFailure(e, errorResponse);
    }
}




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