当前位置: 首页 > news >正文

深圳市年检在哪个网站做wordpress模特主题

深圳市年检在哪个网站做,wordpress模特主题,网站设计手机型,马达加工东莞网站建设文章目录 Android 优雅封装Glide核心思想定义策略接口定义图片选项实现Glide策略图片管理类使用 Android 优雅封装Glide 核心思想 使用策略模式实现不同图片加载框架的切换#xff0c;使用建造者设计模式处理不同参数#xff0c;最后通过 ImageLoader 进行管理。 定义策略… 文章目录 Android 优雅封装Glide核心思想定义策略接口定义图片选项实现Glide策略图片管理类使用 Android 优雅封装Glide 核心思想 使用策略模式实现不同图片加载框架的切换使用建造者设计模式处理不同参数最后通过 ImageLoader 进行管理。 定义策略接口 interface ILoaderStrategy {fun loadImage(configs: ImageOptions)fun clearDiskCache(context: Context)fun clearMemoryCache(context: Context)fun clearAll(context: Context) {clearDiskCache(context)clearMemoryCache(context)}fun clear(imageView: ImageView) }定义图片选项 class ImageOptions private constructor() {var targetObj: Any? null // 生命周期对象var targetView: ImageView? null // 目标ImageViewvar resource: Any? null // 加载资源var width -1 // 指定宽度var height -1 // 指定高度var isDiskCache true // 磁盘缓存var isMemoryCache true // 内存缓存DrawableResvar placeholder: Int -1 // 占位图资源DrawableResvar error: Int -1 // 失败图资源var listener: Listener? nullcompanion object {fun create(): ImageOptions {return ImageOptions()}}fun with(targetObj: Any): ImageOptions {this.targetObj targetObjreturn this}fun loadResource(resource: Any): ImageOptions {this.resource resourcereturn this}fun size(size: Int): ImageOptions {return size(width, height)}fun size(width: Int, height: Int): ImageOptions {this.width widththis.height heightreturn this}fun placeholder(DrawableRes placeholder: Int): ImageOptions {this.placeholder placeholderreturn this}fun error(DrawableRes error: Int): ImageOptions {this.error errorreturn this}fun setDiskCache(isCache: Boolean): ImageOptions {isDiskCache isCachereturn this}fun setMemoryCache(isCache: Boolean): ImageOptions {isMemoryCache isCachereturn this}fun setListener(listener: Listener): ImageOptions {this.listener listenerreturn this}fun into(imageView: ImageView) {this.targetView imageViewImageLoader.loadOptions(this)}interface Listener {fun onSuccess(model: Any?)fun onFail(model: Any?)} }实现Glide策略 class GlideLoader : ILoaderStrategy {private lateinit var requestManager: RequestManageroverride fun loadImage(options: ImageOptions) {requestManager getRequestManager(options.targetObj)var requestBuilder: RequestBuilderDrawable? nulloptions.resource?.let {requestBuilder generateRequestBuilder(it)}requestBuilder?.let {if (options.placeholder ! -1) {it.placeholder(options.placeholder)}if (options.error ! -1) {it.error(options.error)}if (options.width ! -1 || options.height ! -1) {it.override(options.width, options.height)}it.skipMemoryCache(options.isMemoryCache)it.diskCacheStrategy(if (options.isDiskCache) DiskCacheStrategy.AUTOMATIC else DiskCacheStrategy.NONE)options.listener?.let { listener -it.addListener(object : RequestListenerDrawable {override fun onLoadFailed(e: GlideException?,model: Any?,target: TargetDrawable?,isFirstResource: Boolean): Boolean {listener.onFail(model)return false}override fun onResourceReady(resource: Drawable?,model: Any?,target: TargetDrawable?,dataSource: DataSource?,isFirstResource: Boolean): Boolean {listener.onSuccess(model)return false}})}if (options.targetView null) {throw IllegalArgumentException(targetView cannot be null);}it.into(options.targetView!!)}}private fun getRequestManager(targetObj: Any?): RequestManager {return if (targetObj is FragmentActivity) {Glide.with(targetObj)} else if (targetObj is Context) {Glide.with(targetObj)} else if (targetObj is View) {Glide.with(targetObj)} else if (targetObj is Fragment) {Glide.with(targetObj)} else {throw IllegalArgumentException(You cannot start a load on a null Context);}}private fun generateRequestBuilder(res: Any): RequestBuilderDrawable? {return if (res is String) {requestManager.load(res)} else if (res is File) {requestManager.load(res)} else {return null}}override fun clearDiskCache(context: Context) {thread {Glide.get(context).clearDiskCache()}}override fun clearMemoryCache(context: Context) {Glide.get(context).clearMemory()}override fun clear(imageView: ImageView) {Glide.with(imageView.context).clear(imageView)} }图片管理类 object ImageLoader {private var imageLoader: ILoaderStrategy? nullfun setImageLoader(imageLoader: ILoaderStrategy) {this.imageLoader imageLoader}fun with(targetObj: Any): ImageOptions {val options ImageOptions.create()options.with(targetObj)return options}fun loadOptions(options: ImageOptions) {imageLoader!!.loadImage(options)}fun clearDiskCache(context: Context){imageLoader!!.clearDiskCache(context)}fun clearMemoryCache(context: Context){imageLoader!!.clearMemoryCache(context)}fun clearAll(context:Context){imageLoader!!.clearAll(context)}fun clear(imageView: ImageView){imageLoader!!.clear(imageView)}}使用 override fun onCreate(savedInstanceState: Bundle?) {super.onCreate(savedInstanceState)setContentView(R.layout.activity_image_loader)imageView0 findViewById(R.id.imageView0)imageView1 findViewById(R.id.imageView1)imageView2 findViewById(R.id.imageView2)ImageLoader.setImageLoader(GlideLoader())val url https://i-blog.csdnimg.cn/blog_migrate/de6e3262387d57977e53af596a87f582.pngImageLoader.with(this).loadResource(url).size(100).placeholder(R.mipmap.ic_launcher).error(R.mipmap.ic_launcher).into(imageView1)ImageLoader.with(this).loadResource(File(cacheDir, aaa.png)).placeholder(R.mipmap.ic_launcher).error(R.mipmap.ic_launcher).into(imageView2) } ImageLoader.clear(imageView1) ImageLoader.clearAll(this) ImageLoader.clearMemoryCache(this) ImageLoader.clearDiskCache(this)
http://www.hkea.cn/news/14429849/

