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

相关推荐
遇见你的那天13 分钟前
反编译查看源码
android
明飞198719 分钟前
isSuperclassOf 与is 与 ==的区别
kotlin
用户20187928316729 分钟前
SIGABRT+GL errors Native Crash 问题分析
android
Nathan2024061630 分钟前
Kotlin-Sealed与Open的使用
android·前端·面试
2501_9160137432 分钟前
iOS 26 设备文件管理实战指南,文件访问、沙盒导出、系统变更与 uni-app 项目适配
android·ios·小程序·uni-app·cocoa·iphone·webview
2501_9159214339 分钟前
前端用什么开发工具?常用前端开发工具推荐与不同阶段的选择指南
android·前端·ios·小程序·uni-app·iphone·webview
2501_916007471 小时前
iOS 26 能耗检测实战指南,升级后电池掉速是否正常 + KeyMob + Instruments 实时监控 + 优化策略
android·macos·ios·小程序·uni-app·cocoa·iphone
2501_916013741 小时前
苹果上架 App 全流程详解,iOS 应用发布步骤、ipa 文件上传工具、TestFlight 测试与 App Store 审核经验
android·ios·小程序·https·uni-app·iphone·webview
2501_915909061 小时前
HTML 开发工具有哪些?常用 HTML 开发工具推荐、学习路线与实战经验分享
android·小程序·https·uni-app·iphone·webview
wei8440678722 小时前
Android实现RecyclerView粘性头部效果,模拟微信账单列表的月份标题平移
android·java·微信·gitee