本文整理汇总了Java中com.liulishuo.filedownloader.model.FileDownloadStatus.completed方法的典型用法代码示例。如果您正苦于以下问题:Java FileDownloadStatus.completed方法的具体用法?Java FileDownloadStatus.completed怎么用?Java FileDownloadStatus.completed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.liulishuo.filedownloader.model.FileDownloadStatus
的用法示例。
在下文中一共展示了FileDownloadStatus.completed方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: takeBlockCompleted
import com.liulishuo.filedownloader.model.FileDownloadStatus; //导入方法依赖的package包/类
public static MessageSnapshot takeBlockCompleted(MessageSnapshot snapshot) {
if (snapshot.getStatus() != FileDownloadStatus.completed) {
throw new IllegalStateException(
FileDownloadUtils.formatString("take block completed snapshot, must has " +
"already be completed. %d %d", snapshot.getId(), snapshot.getStatus()));
}
return new BlockCompleteMessage.BlockCompleteMessageImpl(snapshot);
}
示例3: getStatus
import com.liulishuo.filedownloader.model.FileDownloadStatus; //导入方法依赖的package包/类
/**
* The {@link FileDownloader#getStatus(int, String)} request.
*/
public byte getStatus(final int id, final String path) {
if (FileDownloader.getImpl().isServiceConnected()) {
return FileDownloader.getImpl().getStatus(id, path);
}
if (path != null && new File(path).exists()) {
return FileDownloadStatus.completed;
}
final ConnectSubscriber subscriber = new ConnectSubscriber() {
private byte mValue;
@Override
public void connected() {
mValue = FileDownloader.getImpl().getStatus(id, path);
}
@Override
public Object getValue() {
return mValue;
}
};
wait(subscriber);
return (byte) subscriber.getValue();
}
示例4: handleMessage
import com.liulishuo.filedownloader.model.FileDownloadStatus; //导入方法依赖的package包/类
@Override
public boolean handleMessage(Message msg) {
final int status = msg.what;
switch (status) {
case FileDownloadStatus.progress:
handleProgress(SystemClock.elapsedRealtime(), true);
break;
case FileDownloadStatus.completed:
if (interceptBeforeCompleted()) {
return true;
}
try {
handleCompleted();
} catch (IOException e) {
onError(e);
return true;
}
break;
case FileDownloadStatus.retry:
handleRetry((Exception) msg.obj, msg.arg1);
break;
case FileDownloadStatus.paused:
handlePaused();
break;
case FileDownloadStatus.error:
handleError((Exception) msg.obj);
break;
}
if (FileDownloadStatus.isOver(status)) {
handlerThread.quit();
}
return true;
}
示例5: 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);
}
示例6: show
import com.liulishuo.filedownloader.model.FileDownloadStatus; //导入方法依赖的package包/类
@Override
public void show(boolean statusChanged, int status, boolean isShowProgress) {
String desc = getDesc();
switch (status) {
case FileDownloadStatus.pending:
desc += " pending";
break;
case FileDownloadStatus.started:
desc += " started";
break;
case FileDownloadStatus.progress:
desc += " progress";
break;
case FileDownloadStatus.retry:
desc += " retry";
break;
case FileDownloadStatus.error:
desc += " error";
break;
case FileDownloadStatus.paused:
desc += " paused";
break;
case FileDownloadStatus.completed:
desc += " completed";
break;
case FileDownloadStatus.warn:
desc += " warn";
break;
}
builder.setContentTitle(getTitle())
.setContentText(desc);
if (statusChanged) {
builder.setTicker(desc);
}
builder.setProgress(getTotal(), getSofar(), !isShowProgress);
getManager().notify(getId(), builder.build());
}
示例7: createFromParcel
import com.liulishuo.filedownloader.model.FileDownloadStatus; //导入方法依赖的package包/类
@Override
public MessageSnapshot createFromParcel(Parcel source) {
boolean largeFile = source.readByte() == 1;
byte status = source.readByte();
final MessageSnapshot snapshot;
switch (status) {
case FileDownloadStatus.pending:
if (largeFile) {
snapshot = new LargeMessageSnapshot.PendingMessageSnapshot(source);
} else {
snapshot = new SmallMessageSnapshot.PendingMessageSnapshot(source);
}
break;
case FileDownloadStatus.started:
snapshot = new StartedMessageSnapshot(source);
break;
case FileDownloadStatus.connected:
if (largeFile) {
snapshot = new LargeMessageSnapshot.ConnectedMessageSnapshot(source);
} else {
snapshot = new SmallMessageSnapshot.ConnectedMessageSnapshot(source);
}
break;
case FileDownloadStatus.progress:
if (largeFile) {
snapshot = new LargeMessageSnapshot.ProgressMessageSnapshot(source);
} else {
snapshot = new SmallMessageSnapshot.ProgressMessageSnapshot(source);
}
break;
case FileDownloadStatus.retry:
if (largeFile) {
snapshot = new LargeMessageSnapshot.RetryMessageSnapshot(source);
} else {
snapshot = new SmallMessageSnapshot.RetryMessageSnapshot(source);
}
break;
case FileDownloadStatus.error:
if (largeFile) {
snapshot = new LargeMessageSnapshot.ErrorMessageSnapshot(source);
} else {
snapshot = new SmallMessageSnapshot.ErrorMessageSnapshot(source);
}
break;
case FileDownloadStatus.completed:
if (largeFile) {
snapshot = new LargeMessageSnapshot.CompletedSnapshot(source);
} else {
snapshot = new SmallMessageSnapshot.CompletedSnapshot(source);
}
break;
case FileDownloadStatus.warn:
if (largeFile) {
snapshot = new LargeMessageSnapshot.WarnMessageSnapshot(source);
} else {
snapshot = new SmallMessageSnapshot.WarnMessageSnapshot(source);
}
break;
default:
snapshot = null;
}
if (snapshot != null) {
snapshot.isLargeFile = largeFile;
} else {
throw new IllegalStateException("Can't restore the snapshot because unknown " +
"status: " + status);
}
return snapshot;
}
示例8: getStatus
import com.liulishuo.filedownloader.model.FileDownloadStatus; //导入方法依赖的package包/类
@Override
public byte getStatus() {
return FileDownloadStatus.completed;
}
示例9: remove
import com.liulishuo.filedownloader.model.FileDownloadStatus; //导入方法依赖的package包/类
/**
* @param willRemoveDownload will be remove
*/
public boolean remove(final BaseDownloadTask.IRunningTask willRemoveDownload,
MessageSnapshot snapshot) {
final byte removeByStatus = snapshot.getStatus();
boolean succeed;
synchronized (mList) {
succeed = mList.remove(willRemoveDownload);
}
if (FileDownloadLog.NEED_LOG) {
if (mList.size() == 0) {
FileDownloadLog.v(this, "remove %s left %d %d",
willRemoveDownload, removeByStatus, mList.size());
}
}
if (succeed) {
final IFileDownloadMessenger messenger = willRemoveDownload.getMessageHandler().
getMessenger();
// Notify 2 Listener
switch (removeByStatus) {
case FileDownloadStatus.warn:
messenger.notifyWarn(snapshot);
break;
case FileDownloadStatus.error:
messenger.notifyError(snapshot);
break;
case FileDownloadStatus.paused:
messenger.notifyPaused(snapshot);
break;
case FileDownloadStatus.completed:
messenger.notifyBlockComplete(MessageSnapshotTaker.takeBlockCompleted(snapshot));
break;
}
} else {
FileDownloadLog.e(this, "remove error, not exist: %s %d", willRemoveDownload,
removeByStatus);
}
return succeed;
}