Glide 不接受 GifDrawable 作为目标参数

Aha*_*kar 2 android android-glide

我正在尝试通过滑行找出 gif 的结尾。

这是我在网上找到的代码:

Glide.with(thisActivity).asGif().load(R.raw.logo_gif_motion_low).listener(object : RequestListener<GifDrawable> {
                override fun onLoadFailed(p0: GlideException?, p1: Any?, p2: Target<GifDrawable>, p3: Boolean): Boolean {

                }
                override  fun onResourceReady(p0: GifDrawable?, p1: Any?, p2: Target<GifDrawable>, p3: DataSource?, p4: Boolean): Boolean {

                    return false
                }
            }).into(splashscreen);
Run Code Online (Sandbox Code Playgroud)

问题是,它不接受GifDrawable目标

错误说:

在此处输入图片说明

Nil*_*hod 6

target: com.bumptech.glide.request.target.Target<GifDrawable>?
Run Code Online (Sandbox Code Playgroud)

代替

Target<GifDrawable>
Run Code Online (Sandbox Code Playgroud)

尝试这个

    Glide.with(this).asGif().load("").listener(object : RequestListener<GifDrawable> {
        override fun onResourceReady(resource: GifDrawable?, model: Any?, target: Target<GifDrawable>?, dataSource: DataSource?, isFirstResource: Boolean): Boolean {
            TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
        }

        override fun onLoadFailed(e: GlideException?, model: Any?, target: com.bumptech.glide.request.target.Target<GifDrawable>?, isFirstResource: Boolean): Boolean {
            TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
        }


    }).into(splashscreen)
Run Code Online (Sandbox Code Playgroud)