我想更新状态并同时删除打开的文件。 This is my database
private void loadOrders() {
FirebaseRecyclerOptions<Orders> options = new FirebaseRecyclerOptions.Builder<Orders>()
.setQuery(requests,Orders.class)
.build();
adapter = new FirebaseRecyclerAdapter<Orders, AdminOrderViewHolder>(options) {
@Override
protected void onBindViewHolder(@NonNull AdminOrderViewHolder viewHolder, final int position, final Orders model) {
viewHolder.txtTableNo.setText("Table No:" + model.getTableNo());
viewHolder.txtOrderId.setText(adapter.getRef(position).getKey());
viewHolder.txtOrderStatus.setText(Common.convertCodeToStatus(model.getStatus()));
//New event button
viewHolder.btnEdit.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view){
showUpdateDialog(adapter.getRef(position).getKey(),adapter.getItem(position));
}
});
viewHolder.btnRemove.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view){
deleteOrder(adapter.getRef(position).getKey());
}
});
viewHolder.btnDetail.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view){
Intent orderDetail = new Intent(RestaurantViewCompleteOrder.this,OrderDetail.class);
Common.currentRequest = model;
orderDetail.putExtra("OrderId", adapter.getRef(position).getKey());
startActivity(orderDetail);
}
});
viewHolder.btnBill.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view){
showUpdatePayment(adapter.getRef(position).getKey(),status,open);
}
});
我想在这里更新和删除
private void showUpdatePayment(final String key,String status,String open) {
Query mUpdate =requests.child(key).child("status").child("open");
adapter.notifyDataSetChanged();
}
答案 0 :(得分:0)
HashMap<String, Object> dataMap = new HashMap<>();
dataMap.put("status", 1);
dataMap.put("open",FieldValue.delete());
更新dataMap
将更新状态并删除打开状态
希望这会有所帮助