|
18 | 18 |
|
19 | 19 |
|
20 | 20 | import com.liulishuo.filedownloader.model.FileDownloadModel;
|
| 21 | +import com.liulishuo.filedownloader.model.FileDownloadStatus; |
21 | 22 |
|
22 | 23 | import java.util.List;
|
23 | 24 |
|
|
36 | 37 | public interface FileDownloadDatabase {
|
37 | 38 |
|
38 | 39 | /**
|
39 |
| - * @param id download id |
| 40 | + * Find the model which identify is {@code id}. |
| 41 | + * |
| 42 | + * @param id the download id. |
40 | 43 | */
|
41 | 44 | FileDownloadModel find(final int id);
|
42 | 45 |
|
43 |
| - |
| 46 | + /** |
| 47 | + * Insert the model to the database. |
| 48 | + * |
| 49 | + * @param downloadModel the download model. |
| 50 | + */ |
44 | 51 | void insert(final FileDownloadModel downloadModel);
|
45 | 52 |
|
| 53 | + /** |
| 54 | + * Update the data compare to the {@code downloadModel} |
| 55 | + * |
| 56 | + * @param downloadModel the download model. |
| 57 | + */ |
46 | 58 | void update(final FileDownloadModel downloadModel);
|
47 | 59 |
|
| 60 | + /** |
| 61 | + * Update the batch of datum compare to the {@code downloadModelList} |
| 62 | + * |
| 63 | + * @param downloadModelList the list of model. |
| 64 | + */ |
48 | 65 | void update(final List<FileDownloadModel> downloadModelList);
|
49 | 66 |
|
| 67 | + /** |
| 68 | + * Remove the model which identify is {@code id}. |
| 69 | + * |
| 70 | + * @param id the download id. |
| 71 | + * @return {@code true} if succeed to remove model from the database. |
| 72 | + */ |
50 | 73 | boolean remove(final int id);
|
51 | 74 |
|
| 75 | + /** |
| 76 | + * Clear all models in this database. |
| 77 | + */ |
52 | 78 | void clear();
|
53 | 79 |
|
| 80 | + /** |
| 81 | + * Update the data because of the download status alternative to {@link FileDownloadStatus#connected}. |
| 82 | + * |
| 83 | + * @param model the data in the model will be updated. |
| 84 | + * @param total the new total bytes. |
| 85 | + * @param etag the new etag. |
| 86 | + * @param fileName the new file name. |
| 87 | + */ |
54 | 88 | void updateConnected(final FileDownloadModel model, final long total, final String etag,
|
55 | 89 | final String fileName);
|
56 | 90 |
|
| 91 | + /** |
| 92 | + * Update the data because of the download status alternative to {@link FileDownloadStatus#progress}. |
| 93 | + * |
| 94 | + * @param model the data in the model will be updated. |
| 95 | + * @param soFar the new so far bytes. |
| 96 | + */ |
57 | 97 | void updateProgress(final FileDownloadModel model, final long soFar);
|
58 | 98 |
|
| 99 | + /** |
| 100 | + * Update the data because of the download status alternative to {@link FileDownloadStatus#error}. |
| 101 | + * |
| 102 | + * @param model the data in the model will be updated. |
| 103 | + * @param throwable the new exception. |
| 104 | + * @param sofar the new so far bytes. |
| 105 | + */ |
59 | 106 | void updateError(final FileDownloadModel model, final Throwable throwable, final long sofar);
|
60 | 107 |
|
| 108 | + /** |
| 109 | + * Update the data because of the download status alternative to {@link FileDownloadStatus#retry}. |
| 110 | + * |
| 111 | + * @param model the data in the model will be updated. |
| 112 | + * @param throwable the new exception. |
| 113 | + */ |
61 | 114 | void updateRetry(final FileDownloadModel model, final Throwable throwable);
|
62 | 115 |
|
| 116 | + /** |
| 117 | + * Update the data because of the download status alternative to {@link FileDownloadStatus#completed}. |
| 118 | + * |
| 119 | + * @param model the data in the model will be updated. |
| 120 | + * @param total the new total bytes. |
| 121 | + */ |
63 | 122 | void updateComplete(final FileDownloadModel model, final long total);
|
64 | 123 |
|
| 124 | + /** |
| 125 | + * Update the data because of the download status alternative to {@link FileDownloadStatus#paused}. |
| 126 | + * |
| 127 | + * @param model the data in the model will be updated. |
| 128 | + * @param sofar the new so far bytes. |
| 129 | + */ |
65 | 130 | void updatePause(final FileDownloadModel model, final long sofar);
|
66 | 131 |
|
| 132 | + /** |
| 133 | + * Update the data because of the download status alternative to {@link FileDownloadStatus#pending}. |
| 134 | + * |
| 135 | + * @param model the data in the model will be updated. |
| 136 | + */ |
67 | 137 | void updatePending(final FileDownloadModel model);
|
68 | 138 | }
|
0 commit comments