All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.laputapp.http.ExtendedCallback Maven / Gradle / Ivy

There is a newer version: 1.0.6
Show newest version
/**
 * Created by YuGang Yang on February 06, 2015.
 * Copyright 2007-2015 Laputapp.com. All rights reserved.
 */
package com.laputapp.http;

import retrofit.Callback;
import retrofit.RetrofitError;

public class ExtendedCallback extends Callbacks.ApiBaseCallback implements Callback> {

  @Override public void success(Response tResponse, retrofit.client.Response response) {
    // response value
    tResponse.mResponse = response;
    tResponse.mStatus = response.getStatus();
    tResponse.mReason = response.getReason();
    tResponse.mHeaders = response.getHeaders();

    if (tResponse.isSuccessed()) {
      onRequestComplete(tResponse);
    } else {
      onRequestFailure(tResponse);
    }

    onFinish();
  }

  @Override public void failure(RetrofitError error) {
    if (error.getKind() == RetrofitError.Kind.NETWORK) {
      onRequestNetworkError();
    } else {
      onRequestFailure(error);
    }
    onFinish();
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy