0

Currently, I have this:

ItemTouchHelper.SimpleCallback simpleCallback = new ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT) {
            @Override
            public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
                return false;
            }

            @Override
            public void onSwiped(final RecyclerView.ViewHolder viewHolder, int direction) {
                final int position = viewHolder.getAdapterPosition(); //get position which is swipe

                if (direction == ItemTouchHelper.LEFT) {    //if swipe left
                    mAdapter.notifyItemRemoved(position);    //item removed from recylcerview
                    showSnackBar(findViewById(R.id.activity_main), getString(R.string.order_cancelled), Snackbar.LENGTH_INDEFINITE);
                } else if (direction == ItemTouchHelper.RIGHT) {
                    mAdapter.notifyItemRemoved(position);    //item removed from recylcerview
                    showSnackBar(findViewById(R.id.activity_main), getString(R.string.order_completed), Snackbar.LENGTH_INDEFINITE);
                }
            }
        };
        ItemTouchHelper helper = new ItemTouchHelper(simpleCallback);
        helper.attachToRecyclerView(list);

And the RecyclerView's adapter is a FirebaseRecyclerAdapter called mAdapter.

However, when I swipe left/right, I want to access the data in Firebase and add a value to that list (completed: true);

But I can't find a way to getRef() of the current position. What would be the best way to do so?

Ali Bdeir
  • 4,151
  • 10
  • 57
  • 117
  • That should be: `mAdapter.getRef(position)`. See https://stackoverflow.com/questions/32997219/how-to-get-obj-key-from-firebaselistadapter-on-item-click-firebaseui – Frank van Puffelen Jun 19 '17 at 14:12
  • @FrankvanPuffelen D'oh! I was trying to use `getItem(position).getRef();`! Thanks – Ali Bdeir Jun 19 '17 at 14:22

0 Answers0