关于异步加载图片库的使用 异步缓存库图片 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 或者说关于Picasso的使用,是否有一个比较详细的Demo,最好是有涉及到一些它的高级用法的实例,现在在用的只有简单的load into Imageloader 貌似比较出色,楼主可取看看 一直在用imageloader,我觉得比较全面,楼主可以试试,维护的人也比较多,它会采用全局的配置他的config,比如线程池,缓存大小,也集成LruMemoryCache等等,比较灵活,楼主要是需要的话我可以提供给你我们项目中的使用逻辑(已经很成熟了)。Picasso很早以前用过都忘了是什么样的 是UniversalImageLoader么还是单单就是ImageLoader,gitHub上面找的有点懵 十分感谢,能否提供一下相关的使用经验,比如加载实例的配置设置和一般在什么时候清理缓存抱歉这么久才回复https://github.com/nostra13/Android-Universal-Image-Loader 下这个就行了,里面例子实现,原理都有。 十分感谢,能否提供一下相关的使用经验,比如加载实例的配置设置和一般在什么时候清理缓存抱歉这么久才回复https://github.com/nostra13/Android-Universal-Image-Loader 下这个就行了,里面例子实现,原理都有。我现在使用的是UIL ,但是还是会遇到OOM问题,所以想请教依一下,关于这个类库的使用配置需要注意哪些地方1.ImageLoader是在MyApplication里面定义一个全局的实例好,还是每次使用的时候直接getInstance就行,又或者无所谓;2.ImageLoader的cache一般使用什么?LruCache?WeakMemoryCache?cache的大小是多少合适?3.有两个加载图片的Activity界面是一直存在于程序之中的,也就是说,如果程序没有退出,那么他们就不会onDestroy,最多只是OnStop,那么如何管理这样的图片缓存,需要在onStop里面去手动clear 缓存么?以下是我的一些配置代码:1.在MyApplication里面初始化ImageLoader的配置ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder( getApplicationContext()).memoryCacheExtraOptions(480, 480) // default = device screen dimensions .threadPoolSize(3) // default .threadPriority(Thread.NORM_PRIORITY - 1) // default .tasksProcessingOrder(QueueProcessingType.FIFO) .denyCacheImageMultipleSizesInMemory .memoryCache(new WeakMemoryCache()) // memoryCacheSizePercentage .memoryCacheSizePercentage(12) // default .diskCacheSize(50 * 1024 * 1024) // diskCacheFileCount .diskCacheFileCount(100) // cacheFileNameGenerator .diskCacheFileNameGenerator(new HashCodeFileNameGenerator()) // // default .imageDownloader( new BaseImageDownloader(getApplicationContext())) // // default .imageDecoder(new BaseImageDecoder(true)) // default // logs,delete it when release .writeDebugLogs() // build .build(); ImageLoader.getInstance().init(config);2.DisplayImageOptions的配置DisplayImageOptions options = new DisplayImageOptions.Builder() .showImageOnLoading(R.drawable.default_img) .showImageForEmptyUri(R.drawable.default_img) .showImageOnFail(R.drawable.default_img) .resetViewBeforeLoading(false).cacheOnDisk(true) .cacheInMemory(true) .imageScaleType(ImageScaleType.IN_SAMPLE_INT) .bitmapConfig(Bitmap.Config.RGB_565) .displayer(new FadeInBitmapDisplayer(0)).build(); 1,配置我是在application中做的全局的,具体实例是用mImageLoader = ImageLoader.getInstance();2,下面是我的配置ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder( this) // .memoryCacheExtraOptions(200, 200) // default = device screen dimensions // .diskCacheExtraOptions(48, 48, null) .threadPoolSize(3) // default .threadPriority(Thread.NORM_PRIORITY - 2) // default .tasksProcessingOrder(QueueProcessingType.FIFO) .memoryCache(new LruMemoryCache(4 * 1024 * 1024)) .memoryCacheSizePercentage(10) // default // .denyCacheImageMultipleSizesInMemory() // .memoryCacheSize(10 * 1024 * 1024) // .memoryCacheSize(20) // default .discCacheExtraOptions(400, 800, null) .discCache(new UnlimitedDiskCache(cacheDir)) .discCacheFileNameGenerator(new Md5FileNameGenerator()) .discCacheSize(128 * 1024 * 1024) .discCacheFileCount(1000) .imageDownloader( new BaseImageDownloader(this, 5 * 1000, 30 * 1000)) // default .imageDecoder(new BaseImageDecoder(true)) .defaultDisplayImageOptions(DisplayImageOptions.createSimple()) // default .build(); ImageLoader.getInstance().init(config);3,我没明白你的activity的机制,你可以去跟踪一下heap看看是怎么溢出的,下面这个帖子看一下会有帮助,http://blog.csdn.net/zhiying201039/article/details/8581982 想把SD卡以树形结构显示要怎么做啊? 是把我下列的程序和Tree结合吗? 如果是结合要怎么做啊 做小应用关于图片分辨率 如何让在wifi打开的情况下。也能使用到GPRS ※★※★URI打开网页怎么用post传递数据??※★※★ android sdcard中复制粘贴功能遇到的问题,求指教 蓝牙自动配对时不弹出用户输入界面 Android中使用POI写入word,表格为什么不能超过六列? 百度定位API的定位数据获得 Android Studio报错求助!!! alertdialog 二次开发界面调整 abortBroadcast 起作用.我的优先级已经设置1000 为什么还是不能拦截 短信呢
十分感谢,能否提供一下相关的使用经验,比如加载实例的配置设置和一般在什么时候清理缓存
抱歉这么久才回复
https://github.com/nostra13/Android-Universal-Image-Loader 下这个就行了,里面例子实现,原理都有。
十分感谢,能否提供一下相关的使用经验,比如加载实例的配置设置和一般在什么时候清理缓存
抱歉这么久才回复https://github.com/nostra13/Android-Universal-Image-Loader 下这个就行了,里面例子实现,原理都有。
我现在使用的是UIL ,但是还是会遇到OOM问题,所以想请教依一下,关于这个类库的使用配置需要注意哪些地方
1.ImageLoader是在MyApplication里面定义一个全局的实例好,还是每次使用的时候直接getInstance就行,又或者无所谓;
2.ImageLoader的cache一般使用什么?LruCache?WeakMemoryCache?cache的大小是多少合适?
3.有两个加载图片的Activity界面是一直存在于程序之中的,也就是说,如果程序没有退出,那么他们就不会onDestroy,最多只是OnStop,那么如何管理这样的图片缓存,需要在onStop里面去手动clear 缓存么?以下是我的一些配置代码:
1.在MyApplication里面初始化ImageLoader的配置
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(
getApplicationContext()).memoryCacheExtraOptions(480, 480)
// default = device screen dimensions
.threadPoolSize(3)
// default
.threadPriority(Thread.NORM_PRIORITY - 1)
// default
.tasksProcessingOrder(QueueProcessingType.FIFO)
.denyCacheImageMultipleSizesInMemory
.memoryCache(new WeakMemoryCache())
// memoryCacheSizePercentage
.memoryCacheSizePercentage(12)
// default
.diskCacheSize(50 * 1024 * 1024)
// diskCacheFileCount
.diskCacheFileCount(100)
// cacheFileNameGenerator
.diskCacheFileNameGenerator(new HashCodeFileNameGenerator()) //
// default
.imageDownloader(
new BaseImageDownloader(getApplicationContext())) //
// default
.imageDecoder(new BaseImageDecoder(true)) // default
// logs,delete it when release
.writeDebugLogs()
// build
.build();
ImageLoader.getInstance().init(config);2.DisplayImageOptions的配置DisplayImageOptions options = new DisplayImageOptions.Builder()
.showImageOnLoading(R.drawable.default_img)
.showImageForEmptyUri(R.drawable.default_img)
.showImageOnFail(R.drawable.default_img)
.resetViewBeforeLoading(false).cacheOnDisk(true)
.cacheInMemory(true)
.imageScaleType(ImageScaleType.IN_SAMPLE_INT)
.bitmapConfig(Bitmap.Config.RGB_565)
.displayer(new FadeInBitmapDisplayer(0)).build();
2,下面是我的配置
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(
this)
// .memoryCacheExtraOptions(200, 200)
// default = device screen dimensions
// .diskCacheExtraOptions(48, 48, null)
.threadPoolSize(3)
// default
.threadPriority(Thread.NORM_PRIORITY - 2)
// default
.tasksProcessingOrder(QueueProcessingType.FIFO)
.memoryCache(new LruMemoryCache(4 * 1024 * 1024))
.memoryCacheSizePercentage(10)
// default
// .denyCacheImageMultipleSizesInMemory()
// .memoryCacheSize(10 * 1024 * 1024)
// .memoryCacheSize(20)
// default
.discCacheExtraOptions(400, 800, null)
.discCache(new UnlimitedDiskCache(cacheDir))
.discCacheFileNameGenerator(new Md5FileNameGenerator())
.discCacheSize(128 * 1024 * 1024)
.discCacheFileCount(1000)
.imageDownloader(
new BaseImageDownloader(this, 5 * 1000, 30 * 1000))
// default
.imageDecoder(new BaseImageDecoder(true))
.defaultDisplayImageOptions(DisplayImageOptions.createSimple()) // default
.build();
ImageLoader.getInstance().init(config);
3,我没明白你的activity的机制,你可以去跟踪一下heap看看是怎么溢出的,下面这个帖子看一下会有帮助,http://blog.csdn.net/zhiying201039/article/details/8581982