我有一个包含产品列表的 Firebase 数据库,每个产品都有一个购物车元素的子列表。我只想接收包含具有正确用户 ID 的购物车元素的产品元素。
我正在使用 FirebaseUI 列表适配器。我得到了产品列表的所有元素,但我只想显示包含用户 ID 的产品。
我可以从 ListAdapter 中删除视图吗?或者可以通过一些查询排序?
欢迎所有解决问题的想法!
编辑
这是产品类的一部分。
public class Product implements Serializable{
private boolean active;
private ArrayList<Cart> carts;
private String description;
private String details;
private String ean;
private String id;
private String image;
private String name;
private Float price;
private ArrayList<ProductPack> productpacks;
private int stock;
private int stockavailable;
private Float tax;
private String users;
}
firebase 中存储的部分数据:
products
-KG8O_5iHKWGCBytLtn0
active: true
carts
0
amount: 11
userID: "google:116879660852602200588"
1
amount: 12
userID: "google:116879660852602200589"
description: ""
details: ""
ean: ""
id: "-KG8O_5iHKWGCBytLtn0"
image: "iVBORw0KGgoAAAANSUhEUgAABqsAAAPACAIAAAAt5NQJAAA..."
name: "test"
price: 1
stock: 0
stockavailable: 0
tax: 1
users: ""
-KG9-r5ATr1BokkVzuYt
active: true
carts
0
amount: 11
userID: "google:116879660852602200588"
1
amount: 12
userID: "google:116879660852602200589"
description: ""
details: ""
ean: ""
id: "-KG9-r5ATr1BokkVzuYt"
image: "iVBORw0KGgoAAAANSUhEUgAABqsAAAPACAIAAAAt5NQJAAA..."
name: "test"
price: 1
stock: 0
stockavailable: 0
tax: 0.25
users: ""