From 66cfb5c7a836bbb043ce60480c3626faae42b89c Mon Sep 17 00:00:00 2001 From: Ben Kwa Date: Fri, 8 Jan 2016 15:38:55 -0800 Subject: Assign a null timestamp to active downloads. This makes it such that ordering downloads by timestamp doesn't continually shuffle stuff around if the UI happens to be sorting files by mod time. BUG=26417297 Change-Id: Ibe51513ee5d27ff959f8e7a2a5bad7244c3a731f --- src/com/android/providers/downloads/DownloadStorageProvider.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/com/android/providers/downloads/DownloadStorageProvider.java b/src/com/android/providers/downloads/DownloadStorageProvider.java index c8d942c8..c626b4f9 100644 --- a/src/com/android/providers/downloads/DownloadStorageProvider.java +++ b/src/com/android/providers/downloads/DownloadStorageProvider.java @@ -372,8 +372,12 @@ public class DownloadStorageProvider extends DocumentsProvider { row.add(Document.COLUMN_SUMMARY, summary); row.add(Document.COLUMN_SIZE, size); row.add(Document.COLUMN_MIME_TYPE, mimeType); - row.add(Document.COLUMN_LAST_MODIFIED, lastModified); row.add(Document.COLUMN_FLAGS, flags); + // Incomplete downloads get a null timestamp. This prevents thrashy UI when a bunch of + // active downloads get sorted by mod time. + if (status != DownloadManager.STATUS_RUNNING) { + row.add(Document.COLUMN_LAST_MODIFIED, lastModified); + } final String localFilePath = cursor.getString( cursor.getColumnIndexOrThrow(DownloadManager.COLUMN_LOCAL_FILENAME)); -- cgit v1.2.3