MCPcopy Create free account
hub / github.com/XCSoar/XCSoar / enumerate

Method enumerate

android/src/DownloadUtil.java:123–157  ·  view source on GitHub ↗
(long handler)

Source from the content-addressed store, hash-verified

121 }
122
123 void enumerate(long handler) {
124 DownloadManager.Query query = new DownloadManager.Query();
125 query.setFilterByStatus(DownloadManager.STATUS_PAUSED |
126 DownloadManager.STATUS_PENDING |
127 DownloadManager.STATUS_RUNNING);
128 Cursor c = dm.query(query);
129
130 if (!c.moveToFirst())
131 return;
132
133 final int columnLocalURI =
134 c.getColumnIndexOrThrow(DownloadManager.COLUMN_LOCAL_URI);
135 final int columnStatus =
136 c.getColumnIndexOrThrow(DownloadManager.COLUMN_STATUS);
137 final int columnSize =
138 c.getColumnIndexOrThrow(DownloadManager.COLUMN_TOTAL_SIZE_BYTES);
139 final int columnPosition =
140 c.getColumnIndexOrThrow(DownloadManager.COLUMN_BYTES_DOWNLOADED_SO_FAR);
141
142 do {
143 final String uri = c.getString(columnLocalURI);
144 final String path = matchPath(uri);
145 if (path == null)
146 continue;
147
148 /* strip the "file://" */
149 int status = c.getInt(columnStatus);
150 long size = c.getLong(columnSize);
151 long position = status == DownloadManager.STATUS_RUNNING
152 ? c.getLong(columnPosition)
153 : -1;
154
155 onDownloadAdded(handler, toFinalPath(path), size, position);
156 } while (c.moveToNext());
157 }
158
159 /**
160 * @param path the absolute destination path

Callers

nothing calls this directly

Calls 4

matchPathMethod · 0.95
onDownloadAddedMethod · 0.95
toFinalPathMethod · 0.95
queryMethod · 0.80

Tested by

no test coverage detected