package com.weikou.beibeivideo;
|
|
import android.os.Handler;
|
import android.os.Message;
|
import android.util.Log;
|
|
import com.lcjian.library.util.common.StringUtils;
|
import com.lcjian.library.util.security.DEScrypt;
|
|
import org.apache.http.Header;
|
import org.json.JSONObject;
|
|
import java.io.IOException;
|
import java.io.InputStream;
|
|
import okhttp3.Call;
|
import okhttp3.Callback;
|
import okhttp3.Response;
|
|
public abstract class BasicTextHttpResponseCallback implements Callback {
|
|
private static final String TAG = "BasicTextHttpResponseHandler";
|
|
public abstract void onSuccessPerfect(int statusCode, Header[] headers,
|
JSONObject jsonObject) throws Exception;
|
|
public void onResponse(Call var1, Response var2) throws IOException {
|
try {
|
if (var2.isSuccessful()) {
|
String responseString=var2.body().string();
|
responseString = DEScrypt.decode(responseString);
|
JSONObject jsonObject = new JSONObject(responseString);
|
onSuccessPerfect(var2.code(), null, jsonObject);
|
}
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
|
}
|
|
@Override
|
public void onFailure(Call call, IOException e) {
|
|
}
|
// @Override
|
// public void onSuccess(int statusCode, Header[] headers,
|
// String responseString) {
|
// try {
|
// responseString = DEScrypt.decode(responseString);
|
// JSONObject jsonObject = new JSONObject(responseString);
|
// onSuccessPerfect(statusCode, headers, jsonObject);
|
// } catch (Exception e) {
|
// e.printStackTrace();
|
// }
|
// }
|
//
|
// @Override
|
// public void onFailure(int statusCode, Header[] headers,
|
// String responseString, Throwable throwable) {
|
// responseString = DEScrypt.decode(responseString);
|
// }
|
//
|
// private String toHeadersString(Header[] headers) {
|
// StringBuilder builder = new StringBuilder();
|
// if (headers != null) {
|
// for (Header header : headers) {
|
// builder.append(header.toString() + ";");
|
// }
|
// }
|
// return builder.toString();
|
// }
|
}
|