Giter Club home page Giter Club logo

glideutils's Introduction

GlideUtils

Glide图片加载库的封装类 占位符 不会覆盖CircleImageView,支持直接加载静态图、动态图到View,或者获取Bitmap,Drawable。加载普通图片可以加参数设置占位符和错误图

普通加载图片(支持CircleImageView):


GlideUtils.loadImage(url, imageview);

//GlideUtils.loadImage(this, url, imageview, null);



需要添加占位图和错误图在后面加:

GlideUtils.loadImage(this, url, imageview, null, R.drawable.default_article_image, R.drawable.default_article_image);

加载Gif图片,带监听

GlideUtils.loadImageGif(mImageUrl, mImageView, new GlideUtils.ImageLoadListener<String, GifDrawable>() {
                @Override
                public void onLoadingComplete(String uri, ImageView view, GifDrawable resource) {
                    progressBar.setVisibility(View.GONE);

                }

                @Override
                public void onLoadingError(String source, Exception e) {
                    LogUtil.e("im查看图片加载失败:"+e);
                    mEntry.setIsDownload(false);
                    progressBar.setVisibility(View.GONE);
                    mFailLayout.setVisibility(View.VISIBLE);
                }
            });

不带监听就设置把监听属性设置我为null;

加载静态图片

GlideUtils.loadImage(this, mImageUrl, mImageView, new GlideUtils.ImageLoadListener<String, GlideDrawable>() {
                        @Override
                        public void onLoadingComplete(String uri, ImageView view, GlideDrawable resource) {
                            progressBar.setVisibility(View.GONE);
                            mEntry.setIsDownload(true);
                        }

                        @Override
                        public void onLoadingError(String source, Exception e) {
                            LogUtil.e("im查看图片加载失败:" +e + "连接:" + source);
                            mEntry.setIsDownload(false);
                            progressBar.setVisibility(View.GONE);
                            mFailLayout.setVisibility(View.VISIBLE);
                        }
                    });

重要一点,在多图片的界面destory之后,在onDestory回调方法调用

   @Override
    protected void onDestroy() {
        super.onDestroy();
        GlideUtils.clearMemory(this);
        System.gc();
    }

其他等等

glideutils's People

Contributors

tpnet avatar

Watchers

 avatar  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.