package com.prank.funnypranksounds.ui.callback;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.ItemTouchHelper;
import androidx.recyclerview.widget.RecyclerView;

public class AudioItemCallback extends ItemTouchHelper.SimpleCallback {

    private final OnItemSwipeListener listener;

    public AudioItemCallback(OnItemSwipeListener listener) {
        super(0, ItemTouchHelper.LEFT);
        this.listener = listener;
    }

    @Override
    public boolean onMove(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder, @NonNull RecyclerView.ViewHolder target) {
        return false;
    }

    @Override
    public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) {
        int position = viewHolder.getAdapterPosition();
        if (listener != null) {
            listener.onItemSwiped(position);
        }
    }

    public interface OnItemSwipeListener {
        void onItemSwiped(int position);
    }
}

