summaryrefslogtreecommitdiffstats
path: root/src/com/android/dreams/phototable/PhotoSource.java
diff options
context:
space:
mode:
authorChris Wren <cwren@android.com>2012-09-06 16:46:57 -0400
committerChris Wren <cwren@android.com>2012-09-07 17:41:42 -0400
commitd85f53c69dead1f1f6c0290b8104422143bc5166 (patch)
tree2a8d5cec293a0b55937a0a8296ed995f2af39bb8 /src/com/android/dreams/phototable/PhotoSource.java
parent83fee9012b6d5c5940de5b96fe8d98653ba14c0d (diff)
downloadandroid_packages_screensavers_PhotoTable-d85f53c69dead1f1f6c0290b8104422143bc5166.tar.gz
android_packages_screensavers_PhotoTable-d85f53c69dead1f1f6c0290b8104422143bc5166.tar.bz2
android_packages_screensavers_PhotoTable-d85f53c69dead1f1f6c0290b8104422143bc5166.zip
Add ability to select the albums to display.
Change-Id: I80ff33c4c880c445b79735d6483bc9337a89e392
Diffstat (limited to 'src/com/android/dreams/phototable/PhotoSource.java')
-rw-r--r--src/com/android/dreams/phototable/PhotoSource.java34
1 files changed, 27 insertions, 7 deletions
diff --git a/src/com/android/dreams/phototable/PhotoSource.java b/src/com/android/dreams/phototable/PhotoSource.java
index 2851c6c..32c7739 100644
--- a/src/com/android/dreams/phototable/PhotoSource.java
+++ b/src/com/android/dreams/phototable/PhotoSource.java
@@ -17,6 +17,7 @@ package com.android.dreams.phototable;
import android.content.ContentResolver;
import android.content.Context;
+import android.content.SharedPreferences;
import android.content.res.Resources;
import android.database.Cursor;
import android.graphics.Bitmap;
@@ -46,25 +47,43 @@ public abstract class PhotoSource {
// that we can mark and reset the input stream to avoid duplicate network i/o
private static final int BUFFER_SIZE = 128 * 1024;
- public static class ImageData {
+ public class ImageData {
public String id;
public String url;
public int orientation;
- public int type;
+
+ InputStream getStream() {
+ return PhotoSource.this.getStream(this);
+ }
+ }
+
+ public static class AlbumData {
+ public String id;
+ public String title;
+ public String thumbnailUrl;
+ public long updated;
+
+ @Override
+ public String toString() {
+ return title;
+ }
}
- private final Context mContext;
private final LinkedList<ImageData> mImageQueue;
private final int mMaxQueueSize;
+ protected final Context mContext;
protected final Resources mResources;
- protected ContentResolver mResolver;
- protected String mSourceName;
protected final Random mRNG;
+ protected final SharedPreferences mSettings;
+ protected final ContentResolver mResolver;
+
+ protected String mSourceName;
- public PhotoSource(Context context) {
+ public PhotoSource(Context context, SharedPreferences settings) {
mSourceName = TAG;
mContext = context;
+ mSettings = settings;
mResolver = mContext.getContentResolver();
mResources = context.getResources();
mImageQueue = new LinkedList<ImageData>();
@@ -91,7 +110,7 @@ public abstract class PhotoSource {
ImageData data = mImageQueue.poll();
InputStream is = null;
try {
- is = getStream(data);
+ is = data.getStream();
BufferedInputStream bis = new BufferedInputStream(is);
bis.mark(BUFFER_SIZE);
@@ -180,4 +199,5 @@ public abstract class PhotoSource {
protected abstract InputStream getStream(ImageData data);
protected abstract Collection<ImageData> findImages(int howMany);
+ public abstract Collection<AlbumData> findAlbums();
}