- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试从我的 firebase storage
加载图像并在我的 Cardview 中显示它,但它不起作用。我唯一得到的是:class com.bumptech.glide.load.engine.GlideException: Failed to load resource
和 Oh, Something went wrong!
(我自己的木材信息)。这是我的代码
XML
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<data>
<variable
name="product"
type="com.example.app.framework.datasource.models.product.Product" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.card.MaterialCardView
android:id="@+id/mcv_product_item"
android:layout_width="165dp"
android:layout_height="210dp"
android:layout_marginTop="12dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/iv_product_image"
android:layout_width="165dp"
android:layout_height="110dp"
android:contentDescription="TODO"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:loadImage="@{product.images[0]}" <-- Trying to load Image here
tools:src="@drawable/ic_calibrate" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/tv_product_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="12dp"
android:layout_marginEnd="8dp"
android:ellipsize="end"
android:maxLines="2"
android:text="@{product.name}"
app:layout_constraintEnd_toEndOf="@+id/iv_product_image"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="@+id/iv_product_image"
app:layout_constraintTop_toBottomOf="@+id/iv_product_image"
tools:text="Test Name" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/tv_product_price"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="12dp"
android:text="@{product.price}"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="@+id/tv_product_name" />
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
数据类
data class Product(
val name: String = "",
val price: Float = 0F,
val category: String = "",
val note: String = "",
val articelNumber: Int = 0,
val images: ArrayList<String> = arrayListOf(),
val description: ArrayList<ProductDescription> = arrayListOf(),
val technicalDescription: ArrayList<ProductDescription>? = arrayListOf(),
val hasAccessories: Boolean = false
)
data class ProductDescription(
val category: String = "",
val body: String = "",
)
滑动绑定(bind)适配器
@BindingAdapter("loadImage")
fun setImageFromUrl(view: ImageView, url: String?) {
if (!url.isNullOrEmpty()) {
GlideApp
.with(view)
.load(url)
.fitCenter()
.apply(RequestOptions.bitmapTransform(RoundedCorners(4)))
.into(view)
} else {
Timber.d("Oh, Something went wrong!")
}
}
GlideApp 模块
@GlideModule
class GlideAppModule : AppGlideModule() {
override fun registerComponents(context: Context, glide: Glide, registry: Registry) {
super.registerComponents(context, glide, registry)
registry.append(StorageReference::class.java, InputStream::class.java, FirebaseImageLoader.Factory())
}
}
依赖项
implementation "com.firebaseui:firebase-ui-storage:6.3.0"
implementation "com.github.bumptech.glide:glide:4.11.0"
kapt "com.github.bumptech.glide:compiler:4.11.0"
kapt "com.github.bumptech.glide:annotations:4.11.0"
堆栈跟踪(审查链接)
com.example.app W/Glide: Load failed for gs://censored.appspot.com/products/images/censored-SET_an238386.png with size [433x289]
class com.bumptech.glide.load.engine.GlideException: Failed to load resource
com.example.app D/BindingAdapterKt: Oh, Something went wrong!
我正在从
cloud firestore
获取我的产品对象并且我的卡片 View 中的所有内容都正确加载,除了相应的图像
GlideApp
不幸的是,没有提供额外的信息,
@BindingAdapter("loadImage")
fun setImageFromUrl(view: ImageView, url: String?) {
if (!url.isNullOrEmpty()) {
GlideApp
.with(view)
.load(url)
.addListener(
object : RequestListener<Drawable> {
override fun onLoadFailed(
e: GlideException?,
model: Any?,
target: Target<Drawable>?,
isFirstResource: Boolean,
): Boolean {
if (e != null) {
Timber.d("Exception ist ${e.stackTraceToString()}")
}
return false
}
override fun onResourceReady(
resource: Drawable?,
model: Any?,
target: Target<Drawable>?,
dataSource: DataSource?,
isFirstResource: Boolean,
): Boolean {
return false
}
}
)
.into(view)
} else {
Timber.d("Oh, Something went wrong!")
}
}
错误仍然存在
class com.bumptech.glide.load.engine.GlideException: Failed to load resource
.加载图像的权限也来自
firebase cloud firestore
最佳答案
!!临时解决方案!
所以我为我的问题找到了一个临时解决方案。而不是保存:
gs://censored.appspot.com/products/images/censored-SET_an238386.png
作为您对图像的引用(这是正确的方法,但在这里它不起作用),通过单击提取 https
https://firebasestorage.googleapis.com/v0/b/censored.appspot.com
/o/products%2Fimages%2Fcensored-Leihgeraet_an326331.png?alt=media&token=censored-c92b-4153-a3f3-censored
保存
https link
在您的
cloud-firestore
数据库,然后从那里获取它。比单独下载url链接的好处是,上述方法要快得多。
关于安卓,Firestore : GlideException: Failed to load resource,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64206164/
我正在尝试为我的 Firestore 设置一个数据库,但是我尝试重新安装 pod 和许多其他东西,但我仍然无法让它工作,因为它显示了这个错误: Type 'Firestore' has no memb
我需要更改我的项目 ID,因为要验证的 Firebase 身份验证链接在链接上显示了项目 ID,并且由于品牌 reshape ,项目名称已更改。根据我发现的信息,更改项目 ID 似乎不太可能。我正在考
快速提问。长话短说,我在我的谷歌云功能日志中收到此错误: Firestore (4.10.1):无法到达 Firestore 后端。 这是我的函数文件中的代码: // pull in firebas
我正在从事 Angular 6 项目。这是我使用 --prod 构建时遇到的错误标记、主持和运行。我已经坐了很长时间了。最初认为这可能是 firestore 包的问题,我等了。但是现在更新到fir
我正在开发一个 React 项目,这是我的第一个 React 项目。此代码部署成功。但在使用 postman 测试时出现一些错误。我“发布”“createScream”函数的 URL 并发送它。然后我
我有一个包含两个集合的 Firestore 数据库:用户和锦标赛。用户具有“参与者”角色和“管理员”角色,并在用户文档中由“isParticipant”和“isAdmin” bool 值指示: /us
Firebase 数据库根据他们的文档提供了 10 MB 的离线数据库缓存限制,但没有提到 的离线数据限制。 Firestore 数据库。 Firestore 的离线数据保存限制是多少? 最佳答案 根
我正在尝试评估 string在 Firestore 安全规则 基于 matches正则表达式功能 我的代码是 username.matches('^(?!\.)(?!_)(?!.*\.$)(?!.*?
是否可以在 Firestore 中定义具有唯一约束的索引?如果没有,如何在文档字段上强制执行唯一性(不使用文档 ID)? 最佳答案 是的,这可以通过结合使用两个集合、Firestore 规则和批量写入
我正在学习 GCP,在他们的 Firestore 中,我对 Admin.firestore 和 Firebase.firestore 的区别感到困惑。 这是管理员的代码: const admin =
使用带有自定义声明的 firestore 在线安全模拟会导致错误,但它在部署时可以完美运行(同时实际处理真实请求)。错误是: Error: simulator.rules line [5], colu
所以,我知道有一些类似命名的问题,但这是不一样的。 我很想知道是否有人可以解释缺少 increment 的原因。哨兵,类似于delete一。 据我所知,字段删除与文档更新没有什么不同。意思是,我只能
我想创建两个带有分页选项的查询。在第一个记录中,我想获取前十条记录,在第二个记录中,我想获取其他所有记录: .startAt(0) .limit(10) .startAt(9) .limit(null
我正在努力为我的应用寻找最佳架构。我应该使用顶级集合、子集合、数组等吗? 设置: 我的应用程序将有许多用户将参与的测验。 每个测验都会有多个问题。 每个问题都有多个答案,只能选择一个。 每个用户只能回
我正在努力为我的应用寻找最佳架构。我应该使用顶级集合、子集合、数组等吗? 设置: 我的应用程序将有许多用户将参与的测验。 每个测验都会有多个问题。 每个问题都有多个答案,只能选择一个。 每个用户只能回
我无法在任何地方找到我可以在一个Collection中获得的文档数量的限制。假设我有1,000,000,000个文档...那有可能吗?如果我想把它们全部都拿走,实际上会给我十亿吗? 最佳答案 可以存储
假设我有一个集合 mycollection有 1,000,000 条记录。 此查询将返回多少条记录? const query = firestore.collection('mycollection'
这是错误消息:@firebase/firestore: Firestore (4.12.1): Could not reach Firestore backend 我正在构建一个网络应用程序,它今天运
我在编写和测试我的 Firestore 规则时遇到了一个奇怪的问题。这是我想要实现的目标: 当应用程序启动时,用户会匿名登录。这用户开始新游戏。 我创建了一个基本上只包含时间戳的“ session ”
我是云函数的新手。我有一些困惑。 admin.firestore 和functions.firestore? admin.database 是实时数据库吗? 因此,如果云函数基本上是用 JavaScr
我是一名优秀的程序员,十分优秀!