add preload amount as arg for photo grid instance
diff --git a/samples/flickr/src/com/bumptech/glide/samples/flickr/FlickrPhotoGrid.java b/samples/flickr/src/com/bumptech/glide/samples/flickr/FlickrPhotoGrid.java
index 8d22f6e..9ce5e47 100644
--- a/samples/flickr/src/com/bumptech/glide/samples/flickr/FlickrPhotoGrid.java
+++ b/samples/flickr/src/com/bumptech/glide/samples/flickr/FlickrPhotoGrid.java
@@ -26,17 +26,18 @@
public class FlickrPhotoGrid extends SherlockFragment implements PhotoViewer {
private static final String IMAGE_SIZE_KEY = "image_size";
- private static final int PRELOAD_COUNT = 10;
+ private static final String PRELOAD_KEY = "preload";
private PhotoAdapter adapter;
private List<Photo> currentPhotos;
private int photoSize;
private final Cache<URL> urlCache = new Cache<URL>();
- public static FlickrPhotoGrid newInstance(int size) {
+ public static FlickrPhotoGrid newInstance(int size, int preloadCount) {
FlickrPhotoGrid photoGrid = new FlickrPhotoGrid();
Bundle args = new Bundle();
args.putInt(IMAGE_SIZE_KEY, size);
+ args.putInt(PRELOAD_KEY, preloadCount);
photoGrid.setArguments(args);
return photoGrid;
}
@@ -49,7 +50,7 @@
final View result = inflater.inflate(R.layout.flickr_photo_grid, container, false);
final GridView grid = (GridView) result.findViewById(R.id.images);
grid.setColumnWidth(photoSize);
- final FlickrPreloader preloader = new FlickrPreloader(getActivity(), PRELOAD_COUNT);
+ final FlickrPreloader preloader = new FlickrPreloader(getActivity(), args.getInt(PRELOAD_KEY));
grid.setOnScrollListener(preloader);
adapter = new PhotoAdapter();
grid.setAdapter(adapter);
@@ -67,13 +68,15 @@
}
private class FlickrPreloader extends ListPreloader<Photo> {
+ private final int[] dimens = new int[] { photoSize, photoSize };
+
public FlickrPreloader(Context context, int toPreload) {
super(context, toPreload);
}
@Override
protected int[] getDimens(Photo item) {
- return new int[] { photoSize, photoSize };
+ return dimens;
}
@Override
diff --git a/samples/flickr/src/com/bumptech/glide/samples/flickr/FlickrSearchActivity.java b/samples/flickr/src/com/bumptech/glide/samples/flickr/FlickrSearchActivity.java
index cc935bf..b5e6c18 100644
--- a/samples/flickr/src/com/bumptech/glide/samples/flickr/FlickrSearchActivity.java
+++ b/samples/flickr/src/com/bumptech/glide/samples/flickr/FlickrSearchActivity.java
@@ -95,7 +95,6 @@
glide.setImageManager(new ImageManager.Builder(this)
.setBitmapCompressQuality(70)
- .setMemoryCache(new LruMemoryCache(ImageManager.getSafeMemoryCacheSize(this)/4))
.setDiskCache(diskCache));
}
@@ -245,11 +244,11 @@
Page page = Page.values()[position];
if (page == Page.SMALL) {
int pageSize = getPageSize(R.dimen.small_photo_side);
- return FlickrPhotoGrid.newInstance(pageSize);
+ return FlickrPhotoGrid.newInstance(pageSize, 30);
} else if (page == Page.MEDIUM) {
int pageSize = getPageSize(R.dimen.medium_photo_side);
- return FlickrPhotoGrid.newInstance(pageSize);
+ return FlickrPhotoGrid.newInstance(pageSize, 10);
} else if (page == Page.LIST) {
return FlickrPhotoList.newInstance();
} else {