Android Glide不接受可绘制作为目标参数

Android Glide不接受可绘制作为目标参数,android,android-glide,Android,Android Glide,我想用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&g

我想用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);
Glide.with(thisActivity).asGif().load(R.raw.logo\u gif\u motion\u low).侦听器(对象:RequestListener{
重写fun onLoadFailed(p0:GlideException?,p1:Any?,p2:Target,p3:Boolean):布尔值{
}
重写fun onResourceReady(p0:GifDrawable?,p1:Any?,p2:Target,p3:DataSource?,p4:Boolean):布尔值{
返回错误
}
}).进入(溅屏);
问题是,它不接受Target中的giftravable

错误是说:


在build.gradle文件中添加以下内容

包括Glide的注释处理器需要依赖Glide的注释和注释处理器:

compile 'com.github.bumptech.glide:annotations:4.8.0'
repositories {
 mavenCentral()
 }

dependencies {
 annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'
}
在Glide的注释处理器上添加依赖项:

compile 'com.github.bumptech.glide:annotations:4.8.0'
repositories {
 mavenCentral()
 }

dependencies {
 annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'
}
使用

target:com.bumptech.glide.request.target.target?
而不是

Target<GifDrawable>
目标
试试这个

    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)
Glide.with(this).asGif().load(“”).listener(对象:RequestListener{
覆盖onResourceReady(资源:GifDrawable?、模型:Any?、目标:target?、数据源:dataSource?、isFirstResource:Boolean):布尔{
TODO(“未实现”)//要更改已创建函数的主体,请使用文件|设置|文件模板。
}
重写fun onLoadFailed(e:GlideException?,型号:Any?,目标:com.bumptech.glide.request.target.target?,isFirstResource:Boolean):布尔{
TODO(“未实现”)//要更改已创建函数的主体,请使用文件|设置|文件模板。
}
}).进入(溅屏)

将最新的
Glide
依赖项导入成绩文件

implementation 'com.github.bumptech.glide:glide:4.8.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'
然后使用以下解决方案之一:

Glide.with(thisActivity)
        .asGif()
        .load(R.raw.logo_gif_motion_low)
        .listener(object : RequestListener<GifDrawable> {
            override fun onResourceReady(resource: GifDrawable?, model: Any?, target: Target<GifDrawable>?, dataSource: DataSource?, isFirstResource: Boolean): Boolean {
                // TODO: Process your gif drawable here
                return false
            }

            override fun onLoadFailed(e: GlideException?, model: Any?, target: Target<GifDrawable>?, isFirstResource: Boolean): Boolean {
                return false
            }
        }).into(splashscreen)
Glide.with(此活动)
.asGif()
.load(R.raw.logo\u gif\u motion\u low)
.listener(对象:RequestListener{
覆盖onResourceReady(资源:GifDrawable?、模型:Any?、目标:target?、数据源:dataSource?、isFirstResource:Boolean):布尔{
//TODO:在此处处理可绘制的gif
返回错误
}
重写fun onLoadFailed(e:GlideException?,model:Any?,target:target?,isFirstResource:Boolean):布尔{
返回错误
}
}).进入(溅屏)

Glide.with(此活动)
.load(R.raw.logo\u gif\u motion\u low)
.listener(对象:RequestListener{
覆盖onResourceReady(资源:可绘制?、模型:任意?、目标:目标?、数据源:数据源?、isFirstResource:Boolean):布尔{
val giftravable=资源是否为giftravable?
有天赋?让我来{
//TODO:在此处处理可绘制的gif
}
返回错误
}
重写fun onLoadFailed(e:GlideException?,model:Any?,target:target?,isFirstResource:Boolean):布尔{
返回错误
}
})
.进入(溅屏)

您使用的是GLide 3x还是4x?我得到了以下编译错误:
类型不匹配:推断的类型为但为RequestListener?是否需要
知道吗?我们如何在位图变量(如位图位图=滑动输出)中获得输出,然后将此位图添加到arraylist。