public interface FileDownloadDatabase
FileDownloadModel.
The data stored in the database is only used for task resumes from the breakpoint.
The task of the data stored in the database must be a task that has not finished downloading yet,
and if the task has finished downloading, its data will be remove(int) from the
database, since that data is no longer available for resumption of its task pass.
| Modifier and Type | Interface and Description |
|---|---|
static interface |
FileDownloadDatabase.Maintainer
the maintainer for the database, this maintainer will be used when the database is
initializing.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Clear all models in this database.
|
FileDownloadModel |
find(int id)
Find the model which identify is
id. |
java.util.List<ConnectionModel> |
findConnectionModel(int id)
Find the connection model which download identify is
id |
void |
insert(FileDownloadModel downloadModel)
Insert the model to the database.
|
void |
insertConnectionModel(ConnectionModel model)
Insert the
model to connection table. |
FileDownloadDatabase.Maintainer |
maintainer()
Get the maintainer for the database, this maintainer will be used when the database is
initializing.
|
void |
onTaskStart(int id)
Invoked when task is started.
|
boolean |
remove(int id)
Remove the model which identify is
id. |
void |
removeConnections(int id)
Delete all connection model store on database through the download id.
|
void |
update(FileDownloadModel downloadModel)
Update the data compare to the
downloadModel |
void |
updateCompleted(int id,
long total)
Update the data because of the download status alternative to
FileDownloadStatus.completed. |
void |
updateConnected(int id,
long total,
java.lang.String etag,
java.lang.String filename)
Update the data because of the download status alternative to
FileDownloadStatus.connected. |
void |
updateConnectionCount(int id,
int count)
Update the count of connection.
|
void |
updateConnectionModel(int id,
int index,
long currentOffset)
Update the currentOffset with
currentOffset which id is id, index is
index |
void |
updateError(int id,
java.lang.Throwable throwable,
long sofar)
Update the data because of the download status alternative to
FileDownloadStatus.error. |
void |
updateOldEtagOverdue(int id,
java.lang.String newEtag,
long sofar,
long total,
int connectionCount)
Update when the old one is overdue.
|
void |
updatePause(int id,
long sofar)
Update the data because of the download status alternative to
FileDownloadStatus.paused. |
void |
updatePending(int id)
Update the data because of the download status alternative to
FileDownloadStatus.pending. |
void |
updateProgress(int id,
long sofarBytes)
Update the sofar bytes with the status
progress, so don't forget to store the
FileDownloadStatus.progress too. |
void |
updateRetry(int id,
java.lang.Throwable throwable)
Update the data because of the download status alternative to
FileDownloadStatus.retry. |
void onTaskStart(int id)
id - the download id.FileDownloadModel find(int id)
id.id - the download id.java.util.List<ConnectionModel> findConnectionModel(int id)
idid - the download id.void removeConnections(int id)
id - the download id.void insertConnectionModel(ConnectionModel model)
model to connection table.model - the connection model.void updateConnectionModel(int id,
int index,
long currentOffset)
currentOffset which id is id, index is
indexid - the download id.index - the connection index.currentOffset - the current offset.void updateConnectionCount(int id,
int count)
count - the connection count.void insert(FileDownloadModel downloadModel)
downloadModel - the download model.void update(FileDownloadModel downloadModel)
downloadModeldownloadModel - the download model.boolean remove(int id)
id.id - the download id.true if succeed to remove model from the database.void clear()
void updateOldEtagOverdue(int id,
java.lang.String newEtag,
long sofar,
long total,
int connectionCount)
void updateConnected(int id,
long total,
java.lang.String etag,
java.lang.String filename)
FileDownloadStatus.connected.id - the download id.total - the new total bytes.etag - the new etag. this value will be null when we can't find it on
response header.filename - the new file name. this value will be null when its no need to store.void updateProgress(int id,
long sofarBytes)
progress, so don't forget to store the
FileDownloadStatus.progress too.sofarBytes - the current sofar bytes.void updateError(int id,
java.lang.Throwable throwable,
long sofar)
FileDownloadStatus.error.id - the download id.throwable - the new exception.sofar - the new so far bytes.void updateRetry(int id,
java.lang.Throwable throwable)
FileDownloadStatus.retry.id - the download id.throwable - the new exception.void updateCompleted(int id,
long total)
FileDownloadStatus.completed.
The latest version will remove model from DB.id - the download id.total - the new total bytes.void updatePause(int id,
long sofar)
FileDownloadStatus.paused.id - the download id.sofar - the new so far bytes.void updatePending(int id)
FileDownloadStatus.pending.id - the download id.FileDownloadDatabase.Maintainer maintainer()
The maintainer will return all data on the database.