'I want to best hide a CardView Order request from layout

I'm using setValue(View.INVISIBLE with several references hosted in firebase:

holder.txtOrderId.setText(adapter.getRef(position).getKey());
                holder.txtOrderStatus.setText(Common.convertCodeToStatus(model.getStatus()));
                holder.txtOrderAddress.setText(model.getAddress());
                holder.txtOrderPhone.setText(model.getPhone());       holder.txtOrderDate.setText(Common.getDate(Long.parseLong(adapter.getRef(position).getKey())));
                holder.txtPaymentMethod.setText(model.getPaymentMethod());
                holder.txtPaymentState.setText(model.getPaymentState());
                holder.txtName.setText(model.getName());
                holder.txtTotal.setText(model.getTotal());

i want it to just disappear without deleting from firebase, disappear in this layout, it disappears but it disappears for whoever makes the request too (dont want this), and be able to eliminate it in another layout I have(its works) and crashes next time you go to orders in both layouts.

holder.btnHide.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        hideOrder(adapter.getRef(position).getKey());
                    }
                });

After:hideOrder

private void hideOrder(final String key) {
        AlertDialog.Builder alertDialog=new AlertDialog.Builder(OrderStatus.this);
        alertDialog.setTitle("Olá, "+Common.currentUser.getName());
        alertDialog.setMessage("O pedido foi entregue?");
        alertDialog.setCancelable(false);
        alertDialog.setPositiveButton("Sim", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {

                dialog.dismiss();
                reuests.child(key).setValue(View.INVISIBLE);
                adapter.notifyDataSetChanged();
                Toast.makeText(OrderStatus.this, "Pedido finalizado com sucesso!", Toast.LENGTH_SHORT).show();
            }
        });
        alertDialog.setNegativeButton("Não", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {

                dialog.dismiss();
                Toast.makeText(OrderStatus.this, "Cancelado", Toast.LENGTH_SHORT).show();
            }
        });
        alertDialog.setIcon(R.mipmap.picture);
        alertDialog.show();
    }

I don't know how to do it, can anyone help me?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source