3 Star 0 Fork 0

Gitee 极速下载/ImageLoaderSample

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/wangjiegulu/ImageLoaderSample
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

ImageLoaderSample

android端用于异步加载图片,内存缓存,文件缓存,imageview显示图片时增加淡入淡出动画。

注意:

需要添加LibraryAndroidBucket项目的支持(日志、线程、util等)的依赖,ImageLoader使用的ThreadPool,修改配置文件代码

###Gradle compile 'com.github.wangjiegulu:ImageLoaderSample:1.0.1' ###Maven com.github.wangjiegulu ImageLoaderSample 1.0.1

初始化配置

创建MyApplication 继承Application,在onCreate中增加如下代码:

        /**
         * Created with IntelliJ IDEA.
         * Author: wangjie  email:tiantian.china.2@gmail.com
         * Date: 14-2-27
         * Time: 上午11:25
         */
        public class MyApplication extends ABApplication{

        @Override
            protected void initImageLoader() {
                ImageLoader.init(getApplicationContext(),
                        new CacheConfig()
                                .setDefRequiredSize(600) // 设置默认的加载图片尺寸(表示宽高任一不超过该值,默认是70px)
                                .setDefaultResId(R.drawable.ic_launcher) // 设置显示的默认图片(默认是0,即空白图片)
                                .setBitmapConfig(Bitmap.Config.ARGB_8888) // 设置图片位图模式(默认是Bitmap.CacheConfig.ARGB_8888)
                                .setMemoryCachelimit(Runtime.getRuntime().maxMemory() / 3) // 设置图片内存缓存大小(默认是Runtime.getRuntime().maxMemory() / 4)
        //                    .setFileCachePath(Environment.getExternalStorageDirectory().toString() + "/mycache") // 设置文件缓存保存目录
                );
            }
        ......
    }

###然后再AndroidManifest.xml中添加:
......

加载图片的调用方式如下:

    holder.progress.setText("0%");
    holder.progress.setVisibility(View.VISIBLE);
    final ViewHolder vhr = holder;
    ImageLoader.getInstances().displayImage(list.get(position), holder.image, new ImageLoader.OnImageLoaderListener() {
        @Override
        public void onProgressImageLoader(ImageView imageView, int currentSize, int totalSize) {
            vhr.progress.setText(currentSize * 100 / totalSize + "%");
        }

        @Override
        public void onFinishedImageLoader(ImageView imageView, Bitmap bitmap) {
            vhr.progress.setVisibility(View.GONE);
        }
    });
    或者:
    ImageLoader.getInstances().displayImage(url, imageIv);
    或者
    ImageLoader.getInstances().displayImage(url, imageIv, 100);

备注

例子中,用到了一部分注解(与ImageLoader功能无关,但是可以简化代码的编写) 可以点下面连接进入AndroidInject AndroidInject

License

Copyright 2013 Wang Jie

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

空文件

简介

这个可以实现ImageView异步加载图片,内存缓存,文件缓存,imageview显示图片时增加淡入淡出动画 展开 收起
取消

发行版

暂无发行版

贡献者

全部

语言

近期动态

不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/mirrors/ImageLoaderSample.git
git@gitee.com:mirrors/ImageLoaderSample.git
mirrors
ImageLoaderSample
ImageLoaderSample
master

搜索帮助