Search in sources :

Example 1 with ImageCacheParams

use of com.example.android.bitmapfun.util.ImageCache.ImageCacheParams in project AndroidDynamicLoader by mmin18.

the class ImageGridFragment method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setHasOptionsMenu(true);
    MyResources res = MyResources.getResource(ImageGridFragment.class);
    mImageThumbSize = res.getResources().getDimensionPixelSize(R.dimen.image_thumbnail_size);
    mImageThumbSpacing = res.getResources().getDimensionPixelSize(R.dimen.image_thumbnail_spacing);
    // The empty_photo bitmap is in our package, so we use res.getResources() instead of context.getResources()
    Bitmap emptyPhoto = BitmapFactory.decodeResource(res.getResources(), R.drawable.empty_photo);
    mAdapter = new ImageAdapter(getActivity());
    ImageCacheParams cacheParams = new ImageCacheParams(getActivity(), IMAGE_CACHE_DIR);
    // Set memory cache to 25% of app memory
    cacheParams.setMemCacheSizePercent(0.25f);
    // The ImageFetcher takes care of loading images into our ImageView children asynchronously
    mImageFetcher = new ImageFetcher(getActivity(), mImageThumbSize);
    mImageFetcher.setLoadingImage(emptyPhoto);
    mImageFetcher.addImageCache(getActivity().getFragmentManager(), cacheParams);
}
Also used : Bitmap(android.graphics.Bitmap) MyResources(com.dianping.loader.MyResources) ImageFetcher(com.example.android.bitmapfun.util.ImageFetcher) ImageCacheParams(com.example.android.bitmapfun.util.ImageCache.ImageCacheParams)

Aggregations

Bitmap (android.graphics.Bitmap)1 MyResources (com.dianping.loader.MyResources)1 ImageCacheParams (com.example.android.bitmapfun.util.ImageCache.ImageCacheParams)1 ImageFetcher (com.example.android.bitmapfun.util.ImageFetcher)1