Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
polysoft-nafmii
/
polysoft-android
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 9f947bbd
authored
Jul 16, 2021
by
amateur
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
1
1 parent
f2e466b9
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
23 deletions
app/src/main/java/com/polysoft/nafmii/constants/ServerApi.java
app/src/main/java/com/polysoft/nafmii/net/OkhttpApi.java
app/src/main/java/com/polysoft/nafmii/constants/ServerApi.java
View file @
9f947bb
...
@@ -8,29 +8,16 @@ import java.util.Map;
...
@@ -8,29 +8,16 @@ import java.util.Map;
public
class
ServerApi
{
public
class
ServerApi
{
public
static
final
String
url_version
=
""
;
// 获取广告信息
public
static
final
String
advertisement
=
"nafmii-app-public-server/api/app/index/getOpenScreenImage"
;
/**
* 获取广告信息
*
* @param callback
* @param <T>
*/
public
static
<
T
>
void
postAdvertisement
(
RequestBack
<
T
>
callback
)
{
public
static
<
T
>
void
postAdvertisement
(
RequestBack
<
T
>
callback
)
{
post
(
advertisement
,
""
,
callback
);
String
url
=
"nafmii-app-public-server/api/app/index/getOpenScreenImage"
;
OkhttpApi
.
doPost
(
url
,
""
,
callback
);
}
}
public
static
<
T
>
void
get
(
String
url
,
RequestBack
<
T
>
callback
)
{
get
(
url
,
null
,
callback
);
}
public
static
<
T
>
void
get
(
String
url
,
Map
<
String
,
String
>
param
,
RequestBack
<
T
>
callback
)
{
String
newUrl
=
BuildConfig
.
API_HOST
+
url
;
OkhttpApi
.
doGet
(
newUrl
,
param
,
callback
);
}
public
static
<
T
>
void
post
(
String
url
,
String
param
,
RequestBack
<
T
>
callback
)
{
String
newUrl
=
BuildConfig
.
API_HOST
+
url
;
OkhttpApi
.
doPost
(
newUrl
,
param
,
callback
);
}
}
}
app/src/main/java/com/polysoft/nafmii/net/OkhttpApi.java
View file @
9f947bb
...
@@ -5,6 +5,7 @@ import android.util.Log;
...
@@ -5,6 +5,7 @@ import android.util.Log;
import
androidx.annotation.NonNull
;
import
androidx.annotation.NonNull
;
import
com.polysoft.nafmii.utils.IOUtils
;
import
com.polysoft.nafmii.utils.IOUtils
;
import
com.whaty.nafmii.BuildConfig
;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.annotations.NotNull
;
...
@@ -51,7 +52,8 @@ public class OkhttpApi {
...
@@ -51,7 +52,8 @@ public class OkhttpApi {
}
}
public
static
void
doGet
(
String
url
,
Map
<
String
,
String
>
param
,
RequestBack
callback
)
{
public
static
void
doGet
(
String
url
,
Map
<
String
,
String
>
param
,
RequestBack
callback
)
{
HttpUrl
.
Builder
builder
=
HttpUrl
.
parse
(
url
).
newBuilder
();
String
newUrl
=
BuildConfig
.
API_HOST
+
url
;
HttpUrl
.
Builder
builder
=
HttpUrl
.
parse
(
newUrl
).
newBuilder
();
if
(
null
!=
param
&&
!
param
.
isEmpty
())
{
if
(
null
!=
param
&&
!
param
.
isEmpty
())
{
for
(
Map
.
Entry
<
String
,
String
>
entry
:
param
.
entrySet
())
{
for
(
Map
.
Entry
<
String
,
String
>
entry
:
param
.
entrySet
())
{
builder
.
addQueryParameter
(
entry
.
getKey
(),
entry
.
getValue
());
builder
.
addQueryParameter
(
entry
.
getKey
(),
entry
.
getValue
());
...
@@ -64,11 +66,12 @@ public class OkhttpApi {
...
@@ -64,11 +66,12 @@ public class OkhttpApi {
public
static
void
doPost
(
String
url
,
String
param
,
RequestBack
callback
)
{
public
static
void
doPost
(
String
url
,
String
param
,
RequestBack
callback
)
{
String
newUrl
=
BuildConfig
.
API_HOST
+
url
;
MediaType
mediaType
=
MediaType
.
parse
(
"application/json;charset=UTF-8"
);
MediaType
mediaType
=
MediaType
.
parse
(
"application/json;charset=UTF-8"
);
RequestBody
body
=
RequestBody
.
create
(
param
,
mediaType
);
RequestBody
body
=
RequestBody
.
create
(
param
,
mediaType
);
Request
.
Builder
request
=
buildRequest
(
1
);
Request
.
Builder
request
=
buildRequest
(
1
);
request
.
url
(
u
rl
).
post
(
body
);
request
.
url
(
newU
rl
).
post
(
body
);
getInstance
().
newCall
(
request
.
build
()).
enqueue
(
new
CallbackImpl
(
callback
));
getInstance
().
newCall
(
request
.
build
()).
enqueue
(
new
CallbackImpl
(
callback
));
}
}
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment