Giter VIP home page Giter VIP logo

easyimageloader's Introduction

EasyImageLoader

轻量级图片加载库。具有图片加载,图片缓存、图片压缩功能。 将内存缓存、本地缓存、网络请求、图片压缩、线程池封装,做到模块独立,降低耦合度,只给外层提供ImagLoader的bindBitmap/getBitmap方法加载图片解决数据错乱问题,能够在加载图片时添加loadding图片,加载失败时自动加载error图片

##示例 EasyImageLoaderSample.gif

##依赖 该库依赖以下常见库

compile 'com.jakewharton:disklrucache:2.0.2' //Google推荐的本地缓存库

compile 'com.google.code.gson:gson:2.3.1' //解析json库,用于封装的网络请求库自动解析json

##EasyImageLoader的使用

//根据图片url给imageView加载图片,自动本地缓存、内存缓存,注意Context需使用ApplicationContext,否则会导致内存泄露,下同
EasyImageLoader.getInstance(context).bindBitmap(imageUrl, imageView);

//重载方法加载图片并根据需求宽高压缩图片
EasyImageLoader.getInstance(context).bindBitmap(imageUrl, imageView,reqWidth,reqHeight);

//根据url自动从内存缓存、本地缓存、网络获取bitmap,并回调
EasyImageLoader.getInstance(context).getBitmap(imageUrl, new EasyImageLoader.BitmapCallback() {
        @Override
        public void onResponse(Bitmap bitmap) {
            //保存bitmap到本地
            saveBitmap(bitmap);
        }
    });

列如:

public class ImageItemViewHolder extends RecyclerView.ViewHolder{
    public ImageView imageView;
    private Context context;
    public ImageItemViewHolder(ViewGroup parent) {
        super(LayoutInflater.from(parent.getContext()).inflate(R.layout.itemview_image,parent,false));
        imageView =(ImageView)itemView.findViewById(R.id.itemview_img);
        context =parent.getContext().getApplicationContext();
    }
    //绑定数据
    public void setData(NetImage netImage){
            //加载图片
            EasyImageLoader.getInstance(context).bindBitmap(netImage.getImageUrl, imageView);
        }

}

详细用法请看demo

easyimageloader's People

Contributors

wenhuaijun avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.