Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
android
/
dayu
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
cbed9b96
authored
Feb 05, 2018
by
罗翻
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Api修改
parent
e0fe8b56
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
11 deletions
app/src/main/java/com/dayu/bigfish/api/Api.java
app/src/main/java/com/dayu/bigfish/api/ApiFactory.java
app/src/main/java/com/dayu/bigfish/api/Api.java
View file @
cbed9b96
...
...
@@ -35,15 +35,17 @@ public class Api {
private
static
Retrofit
downloadRetrofit
;
/**
*普通retrofit.
* 普通retrofit.
*
* @return
*/
public
static
APIService
getService
(
)
{
return
getRetrofit
().
create
(
APIService
.
clas
s
);
public
static
<
T
>
T
getService
(
Class
<
T
>
cls
)
{
return
getRetrofit
().
create
(
cl
s
);
}
/**
* 下载的retrofit.
*
* @return
*/
public
static
APIService
getDownloadService
()
{
...
...
@@ -78,13 +80,13 @@ public class Api {
.
writeTimeout
(
DEFAULT_TIMEOUT
,
TimeUnit
.
SECONDS
)
.
connectTimeout
(
DEFAULT_TIMEOUT
,
TimeUnit
.
SECONDS
);
if
(
"download"
.
equals
(
type
))
{
build
.
addNetworkInterceptor
(
chain
->
{
Response
response
=
chain
.
proceed
(
chain
.
request
());
return
response
.
newBuilder
()
.
body
(
new
FileResponseBody
(
response
.
body
()))
//将自定义的ResposeBody设置给它
.
build
();
});
build
.
addNetworkInterceptor
(
chain
->
{
Response
response
=
chain
.
proceed
(
chain
.
request
());
return
response
.
newBuilder
()
.
body
(
new
FileResponseBody
(
response
.
body
()))
//将自定义的ResposeBody设置给它
.
build
();
});
}
return
new
Retrofit
.
Builder
()
.
client
(
build
.
build
())
...
...
@@ -111,7 +113,6 @@ public class Api {
.
build
();
}
}
// Log.d("request_header", request.headers().toString());
return
chain
.
proceed
(
request
);
}
}
...
...
app/src/main/java/com/dayu/bigfish/api/ApiFactory.java
View file @
cbed9b96
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