Commit 440b8dd5 by app_dev@sobot.com

sobot net 1.0.3

parent 29c28144
......@@ -12,7 +12,7 @@ task androidSourcesJar(type: Jar) {
ext {
PUBLISH_GROUP_ID = "com.sobot.library" //项目包名
PUBLISH_ARTIFACT_ID = 'net' //项目名
PUBLISH_VERSION = '1.0.1' //版本号
PUBLISH_VERSION = '1.0.3' //版本号
}
......
......@@ -9,15 +9,16 @@ import com.sobot.network.http.log.SobotNetLogUtils;
import java.io.IOException;
import java.util.Map;
import okhttp3.MediaType;
import okhttp3.Response;
public class SobotHttpUtils {
// ##################### 网络请求 #########################
public static void doPost(Object cancelTag, String url, Map<String, String> map,
public static void doPost(Object cancelTag, String url, Map<String, String> paramsMap,
HttpUtils.StringCallBack call) {
HttpUtils.getInstance().doPost(cancelTag, url, map, null, call);
HttpUtils.getInstance().doPost(cancelTag, url, paramsMap, null, call);
}
public static void doPost(Object cancelTag, String url, Map<String, String> paramsMap, Map<String, String> headerMap,
......@@ -25,14 +26,29 @@ public class SobotHttpUtils {
HttpUtils.getInstance().doPost(cancelTag, url, paramsMap, headerMap, call);
}
public static void doGet(Object cancelTag, String url, Map<String, String> map,
public static void doPostByString(Object cancelTag, String url, Map<String, String> paramsMap, Map<String, String> headerMap, MediaType mediaType,
HttpUtils.StringCallBack call) {
HttpUtils.getInstance().doGet(cancelTag, url, map, call);
HttpUtils.getInstance().doPostByString(cancelTag, url, paramsMap, headerMap, mediaType, call);
}
public static void doPostByJsonString(Object cancelTag, String url, Map<String, String> paramsMap, Map<String, String> headerMap,
HttpUtils.StringCallBack call) {
HttpUtils.getInstance().doPostByJsonString(cancelTag, url, paramsMap, headerMap, call);
}
public static void doGet(Object cancelTag, String url, Map<String, String> paramsMap,
HttpUtils.StringCallBack call) {
HttpUtils.getInstance().doGet(cancelTag, url, paramsMap, null, call);
}
public static void doGet(Object cancelTag, String url, Map<String, String> paramsMap, Map<String, String> headerMap,
HttpUtils.StringCallBack call) {
HttpUtils.getInstance().doGet(cancelTag, url, paramsMap, headerMap, call);
}
//同步请求
public static Response doPostSync(Object cancelTag, String url, Map<String, String> map) throws IOException {
return HttpUtils.getInstance().doPostSync(cancelTag, url, map);
public static Response doPostSync(Object cancelTag, String url, Map<String, String> paramsMap, Map<String, String> headerMap) throws IOException {
return HttpUtils.getInstance().doPostSync(cancelTag, url, paramsMap, headerMap);
}
......@@ -40,24 +56,24 @@ public class SobotHttpUtils {
* 发送文件请求
*
* @param url
* @param map
* @param paramsMap
* @param filePath
* @param callBack
*/
public static void uploadFile(Object cancelTag, String url, Map<String, String> map,
public static void uploadFile(Object cancelTag, String url, Map<String, String> paramsMap, Map<String, String> headerMap,
final String filePath, HttpUtils.StringCallBack callBack) {
///////////////////////////////////////////////////////
if (map != null) {
if (paramsMap != null) {
// 基本传递参数
StringBuilder sb = new StringBuilder();
sb.append("sobot---请求参数: url = " + url + ", filePath=" + filePath + " ");
for (String key : map.keySet()) {
sb.append(key + "=" + map.get(key) + ", ");
for (String key : paramsMap.keySet()) {
sb.append(key + "=" + paramsMap.get(key) + ", ");
}
SobotNetLogUtils.i(sb.toString().substring(0, sb.toString().length() - 2));
}
HttpUtils.getInstance().uploadFile(cancelTag, url, map, filePath, callBack);
HttpUtils.getInstance().uploadFile(cancelTag, url, paramsMap, headerMap, filePath, callBack);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment