【发布时间】:2019-08-16 17:07:12
【问题描述】:
我在 Firestore 中有这个数据结构,如图所示。
我正在使用FirestoreRecyclerOptions 来显示用户的地址。我将地址存储为 POJO (UserAddressModel.java),我不知道以这种方式存储它是否是最佳做法,但我是如何做到的。
用户信息模型.java
public class UserInformationsModel {
private String email, username, name ;
private UserAddressModel userAddress;
private String phoneNumber;
private String photo;
private String photoUrl;
public UserInformationsModel() {
}
}
UserAddressModel.java
public class UserAddressModel {
private String fullName, streetAddressOne, streetAddressTwo, city, state, country;
private String zipCode;
public UserAddressModel() {
}
public UserAddressModel( String streetAddressOne, String city, String state, String country, String zipCode) {
this.streetAddressOne = streetAddressOne;
this.city = city;
this.state = state;
this.country = country;
this.zipCode = zipCode;
}
public String getFullName() {
return fullName;
}
public String getStreetAddressOne() {
return streetAddressOne;
}
public String getStreetAddressTwo() {
return streetAddressTwo;
}
public String getCity() {
return city;
}
public String getState() {
return state;
}
public String getCountry() {
return country;
}
public String getZipCode() {
return zipCode;
}
我已经创建了扩展 FirestoreRecyclerAdapter 及其布局的 AdapterAddress 类。
我的问题是如何在我的 recyclerview 中显示 address1 和 address2 ?
因为我注意到setQuery 方法需要查询,但我不知道如何获取地址
Query query = coll_ref.orderBy("?????");
FirestoreRecyclerOptions<UserAddressModel> options = new FirestoreRecyclerOptions.Builder<UserAddressModel>()
.setQuery(query, UserAddressModel.class)
.build();
adapterAddress = new AdapterAddress(options);
【问题讨论】:
标签: java android firebase google-cloud-firestore firebaseui