use of com.ichi2.utils.okhttp.listener.impl.model.ProgressModel in project AnkiChinaAndroid by ankichinateam.
the class UIProgressListener method onProgress.
@Override
public void onProgress(long bytesWrite, long contentLength, boolean done) {
// 如果是第一次,发送消息
if (!isFirst) {
isFirst = true;
Message start = Message.obtain();
start.obj = new ProgressModel(bytesWrite, contentLength, done);
start.what = ProgressHandler.START;
mHandler.sendMessage(start);
}
// 通过Handler发送进度消息
Message message = Message.obtain();
message.obj = new ProgressModel(bytesWrite, contentLength, done);
message.what = ProgressHandler.UPDATE;
mHandler.sendMessage(message);
if (done) {
Message finish = Message.obtain();
finish.obj = new ProgressModel(bytesWrite, contentLength, done);
finish.what = ProgressHandler.FINISH;
mHandler.sendMessage(finish);
}
}
Aggregations