Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
huangzhicong
/
SmartCanteen
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
a0f9d013
authored
Mar 17, 2020
by
pye52
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
删除冗余的实体类
parent
6617adfb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
58 deletions
+0
-58
app/src/main/java/com/bgycc/smartcanteen/entity/ProgressResponseBody.java
+0
-58
No files found.
app/src/main/java/com/bgycc/smartcanteen/entity/ProgressResponseBody.java
deleted
100644 → 0
View file @
6617adfb
package
com
.
bgycc
.
smartcanteen
.
entity
;
import
com.bgycc.smartcanteen.listener.DownloadProgressListener
;
import
org.jetbrains.annotations.NotNull
;
import
java.io.IOException
;
import
okhttp3.MediaType
;
import
okhttp3.ResponseBody
;
import
okio.Buffer
;
import
okio.BufferedSource
;
import
okio.ForwardingSource
;
import
okio.Okio
;
import
okio.Source
;
public
class
ProgressResponseBody
extends
ResponseBody
{
private
final
ResponseBody
responseBody
;
private
final
DownloadProgressListener
listener
;
private
BufferedSource
bufferedSource
;
public
ProgressResponseBody
(
ResponseBody
responseBody
,
DownloadProgressListener
listener
){
this
.
responseBody
=
responseBody
;
this
.
listener
=
listener
;
}
@Override
public
MediaType
contentType
()
{
return
responseBody
.
contentType
();
}
@Override
public
long
contentLength
()
{
return
responseBody
.
contentLength
();
}
@NotNull
@Override
public
BufferedSource
source
()
{
if
(
null
==
bufferedSource
){
bufferedSource
=
Okio
.
buffer
(
source
(
responseBody
.
source
()));
}
return
bufferedSource
;
}
private
Source
source
(
Source
source
)
{
return
new
ForwardingSource
(
source
)
{
long
totalBytesRead
=
0L
;
@Override
public
long
read
(
@NotNull
Buffer
sink
,
long
byteCount
)
throws
IOException
{
long
bytesRead
=
super
.
read
(
sink
,
byteCount
);
totalBytesRead
+=
bytesRead
!=
-
1
?
bytesRead
:
0
;
listener
.
onProgress
(
totalBytesRead
,
responseBody
.
contentLength
(),
bytesRead
==
-
1
);
return
bytesRead
;
}
};
}
}
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