相关文章:

  • 什么网站可以做miR的差异表达图旅游网站建设报告
  • 网站建设地图怎么设置ps怎么做网站特效
  • 织梦上网站次导航怎么做百度做的网站后台怎么更新
  • 做地方网站数据哪里来运营工资一般多少
  • 互联网怎么做网站wordpress人才市场
  • 做任务网站建设2345网址导航手机版下载
  • 做网站的工资高吗?邢台推广平台
  • 宁波商城网站建设网站内链检测工具
  • 公司网站的制作公司双语网站建设网站
  • 学校网站建设需求文档创建一个自己的公司翻译
  • 分类目录网站平台海原县住房和城乡建设局网站
  • 做网站自己买服务器吗wordpress 显示 链接深度
  • 视频网站用什么做的青岛建设系统一体化网站
  • 贵阳双龙区建设局网站漳州招商局规划建设局网站
  • 网站建设一般要提供什么内容宝安logo设计
  • 潍坊企业免费建站网站跳出率
  • 怎么做电影网站页面的注册公司最好用老年人
  • 网站与微信内容建设与运维总结wordpress会员登录界面美化
  • 想学编程做网站鲜花网站建设的主要工作流程
  • 买空间去哪个网站搞笑视频网站建设策划书
  • 临沂网站建设昂牛网络后台管理网页界面设计
  • 房产网站建设整体架构wordpress秀恩爱
  • 网站建设项目验收报告书网站搭建运营
  • 花木公司网站源码域名后有个wordpress
  • 网站建设实训小结培训机构退费法律规定
  • 做网站要多少人机械 网站源码
  • 扶贫网站建设的意义做网站之前要安装什么
  • 翻译做网站怎样维护公司网站
  • python免费自学网站深圳网站设计必选成都柚米科技09做
  • 网站优化推广费用微信公众号电商网站开发