summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Tomasz Mikolajewski <mtomasz@google.com> 2016-04-25 09:58:09 +0900
committer Tomasz Mikolajewski <mtomasz@google.com> 2016-04-25 10:00:56 +0900
commit6be540666ab6c52e103c8e1faf03945fe2b5fa3c (patch)
tree4298245f2fa421c9f74448e8501071e71ca24d4b
parent0fb51357afb64a034a59f68a926f79d18213c72c (diff)
Fix index computation for quick viewing.
Bug: 28305994 Change-Id: I8c7abc83bd5ca6f01533a4a7ed0bb995c00833af
-rw-r--r--packages/DocumentsUI/src/com/android/documentsui/QuickViewIntentBuilder.java13
1 files changed, 8 insertions, 5 deletions
diff --git a/packages/DocumentsUI/src/com/android/documentsui/QuickViewIntentBuilder.java b/packages/DocumentsUI/src/com/android/documentsui/QuickViewIntentBuilder.java
index c78face9730a..af6aee759eec 100644
--- a/packages/DocumentsUI/src/com/android/documentsui/QuickViewIntentBuilder.java
+++ b/packages/DocumentsUI/src/com/android/documentsui/QuickViewIntentBuilder.java
@@ -101,7 +101,10 @@ final class QuickViewIntentBuilder {
}
}
- intent.putExtra(Intent.EXTRA_INDEX, documentLocation);
+ // The documentLocation variable contains an index in "uris". However,
+ // ClipData contains a slice of "uris", so we need to shift the location
+ // so it points to the same Uri.
+ intent.putExtra(Intent.EXTRA_INDEX, documentLocation - range.getLower());
intent.setClipData(clipData);
return intent;
@@ -147,12 +150,12 @@ final class QuickViewIntentBuilder {
authority = getCursorString(cursor, RootCursorWrapper.COLUMN_AUTHORITY);
uri = DocumentsContract.buildDocumentUri(authority, id);
+ uris.add(uri);
+
if (id.equals(mDocument.documentId)) {
- if (DEBUG) Log.d(TAG, "Found starting point for QV. " + i);
- documentLocation = i;
+ documentLocation = uris.size() - 1; // Position in "uris", not in the model.
+ if (DEBUG) Log.d(TAG, "Found starting point for QV. " + documentLocation);
}
-
- uris.add(uri);
}
return documentLocation;