Glide 不接受 GifDrawable 作为目标参数
Glide does not accepting GifDrawable as target parameter
我正在尝试用滑行找出 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);
问题是,它不接受 Target.
中的 GifDrawable
错误说:
在您的 build.gradle 文件中添加以下内容
包含Glide的注解处理器需要依赖Glide的注解和注解处理器:
compile 'com.github.bumptech.glide:annotations:4.8.0'
添加对 Glide 注释处理器的依赖:
repositories {
mavenCentral()
}
dependencies {
annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'
}
使用
target: com.bumptech.glide.request.target.Target<GifDrawable>?
而不是
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
依赖项导入成绩文件。
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(thisActivity)
.load(R.raw.logo_gif_motion_low)
.listener(object : RequestListener<Drawable> {
override fun onResourceReady(resource: Drawable?, model: Any?, target: Target<Drawable>?, dataSource: DataSource?, isFirstResource: Boolean): Boolean {
val gifDrawable = resource as GifDrawable?
gifDrawable?.let {
// TODO: Process your gif drawable here
}
return false
}
override fun onLoadFailed(e: GlideException?, model: Any?, target: Target<Drawable>?, isFirstResource: Boolean): Boolean {
return false
}
})
.into(splashscreen)
我正在尝试用滑行找出 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);
问题是,它不接受 Target.
中的 GifDrawable错误说:
在您的 build.gradle 文件中添加以下内容
包含Glide的注解处理器需要依赖Glide的注解和注解处理器:
compile 'com.github.bumptech.glide:annotations:4.8.0'
添加对 Glide 注释处理器的依赖:
repositories {
mavenCentral()
}
dependencies {
annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'
}
使用
target: com.bumptech.glide.request.target.Target<GifDrawable>?
而不是
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
依赖项导入成绩文件。
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(thisActivity)
.load(R.raw.logo_gif_motion_low)
.listener(object : RequestListener<Drawable> {
override fun onResourceReady(resource: Drawable?, model: Any?, target: Target<Drawable>?, dataSource: DataSource?, isFirstResource: Boolean): Boolean {
val gifDrawable = resource as GifDrawable?
gifDrawable?.let {
// TODO: Process your gif drawable here
}
return false
}
override fun onLoadFailed(e: GlideException?, model: Any?, target: Target<Drawable>?, isFirstResource: Boolean): Boolean {
return false
}
})
.into(splashscreen)