本文整理汇总了Java中com.liulishuo.filedownloader.model.FileDownloadStatus类的典型用法代码示例。如果您正苦于以下问题:Java FileDownloadStatus类的具体用法?Java FileDownloadStatus怎么用?Java FileDownloadStatus使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FileDownloadStatus类属于com.liulishuo.filedownloader.model包,在下文中一共展示了FileDownloadStatus类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateNotDownloaded
import com.liulishuo.filedownloader.model.FileDownloadStatus; //导入依赖的package包/类
public void updateNotDownloaded(final int status, final long sofar, final long total) {
if (sofar > 0 && total > 0) {
final float percent = sofar
/ (float) total;
taskPb.setMax(100);
taskPb.setProgress((int) (percent * 100));
} else {
taskPb.setMax(1);
taskPb.setProgress(0);
}
switch (status) {
case FileDownloadStatus.error:
taskStatusTv.setText(R.string.tasks_manager_demo_status_error);
break;
case FileDownloadStatus.paused:
taskStatusTv.setText(R.string.tasks_manager_demo_status_paused);
break;
default:
taskStatusTv.setText(R.string.tasks_manager_demo_status_not_downloaded);
break;
}
// taskActionBtn.setText(R.string.start);
}
示例2: handleProgress
import com.liulishuo.filedownloader.model.FileDownloadStatus; //导入依赖的package包/类
private void handleProgress(final long now,
final boolean isNeedCallbackToUser) {
if (model.getSoFar() == model.getTotal()) {
database.updateProgress(model.getId(), model.getSoFar());
return;
}
if (needSetProcess) {
needSetProcess = false;
model.setStatus(FileDownloadStatus.progress);
}
if (isNeedCallbackToUser) {
lastCallbackTimestamp = now;
onStatusChanged(FileDownloadStatus.progress);
callbackIncreaseBuffer.set(0);
}
}
示例3: onProgress
import com.liulishuo.filedownloader.model.FileDownloadStatus; //导入依赖的package包/类
void onProgress(long increaseBytes) {
callbackIncreaseBuffer.addAndGet(increaseBytes);
model.increaseSoFar(increaseBytes);
model.setStatus(FileDownloadStatus.progress);
final long now = SystemClock.elapsedRealtime();
final boolean isNeedCallbackToUser = isNeedCallbackToUser(now);
if (handler == null) {
// direct
handleProgress(now, isNeedCallbackToUser);
} else if (isNeedCallbackToUser) {
// flow
sendMessage(handler.obtainMessage(FileDownloadStatus.progress));
}
}
示例4: getReceiveServiceTaskList
import com.liulishuo.filedownloader.model.FileDownloadStatus; //导入依赖的package包/类
List<BaseDownloadTask.IRunningTask> getReceiveServiceTaskList(final int id){
final List<BaseDownloadTask.IRunningTask> list = new ArrayList<>();
synchronized (this.mList) {
for (BaseDownloadTask.IRunningTask task : this.mList) {
if (task.is(id) && !task.isOver()) {
final byte status = task.getOrigin().getStatus();
if (status != FileDownloadStatus.INVALID_STATUS &&
status != FileDownloadStatus.toLaunchPool) {
list.add(task);
}
}
}
}
return list;
}
示例5: onStatusChanged
import com.liulishuo.filedownloader.model.FileDownloadStatus; //导入依赖的package包/类
private void onStatusChanged(final byte status) {
// In current situation, it maybe invoke this method simultaneously between #onPause() and
// others.
if (status == FileDownloadStatus.paused) {
if (FileDownloadLog.NEED_LOG) {
/**
* Already paused or the current status is paused.
*
* We don't need to call-back to Task in here, because the pause status has
* already handled by {@link BaseDownloadTask#pause()} manually.
*
* In some case, it will arrive here by High concurrent cause. For performance
* more make sense.
*
* High concurrent cause.
*/
FileDownloadLog.d(this, "High concurrent cause, Already paused and we don't " +
"need to call-back to Task in here, %d", model.getId());
}
return;
}
MessageSnapshotFlow.getImpl().inflow(
MessageSnapshotTaker.take(status, model, processParams));
}
示例6: getStatus
import com.liulishuo.filedownloader.model.FileDownloadStatus; //导入依赖的package包/类
/**
* @param id The downloadId.
* @param path The target file path.
* @return the downloading status.
* @see FileDownloadStatus
* @see #getStatus(String, String)
* @see #getStatusIgnoreCompleted(int)
*/
public byte getStatus(final int id, final String path) {
byte status;
BaseDownloadTask.IRunningTask task = FileDownloadList.getImpl().get(id);
if (task == null) {
status = FileDownloadServiceProxy.getImpl().getStatus(id);
} else {
status = task.getOrigin().getStatus();
}
if (path != null && status == FileDownloadStatus.INVALID_STATUS) {
if (FileDownloadUtils.isFilenameConverted(FileDownloadHelper.getAppContext()) &&
new File(path).exists()) {
status = FileDownloadStatus.completed;
}
}
return status;
}
示例7: handleError
import com.liulishuo.filedownloader.model.FileDownloadStatus; //导入依赖的package包/类
private void handleError(Exception exception) {
Exception errProcessEx = exFiltrate(exception);
if (errProcessEx instanceof SQLiteFullException) {
// If the error is sqLite full exception already, no need to update it to the database
// again.
handleSQLiteFullException((SQLiteFullException) errProcessEx);
} else {
// Normal case.
try {
model.setStatus(FileDownloadStatus.error);
model.setErrMsg(exception.toString());
database.updateError(model.getId(), errProcessEx, model.getSoFar());
} catch (SQLiteFullException fullException) {
errProcessEx = fullException;
handleSQLiteFullException((SQLiteFullException) errProcessEx);
}
}
processParams.setException(errProcessEx);
onStatusChanged(FileDownloadStatus.error);
}
示例8: sendCompletedBroadcast
import com.liulishuo.filedownloader.model.FileDownloadStatus; //导入依赖的package包/类
public static void sendCompletedBroadcast(FileDownloadModel model) {
if (model == null) throw new IllegalArgumentException();
if (model.getStatus() != FileDownloadStatus.completed) throw new IllegalStateException();
final Intent intent = new Intent(ACTION_COMPLETED);
intent.putExtra(KEY_MODEL, model);
FileDownloadHelper.getAppContext().sendBroadcast(intent);
}
示例9: onConnected
import com.liulishuo.filedownloader.model.FileDownloadStatus; //导入依赖的package包/类
void onConnected(boolean isResume, long totalLength, String etag, String fileName) throws IllegalArgumentException {
final String oldEtag = model.getETag();
if (oldEtag != null && !oldEtag.equals(etag)) throw
new IllegalArgumentException(FileDownloadUtils.formatString("callback " +
"onConnected must with precondition succeed, but the etag is changes(%s != %s)",
etag, oldEtag));
// direct
processParams.setResuming(isResume);
model.setStatus(FileDownloadStatus.connected);
model.setTotal(totalLength);
model.setETag(etag);
model.setFilename(fileName);
database.updateConnected(model.getId(), totalLength, etag, fileName);
onStatusChanged(FileDownloadStatus.connected);
callbackMinIntervalBytes = calculateCallbackMinIntervalBytes(totalLength, callbackProgressMaxCount);
}
示例10: reset
import com.liulishuo.filedownloader.model.FileDownloadStatus; //导入依赖的package包/类
@Override
public void reset() {
mThrowable = null;
mEtag = null;
mIsResuming = false;
mRetryingTimes = 0;
mIsReusedOldFile = false;
mIsLargeFile = false;
mSoFarBytes = 0;
mTotalBytes = 0;
mSpeedMonitor.reset();
if (FileDownloadStatus.isOver(mStatus)) {
mMessenger.discard();
mMessenger = new FileDownloadMessenger(mTask.getRunningTask(), this);
} else {
mMessenger.reAppointment(mTask.getRunningTask(), this);
}
mStatus = FileDownloadStatus.INVALID_STATUS;
}
示例11: onStatusChanged
import com.liulishuo.filedownloader.model.FileDownloadStatus; //导入依赖的package包/类
private void onStatusChanged(final byte status) {
// In current situation, it maybe invoke this method simultaneously between #onPause() and
// others.
if (model.getStatus() == FileDownloadStatus.paused) {
if (FileDownloadLog.NEED_LOG) {
/**
* Already paused or the current status is paused.
*
* We don't need to call-back to Task in here, because the pause status has
* already handled by {@link BaseDownloadTask#pause()} manually.
*
* In some case, it will arrive here by High concurrent cause. For performance
* more make sense.
*
* High concurrent cause.
*/
FileDownloadLog.d(this, "High concurrent cause, Already paused and we don't " +
"need to call-back to Task in here, %d", model.getId());
}
return;
}
MessageSnapshotFlow.getImpl().inflow(MessageSnapshotTaker.take(status, model, processParams));
}
示例12: onProgress
import com.liulishuo.filedownloader.model.FileDownloadStatus; //导入依赖的package包/类
void onProgress(long increaseBytes) {
callbackIncreaseBuffer.addAndGet(increaseBytes);
model.increaseSoFar(increaseBytes);
final long now = SystemClock.elapsedRealtime();
final boolean isNeedCallbackToUser = isNeedCallbackToUser(now);
if (handler == null) {
// direct
handleProgress(now, isNeedCallbackToUser);
} else if (isNeedCallbackToUser) {
// flow
sendMessage(handler.obtainMessage(FileDownloadStatus.progress));
}
}
示例13: updateNotDownloaded
import com.liulishuo.filedownloader.model.FileDownloadStatus; //导入依赖的package包/类
public void updateNotDownloaded(final int status, final long sofar, final long total) {
if (sofar > 0 && total > 0) {
final float percent = sofar
/ (float) total;
taskPb.setMax(100);
taskPb.setProgress((int) (percent * 100));
} else {
taskPb.setMax(1);
taskPb.setProgress(0);
}
switch (status) {
case FileDownloadStatus.error:
taskStatusTv.setText(R.string.tasks_manager_demo_status_error);
break;
case FileDownloadStatus.paused:
taskStatusTv.setText(R.string.tasks_manager_demo_status_paused);
break;
default:
taskStatusTv.setText(R.string.tasks_manager_demo_status_not_downloaded);
break;
}
taskActionBtn.setText(R.string.start);
}
示例14: onConnected
import com.liulishuo.filedownloader.model.FileDownloadStatus; //导入依赖的package包/类
void onConnected(boolean isResume, long totalLength, String etag, String fileName) throws
IllegalArgumentException {
final String oldEtag = model.getETag();
if (oldEtag != null && !oldEtag.equals(etag)) throw
new IllegalArgumentException(FileDownloadUtils.formatString("callback " +
"onConnected must with precondition succeed, but the etag is changes(%s != %s)",
etag, oldEtag));
// direct
processParams.setResuming(isResume);
model.setStatus(FileDownloadStatus.connected);
model.setTotal(totalLength);
model.setETag(etag);
model.setFilename(fileName);
database.updateConnected(model.getId(), totalLength, etag, fileName);
onStatusChanged(FileDownloadStatus.connected);
callbackMinIntervalBytes = calculateCallbackMinIntervalBytes(totalLength,
callbackProgressMaxCount);
needSetProcess = true;
}
示例15: updateDownloading
import com.liulishuo.filedownloader.model.FileDownloadStatus; //导入依赖的package包/类
public void updateDownloading(final int status, final long sofar, final long total) {
final float percent = sofar
/ (float) total;
taskPb.setMax(100);
taskPb.setProgress((int) (percent * 100));
switch (status) {
case FileDownloadStatus.pending:
taskStatusTv.setText(R.string.tasks_manager_demo_status_pending);
break;
case FileDownloadStatus.started:
taskStatusTv.setText(R.string.tasks_manager_demo_status_started);
break;
case FileDownloadStatus.connected:
taskStatusTv.setText(R.string.tasks_manager_demo_status_connected);
break;
case FileDownloadStatus.progress:
taskStatusTv.setText(R.string.tasks_manager_demo_status_progress);
break;
default:
// taskStatusTv.setText(MyApplication.CONTEXT.getString(
// R.string.tasks_manager_demo_status_downloading, status));
break;
}
// taskActionBtn.setText(R.string.pause);
}