Code Monkey home page Code Monkey logo

glideutils's Introduction

快速开始

  1. 在 project 的 build.gradle 文件中找到 allprojects{} 代码块添加

    allprojects {
        repositories {
            maven { url 'https://jitpack.io' } //增加jitPack Maven仓库
        }
    }
    
  2. 在 app 的 build.gradle 文件中找到 dependencies{} 代码块添加
    最新版本

    dependencies {
        implementation 'com.github.ztind:glideutils:latest.release'
    }
    

Glide4.x工具类封装

  1. 实现本地,网络图片的加载
  2. 图片预加载图片自定义
  3. 圆角,圆形图片裁剪变换
  4. 图片高斯模糊实现
  5. 图片占用大小获取
  6. 图片内存,磁盘缓存清除

UI

how to use api?

  /**
   * 加载网络图片
   */
  fun loadClick(view: View){
      GlideUtils.load(this, url, imageView)
  }
  /**
   * 加载默认属性设置的图片
   */
  fun loadErrorClick(view: View){
      GlideUtils.loadDefaultOptionsImage(this, url, imageView)
  }

  /**
   * 加载圆形图片
   */
  fun loadCircleClick(view: View){
      GlideUtils.loadCircleImage(this, url, imageView)
  }

  /**
   * 加载圆角图片
   */
  fun loadRoundClick(view: View){
      GlideUtils.loadRoundImage(this, url, imageView, 20)
  }

  /**
   * 加载4个角可以自定义的圆角图片
   */
  fun loadCustomerRoundClick(view: View){
      GlideUtils.loadRoundImage(this, url, imageView, 15f,30f,45f,80f)
  }

  /**
   * 模糊图片处理
   */
  fun loadBlurClick(view: View){
      GlideUtils.loadBlurImage(this, url, imageView, 15)
  }

  /**
   * 取消图片加载
   */
  fun clearClick(view: View){
      GlideUtils.clear(this, imageView)
  }

  /**
   * 清除图片缓存
   */
  fun clearCacheClick(view: View){
      GlideUtils.clearImageMemoryCache(this)
      GlideUtils.clearImageDiskCache(this)
  }

  /**
   * 获取图片缓存大小
   */
  fun cacheSizeClick(view: View){
      val size = GlideUtils.cacheSize(this)
      Toast.makeText(this,size, Toast.LENGTH_SHORT).show()
  }

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.