summaryrefslogtreecommitdiffstats
path: root/src/com/android/photos/data/AlbumSetLoader.java
blob: f5fc3b7321d8b435bd136f0f257209d06fe9fa5f (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
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 MatrixCursor MOCK = createRandomCursor(30);

    private static MatrixCursor createRandomCursor(int count) {
        String[] rows = {
                "_id",
                "title",
                "timestamp",
                "thumb_uri",
                "thumb_width",
                "thumb_height",
                "count_pending_upload",
                "_count"
        };
        MatrixCursor c = new MatrixCursor(rows, 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
        };
        return row;
    }
}