private void loadOrders(String phone) {
adapter = new FirebaseRecyclerAdapter<Request, OrderViewHolder>(
Request.class,
R.layout.order_layout,
OrderViewHolder.class,
requests.orderByChild("phone")
.equalTo(phone)
) {
@Override
protected void populateViewHolder(OrderViewHolder viewHolder, final Request model, final int position) {
viewHolder.txtOrderId.setText("Order ID: "+adapter.getRef(position).getKey());
viewHolder.txtOrderStatus.setText("Order Status: "+convertCodeToStatus(model.getStatus()));
viewHolder.txtOrderAddress.setText("Address: "+model.getAddress());
viewHolder.txtOrderPhone.setText("Phone Number: "+model.getPhone());
viewHolder.txtOrderComment.setText("Order Note: "+model.getComment());
viewHolder.txtOrderDate.setText("Order Date: "+Common.getDate(Long.parseLong(adapter.getRef(position).getKey())));
viewHolder.btn_delete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
alertdialog(position);
}
});
viewHolder.btnDetails.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent orderDetail = new Intent(OrderStatus.this,OrderDetail.class);
Common.currentRequest=model;
Intent intent = orderDetail.putExtra("OrderId", adapter.getRef(position).getKey());
startActivity(orderDetail);
}
});
if((Common.convertCodeToStatus(model.getStatus())).equals("Delivered"))
{
viewHolder.btndelivered.setVisibility(View.VISIBLE);
viewHolder.btn_delete.setVisibility(View.INVISIBLE);
}
}
};
recyclerView.setAdapter(adapter);
}
这是我用来从数据库中检索订单的代码,但它首先显示了旧订单。如何使它首先检索新订单?
如果我使用(((LinearLayoutManager)layoutManager).setReverseLayout(true);它只是倒置显示列表