summaryrefslogtreecommitdiff
path: root/src/com/android/dreams/phototable/PhotoSource.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/dreams/phototable/PhotoSource.java')
-rw-r--r--src/com/android/dreams/phototable/PhotoSource.java11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/com/android/dreams/phototable/PhotoSource.java b/src/com/android/dreams/phototable/PhotoSource.java
index 670bd02..32d41c7 100644
--- a/src/com/android/dreams/phototable/PhotoSource.java
+++ b/src/com/android/dreams/phototable/PhotoSource.java
@@ -43,6 +43,9 @@ public abstract class PhotoSource {
private static final String TAG = "PhotoTable.PhotoSource";
private static final boolean DEBUG = false;
+ // An invalid cursor position to represent the uninitialized state.
+ protected static final int INVALID = -2;
+
// This should be large enough for BitmapFactory to decode the header so
// that we can mark and reset the input stream to avoid duplicate network i/o
private static final int BUFFER_SIZE = 128 * 1024;
@@ -248,6 +251,14 @@ public abstract class PhotoSource {
}
}
+ protected int pickRandomStart(int total, int max) {
+ if (max >= total) {
+ return -1;
+ } else {
+ return (mRNG.nextInt() % (total - max)) - 1;
+ }
+ }
+
protected abstract InputStream getStream(ImageData data, int longSide);
protected abstract Collection<ImageData> findImages(int howMany);
public abstract Collection<AlbumData> findAlbums();