我正在尝试获取存储在Firebase存储中的图像URI,以便使用其他方法处理它.我正在使用以下内容:
FirebaseStorage storage = FirebaseStorage.getInstance();
StorageReference storageRef = storage.getReferenceFromUrl(this.getString(R.string.storage_path));
Uri uri = storageRef.child("groups/pizza.png").getDownloadUrl().getResult();
Run Code Online (Sandbox Code Playgroud)
并收到错误"java.lang.IllegalStateException:任务尚未完成"
我正在使用firebase存储来为我的Android应用程序上的用户存储和加载图像.在使用之前,必须对所有用户进行身份验证.有时,某些用户个人资料图像未显示并抛出"403 Forbidden"错误.那些图像在显示之前,我不知道他们为什么停止工作.我在我的firebase存储上使用以下规则:
service firebase.storage {
match /b/<storage_address>.appspot.com/o {
match /{allPaths=**} {
allow read: if request.auth != null;
allow write: if request.auth != null;
}
}
}
Run Code Online (Sandbox Code Playgroud)
如果我改变读取规则, allow read;所有图像都正常工作.这是我的显示方法:
Picasso.Builder builder = new Picasso.Builder(this);
builder.listener(new Picasso.Listener()
{
@Override
public void onImageLoadFailed(Picasso picasso, Uri uri, Exception exception)
{
exception.printStackTrace();
}
});
builder.build().load(URL).into(imgView);
Run Code Online (Sandbox Code Playgroud)
图像URL看起来像这样:
https://firebasestorage.googleapis.com/v0/b/<storage_address>.appspot.com/o/images%2Fprofile%2Fphoto%2F36805?alt=media&token=e62ec151-3aaf-4e5c-aefb-1b3c93828684
Run Code Online (Sandbox Code Playgroud)
它可能与令牌有关吗?
我Linearlayout在内有一个ConstraintLayout具有以下属性的视图():
android:id="@+id/myView"
app:layout_constraintTop_toBottomOf="@+id/anotherView"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
Run Code Online (Sandbox Code Playgroud)
在某些情况下,我希望myView通过简单地删除右侧约束来向左对齐。但是我不能这样做。
我尝试使用以下内容,简单地复制并应用约束参数:
ConstraintLayout.LayoutParams layoutParams = new ConstraintLayout.LayoutParams(holder.myView.getLayoutParams());
holder.myView.setLayoutParams(layoutParams);
Run Code Online (Sandbox Code Playgroud)
但是layoutParams总是收到一个空的参数集,并将视图发送到左上角。也许是因为我在a内使用了它recyclerView?
它在内部的外观如何recyclerView:
public void onBindViewHolder(final RecyclerView.ViewHolder basicHolder, int position) {
ProfileAdapter.UserInfoViewHolder holder = (ProfileAdapter.UserInfoViewHolder) basicHolder;
ConstraintLayout.LayoutParams layoutParams = new ConstraintLayout.LayoutParams(holder.myView.getLayoutParams(??));
holder.myView.setLayoutParams(layoutParams);
}
Run Code Online (Sandbox Code Playgroud)