我正在使用滑行4.3.1
我想打电话给签名方法,但不会出现。
我的代码
Glide.with(context).load(context.getFilesDir().getPath() + "/" + imgName).into(imgView);
我想做这个
Glide.with(context).load(context.getFilesDir().getPath() + "/" + imgName).signature(new StringSignature("someVersion")).into(imgView);
我正在使用android studio,当我把鼠标放在签名方法上时,我看到了消息:无法解析方法'signature(StringSignature)'。
我的构建gradle:
dependencies {
compile 'com.github.bumptech.glide:glide:4.3.1'
}
在glide v4中你应该使用ObjectKey
(用于文件和网址)或MediaStoreSignature
(用于媒体内容)而不是StringSignature
根据我的理解,你为Glide编写了扩展类,但你使用的是基本的Glide类。你应该使用Glide generated API
GlideApp.with(fragment)
.load(myUrl)
.placeholder(R.drawable.placeholder)
.signature(new StringSignature("someVersion")) // your extension
.into(imageView);
你需要把它放在你的应用程序gradle中
实现'com.github.bumptech.glide:glide:4.9.0'
annotationProcessor'com.github.bumptech.glide:compiler:4.9.0'
在你的代码中你必须把它
GlideApp.with(context)
.load(file.getAbsolutePath())
.signature(new ObjectKey(file.getPath() + file.lastModified()))
.fitCenter()
// caches only the final image, after reducing the resolution
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
.into(view);