summaryrefslogtreecommitdiffstats
path: root/src/com/android/photos/data/AlbumSetLoader.java
blob: 94047325574b202b7831bf1bb49e158d7c2ff6c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package com.android.photos.data;

import android.database.MatrixCursor;


public class AlbumSetLoader {
    public static final int INDEX_ID = 0;
    public static final int INDEX_TITLE = 1;
    public static final int INDEX_TIMESTAMP = 2;
    public static final int INDEX_THUMBNAIL_URI = 3;
    public static final int INDEX_THUMBNAIL_WIDTH = 4;
    public static final int INDEX_THUMBNAIL_HEIGHT = 5;
    public static final int INDEX_COUNT_PENDING_UPLOAD = 6;
    public static final int INDEX_COUNT = 7;
    public static final int INDEX_SUPPORTED_OPERATIONS = 8;

    public static final String[] PROJECTION = {
        "_id",
        "title",
        "timestamp",
        "thumb_uri",
        "thumb_width",
        "thumb_height",
        "count_pending_upload",
        "_count",
        "supported_operations"
    };
    public static final MatrixCursor MOCK = createRandomCursor(30);

    private static MatrixCursor createRandomCursor(int count) {
        MatrixCursor c = new MatrixCursor(PROJECTION, count);
        for (int i = 0; i < count; i++) {
            c.addRow(createRandomRow());
        }
        return c;
    }

    private static Object[] createRandomRow() {
        double random = Math.random();
        int id = (int) (500 * random);
        Object[] row = {
            id,
            "Fun times " + id,
            (long) (System.currentTimeMillis() * random),
            null,
            0,
            0,
            (random < .3 ? 1 : 0),
            1,
            0
        };
        return row;
    }
}