1

I'm using firebase-ui to retrieve from firebase and I want to remove from displaying all the status that are equal to unlive I don't want to delete it from firebase database but only removed it from displaying on the recyclerview tried also doing the solution Cannot call this method while RecyclerView is computing a layout or scrolling when try remove item from recyclerview here still encountering the error. Please help I'm stuck here for days. Can't find any solution. Thanks

mAdapter = new FirebaseRecyclerAdapter<Hotels_Model, Adapter_HotelsHolder>(mOptions) {
            @Override
            protected void onBindViewHolder(Adapter_HotelsHolder holder,int position, Hotels_Model model) {

                String status = model.getStatus();
                if (status.equals("unlive")) {
                    mAdapter.notifyItemRemoved(holder.getAdapterPosition());
                    mAdapter.notifyItemRangeChanged(holder.getAdapterPosition(), getItemCount());
                }

        }

This is my error if I scroll to the position where the status is unlive

Cannot call this method while RecyclerView is computing a layout or scrolling android.support.v7.widget.RecyclerView
jo10
  • 111
  • 6

1 Answers1

0

So you can do it easily in that way:

mAdapter = new FirebaseRecyclerAdapter<Hotels_Model, Adapter_HotelsHolder>(mOptions) {
            @Override
            protected void onBindViewHolder(Adapter_HotelsHolder holder,int position, Hotels_Model model) {

                String status = model.getStatus();
                if (status.equals("unlive")) {
                  holder.yourRowView.setVisibility(View.GONE);
                }

        }

You don't need to remove your items from recyclerview.

Murat Güç
  • 377
  • 4
  • 9