请帮我解决一些小问题,我相信你能做到:D
我正在尝试在带有字段“case_number”的 firestore 文档“user_cases_information”上设置一个字段
首先我声明这个全局变量
private String case_number_consecutive = new String("");
在.setOnClickListener
我有这个:(从其他文件中读取旧的连续或案例编号)
if (service_type.equals("support")){
DocumentReference docRef = firestore_popup.collection("param_data_app").document("support_case_numbers");
docRef.get().addOnCompleteListener(new OnCompleteListener<DocumentSnapshot>() {
@Override
public void onComplete(@NonNull Task<DocumentSnapshot> task) {
if (task.isSuccessful()) {
DocumentSnapshot document = task.getResult();
String consecutive = document.get("consecutive").toString();
if (consecutive.equals(null)) {
int random = new Random().nextInt(117) + 4;
case_number_consecutive = "IOC-09"+random;
} else {
case_number_consecutive = consecutive; UpdateCaseNumbersConsecutive("support");
}
} else {
int random = new Random().nextInt(117) + 4;
case_number_consecutive = "IOC-09"+random;
}
}
});
}
Map<String, Object> user_cases_information = new HashMap<>();
user_cases_information.put("case_number", case_number_consecutive);
... (then i use a firestore reference to put the new case number)
它假设当我检查 firestore 时,正是我设置“user_cases_information”文档的文档,我应该看到数字或新的 case_number,但我总是得到一个参考,连续的字段总是null=null
为什么我得到这个空值?我用了一个 Toast 并把它放在这之前:
Toast.makeText(...."Value: "+case_number_consecutive
Map<String, Object> user_cases_information = new HashMap<>();
user_cases_information.put("case_number", case_number_consecutive);
它显示了null上述函数中的值或数据正在丢失
我怎样才能解决这个问题???万分感谢。
元芳怎么了
红糖糍粑
相关分类