1 package com.android.photos.data; 2 3 import android.database.MatrixCursor; 4 5 6 public class AlbumSetLoader { 7 public static final int INDEX_ID = 0; 8 public static final int INDEX_TITLE = 1; 9 public static final int INDEX_TIMESTAMP = 2; 10 public static final int INDEX_THUMBNAIL_URI = 3; 11 public static final int INDEX_THUMBNAIL_WIDTH = 4; 12 public static final int INDEX_THUMBNAIL_HEIGHT = 5; 13 public static final int INDEX_COUNT_PENDING_UPLOAD = 6; 14 public static final int INDEX_COUNT = 7; 15 public static final int INDEX_SUPPORTED_OPERATIONS = 8; 16 17 public static final String[] PROJECTION = { 18 "_id", 19 "title", 20 "timestamp", 21 "thumb_uri", 22 "thumb_width", 23 "thumb_height", 24 "count_pending_upload", 25 "_count", 26 "supported_operations" 27 }; 28 public static final MatrixCursor MOCK = createRandomCursor(30); 29 createRandomCursor(int count)30 private static MatrixCursor createRandomCursor(int count) { 31 MatrixCursor c = new MatrixCursor(PROJECTION, count); 32 for (int i = 0; i < count; i++) { 33 c.addRow(createRandomRow()); 34 } 35 return c; 36 } 37 createRandomRow()38 private static Object[] createRandomRow() { 39 double random = Math.random(); 40 int id = (int) (500 * random); 41 Object[] row = { 42 id, 43 "Fun times " + id, 44 (long) (System.currentTimeMillis() * random), 45 null, 46 0, 47 0, 48 (random < .3 ? 1 : 0), 49 1, 50 0 51 }; 52 return row; 53 } 54 }