Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
Sobot_module_Dev
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sobot_android
Sobot_module_Dev
Commits
440b8dd5
Commit
440b8dd5
authored
Dec 14, 2021
by
app_dev@sobot.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sobot net 1.0.3
parent
29c28144
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
141 additions
and
39 deletions
+141
-39
sobot-network-publish-mavencentral.gradle
sobot_network/sobot-network-publish-mavencentral.gradle
+1
-1
SobotHttpUtils.java
.../main/java/com/sobot/network/apiUtils/SobotHttpUtils.java
+28
-12
HttpUtils.java
...twork/src/main/java/com/sobot/network/http/HttpUtils.java
+112
-26
No files found.
sobot_network/sobot-network-publish-mavencentral.gradle
View file @
440b8dd5
...
...
@@ -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
'
//版本号
}
...
...
sobot_network/src/main/java/com/sobot/network/apiUtils/SobotHttpUtils.java
View file @
440b8dd5
...
...
@@ -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
>
m
ap
,
public
static
void
doPost
(
Object
cancelTag
,
String
url
,
Map
<
String
,
String
>
paramsM
ap
,
HttpUtils
.
StringCallBack
call
)
{
HttpUtils
.
getInstance
().
doPost
(
cancelTag
,
url
,
m
ap
,
null
,
call
);
HttpUtils
.
getInstance
().
doPost
(
cancelTag
,
url
,
paramsM
ap
,
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
().
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
,
m
ap
,
call
);
HttpUtils
.
getInstance
().
doGet
(
cancelTag
,
url
,
paramsMap
,
headerM
ap
,
call
);
}
//同步请求
public
static
Response
doPostSync
(
Object
cancelTag
,
String
url
,
Map
<
String
,
String
>
m
ap
)
throws
IOException
{
return
HttpUtils
.
getInstance
().
doPostSync
(
cancelTag
,
url
,
m
ap
);
public
static
Response
doPostSync
(
Object
cancelTag
,
String
url
,
Map
<
String
,
String
>
paramsMap
,
Map
<
String
,
String
>
headerM
ap
)
throws
IOException
{
return
HttpUtils
.
getInstance
().
doPostSync
(
cancelTag
,
url
,
paramsMap
,
headerM
ap
);
}
...
...
@@ -40,24 +56,24 @@ public class SobotHttpUtils {
* 发送文件请求
*
* @param url
* @param
m
ap
* @param
paramsM
ap
* @param filePath
* @param callBack
*/
public
static
void
uploadFile
(
Object
cancelTag
,
String
url
,
Map
<
String
,
String
>
m
ap
,
public
static
void
uploadFile
(
Object
cancelTag
,
String
url
,
Map
<
String
,
String
>
paramsMap
,
Map
<
String
,
String
>
headerM
ap
,
final
String
filePath
,
HttpUtils
.
StringCallBack
callBack
)
{
///////////////////////////////////////////////////////
if
(
m
ap
!=
null
)
{
if
(
paramsM
ap
!=
null
)
{
// 基本传递参数
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
"sobot---请求参数: url = "
+
url
+
", filePath="
+
filePath
+
" "
);
for
(
String
key
:
m
ap
.
keySet
())
{
sb
.
append
(
key
+
"="
+
m
ap
.
get
(
key
)
+
", "
);
for
(
String
key
:
paramsM
ap
.
keySet
())
{
sb
.
append
(
key
+
"="
+
paramsM
ap
.
get
(
key
)
+
", "
);
}
SobotNetLogUtils
.
i
(
sb
.
toString
().
substring
(
0
,
sb
.
toString
().
length
()
-
2
));
}
HttpUtils
.
getInstance
().
uploadFile
(
cancelTag
,
url
,
m
ap
,
filePath
,
callBack
);
HttpUtils
.
getInstance
().
uploadFile
(
cancelTag
,
url
,
paramsMap
,
headerM
ap
,
filePath
,
callBack
);
}
...
...
sobot_network/src/main/java/com/sobot/network/http/HttpUtils.java
View file @
440b8dd5
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment