summaryrefslogtreecommitdiffstats
path: root/core/java/android/database
diff options
context:
space:
mode:
authorJeff Sharkey <jsharkey@android.com>2013-05-07 12:41:33 -0700
committerJeff Sharkey <jsharkey@android.com>2013-08-17 19:05:07 -0700
commit9d0843df7e3984293dc4ab6ee2f9502e898b63aa (patch)
tree9487940fefdc3034d1e13838b0cca47ed5bce35b /core/java/android/database
parenta5599ef636e37cb0b6474349936999be1afe6987 (diff)
downloadframeworks_base-9d0843df7e3984293dc4ab6ee2f9502e898b63aa.zip
frameworks_base-9d0843df7e3984293dc4ab6ee2f9502e898b63aa.tar.gz
frameworks_base-9d0843df7e3984293dc4ab6ee2f9502e898b63aa.tar.bz2
Resized thumbnails; async; extend MatrixCursor.
When requesting thumbnails, check if their dimensions are larger than requested, and downscale to avoid memory pressure. Load them async and with LruCache. Extend MatrixCursor so that RowBuilder can offer() columns without requiring they know the projection map. This makes it easier to respond to query() calls, where the remote side controls the projection map. Use it to handle custom projections in external storage backend. Update date/time formatting to match spec. Bug: 10333418, 10331689 Change-Id: I7e947a8e8068af8a39b55e6766b3241de4f3fc16
Diffstat (limited to 'core/java/android/database')
-rw-r--r--core/java/android/database/MatrixCursor.java47
1 files changed, 36 insertions, 11 deletions
diff --git a/core/java/android/database/MatrixCursor.java b/core/java/android/database/MatrixCursor.java
index 6e68b6b..2a0d9b9 100644
--- a/core/java/android/database/MatrixCursor.java
+++ b/core/java/android/database/MatrixCursor.java
@@ -83,11 +83,10 @@ public class MatrixCursor extends AbstractCursor {
* row
*/
public RowBuilder newRow() {
- rowCount++;
- int endIndex = rowCount * columnCount;
+ final int row = rowCount++;
+ final int endIndex = rowCount * columnCount;
ensureCapacity(endIndex);
- int start = endIndex - columnCount;
- return new RowBuilder(start, endIndex);
+ return new RowBuilder(row);
}
/**
@@ -180,18 +179,29 @@ public class MatrixCursor extends AbstractCursor {
}
/**
- * Builds a row, starting from the left-most column and adding one column
- * value at a time. Follows the same ordering as the column names specified
- * at cursor construction time.
+ * Builds a row of values using either of these approaches:
+ * <ul>
+ * <li>Values can be added with explicit column ordering using
+ * {@link #add(Object)}, which starts from the left-most column and adds one
+ * column value at a time. This follows the same ordering as the column
+ * names specified at cursor construction time.
+ * <li>Column and value pairs can be offered for possible inclusion using
+ * {@link #offer(String, Object)}. If the cursor includes the given column,
+ * the value will be set for that column, otherwise the value is ignored.
+ * This approach is useful when matching data to a custom projection.
+ * </ul>
+ * Undefined values are left as {@code null}.
*/
public class RowBuilder {
+ private final int row;
+ private final int endIndex;
private int index;
- private final int endIndex;
- RowBuilder(int index, int endIndex) {
- this.index = index;
- this.endIndex = endIndex;
+ RowBuilder(int row) {
+ this.row = row;
+ this.index = row * columnCount;
+ this.endIndex = index + columnCount;
}
/**
@@ -210,6 +220,21 @@ public class MatrixCursor extends AbstractCursor {
data[index++] = columnValue;
return this;
}
+
+ /**
+ * Offer value for possible inclusion if this cursor defines the given
+ * column. Columns not defined by the cursor are silently ignored.
+ *
+ * @return this builder to support chaining
+ */
+ public RowBuilder offer(String columnName, Object value) {
+ for (int i = 0; i < columnNames.length; i++) {
+ if (columnName.equals(columnNames[i])) {
+ data[(row * columnCount) + i] = value;
+ }
+ }
+ return this;
+ }
}
// AbstractCursor implementation.