Android Coil 3拦截器Interceptor计算单次请求耗时,Kotlin

Android Coil 3拦截器Interceptor计算单次请求耗时,Kotlin

Kotlin 复制代码
import android.content.Context
import android.util.Log
import coil3.intercept.Interceptor
import coil3.request.ImageResult

class MyInterceptor : Interceptor {
    companion object {
        const val TAG = "fly/MyInterceptor"
    }

    private var mCtx: Context? = null

    constructor(ctx: Context) {
        mCtx = ctx
    }

    override suspend fun intercept(chain: Interceptor.Chain): ImageResult {

        val t = System.currentTimeMillis()
        val result = chain.proceed()
        Log.d(TAG, "耗时:${System.currentTimeMillis() - t} ms, ${chain.request.data}")

        return result
    }
}
Kotlin 复制代码
        mImageLoader = ImageLoader.Builder(ctx)

            ...
            .components {
                ...

                add(MyInterceptor(ctx))
                
            }.build()

Android Coil3视频封面抽取封面帧存Disk缓存,Kotlin(2)-CSDN博客文章浏览阅读444次,点赞9次,收藏14次。本文介绍了基于Coil3的Android视频封面抽取优化方案,重点改进了磁盘缓存性能。通过将封面帧从PNG无损格式改为JPEG有损压缩(质量80),使缓存文件大小缩减至原先的1/10,显著提升了读写速度。核心实现包括:1)使用FFmpegMediaMetadataRetriever快速抽取视频首帧;2)自定义Bitmap压缩参数(Bitmap.CompressFormat.JPEG);3)采用缓冲流(BufferedOutputStream)处理磁盘缓存写入。该方案在保持图像质量的同时优化了I/O性能,适用https://blog.csdn.net/zhangphil/article/details/150494282

相关推荐
stevenzqzq1 小时前
android lambda回调
android
林北北的霸霸3 小时前
django初识与安装
android·mysql·adb
Java 码农5 小时前
MySQL EXPLAIN 详解与优化指南
android·mysql·adb
stevenzqzq9 小时前
Android Hilt 入门教程_传统写法和Hilt写法的比较
android
wuwu_q9 小时前
用通俗易懂方式,详细讲讲 Kotlin Flow 中的 map 操作符
android·开发语言·kotlin
_李小白10 小时前
【Android FrameWork】第五天:init加载RC文件
android
2501_9160074710 小时前
手机使用过的痕迹能查到吗?完整查询指南与步骤
android·ios·智能手机·小程序·uni-app·iphone·webview
黄毛火烧雪下11 小时前
React Native (RN)项目在web、Android和IOS上运行
android·前端·react native
下位子11 小时前
『OpenGL学习滤镜相机』- Day7: FBO(帧缓冲对象)
android·opengl
從南走到北11 小时前
JAVA国际版同城外卖跑腿团购到店跑腿多合一APP系统源码支持Android+IOS+H5
android·java·ios·微信小程序·小程序