use of com.reprezen.kaizen.oasparser.model3.RequestBody in project C3 by Hi5App.
the class HttpUtilsQualityInspection method getSwcWithOkHttp.
public static void getSwcWithOkHttp(JSONObject userInfo, JSONObject bBox, Callback callback) {
try {
RequestBody body = RequestBody.create(JSON, String.valueOf(new JSONObject().put("bb", bBox).put("user", userInfo)));
asyncPostRequest(URL_GET_SWC, body, callback);
} catch (Exception e) {
e.printStackTrace();
}
}
use of com.reprezen.kaizen.oasparser.model3.RequestBody in project C3 by Hi5App.
the class HttpUtilsQualityInspection method getArborMarkerListWithOkHttp.
public static void getArborMarkerListWithOkHttp(JSONObject userInfo, String arborName, Callback callback) {
try {
RequestBody body = RequestBody.create(JSON, String.valueOf(new JSONObject().put("user", userInfo).put("arborname", arborName)));
asyncPostRequest(URL_GET_ARBOR_MARKER_LIST, body, callback);
} catch (Exception e) {
e.printStackTrace();
}
}
use of com.reprezen.kaizen.oasparser.model3.RequestBody in project C3 by Hi5App.
the class HttpUtilsQualityInspection method getArborWithOkHttp.
public static void getArborWithOkHttp(JSONObject userInfo, Callback callback) {
try {
RequestBody body = RequestBody.create(JSON, String.valueOf(new JSONObject().put("user", userInfo)));
asyncPostRequest(URL_GET_ARBOR, body, callback);
} catch (Exception e) {
e.printStackTrace();
}
}
use of com.reprezen.kaizen.oasparser.model3.RequestBody in project AndroidFastDevFrame by linglongxin24.
the class Myapplication method onCreate.
@Override
public void onCreate() {
super.onCreate();
// x.Ext.init(this);
CustomActivityOnCrash.install(this);
CustomActivityOnCrash.setDebugMode(BuildConfig.DEBUG);
// http请求初始化设置
Http.getHttp().addInterceptor(new Interceptor() {
@Override
public Response intercept(Chain chain) throws IOException {
Request original = chain.request();
Request.Builder requestBuilder = original.newBuilder();
requestBuilder.addHeader("Userid", "589");
requestBuilder.addHeader("FAToken", "VTMWBVZO");
requestBuilder.addHeader("Content-Type", "application/json");
RequestBody requestBody = original.body();
requestBuilder.method(original.method(), requestBody);
Request request = requestBuilder.build();
Logger.d("request.headers().toString()=" + request.headers().toString());
return chain.proceed(request);
}
});
Http.getHttp().setDebugMode(BuildConfig.DEBUG);
Http.getHttp().init(ApiService.class, ApiService.baseUrl, "returnCode", "data", "returnMsg", 200);
Http.getHttp().setShowMessageModel(MessageManager.MessageModel.All);
Http.getHttp().setErrorMessage("网络开小差了");
// AppConfig.setAppLeftResId(R.drawable.pub_arrow_back_write);
if (LeakCanary.isInAnalyzerProcess(this)) {
// You should not init your app in this process.
return;
}
LeakCanary.install(this);
}
use of com.reprezen.kaizen.oasparser.model3.RequestBody in project AndroidFastDevFrame by linglongxin24.
the class RetrofitManager method getRequestBody.
private String getRequestBody(MultipartBody.Part part) {
Class<?> personType = part.getClass();
// 访问私有属性
Field field = null;
try {
field = personType.getDeclaredField("body");
} catch (NoSuchFieldException e) {
e.printStackTrace();
}
field.setAccessible(true);
try {
RequestBody requestBody = (RequestBody) field.get(part);
MediaType contentType = requestBody.contentType();
if (contentType.type().equals("multipart")) {
Buffer buffer = new Buffer();
requestBody.writeTo(buffer);
Charset UTF8 = Charset.forName("UTF-8");
Charset charset = contentType.charset(UTF8);
return buffer.readString(charset);
} else if (contentType.type().equals("image")) {
if (requestBody != null) {
return convertFileSize(requestBody.contentLength());
} else {
return "0b";
}
// Class<?> requestBodyClass = requestBody.getClass();
//
// //访问私有属性
// Field fileRequestBodyClass = null;
// try {
// fileRequestBodyClass = requestBodyClass.getDeclaredField("file");
//
//
// fileRequestBodyClass.setAccessible(true);
// File file = (File) fileRequestBodyClass.get(requestBody);
// Logger.d("file=" + file.getPath());
// } catch (NoSuchFieldException e) {
// e.printStackTrace();
// } catch (Exception e) {
// e.printStackTrace();
// }
}
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return "";
}
Aggregations