// Path: app/src/main/java/com/teocci/ytinbg/interfaces/ItemTouchListener.java
// public interface ItemTouchListener
// {
//     /**
//      * Called when an item has been dragged far enough to trigger a move. This is called every time
//      * an item is shifted, and <strong>not</strong> at the end of a "drop" event.<br/>
//      * <br/>
//      * Implementations should call {@link RecyclerView.Adapter#notifyItemMoved(int, int)} after
//      * adjusting the underlying data to reflect this move.
//      *
//      * @param fromPosition The start position of the moved item.
//      * @param toPosition   Then resolved position of the moved item.
//      * @return True if the item was moved to the new adapter position.
//      * @see RecyclerView.ViewHolder#getAdapterPosition()
//      */
//     boolean onItemMove(int fromPosition, int toPosition);
// 
// 
//     /**
//      * Called when an item has been dismissed by a swipe.<br/>
//      * <br/>
//      * Implementations should call {@link RecyclerView.Adapter#notifyItemRemoved(int)} after
//      * adjusting the underlying data to reflect this removal.
//      *
//      * @param position The position of the item dismissed.
//      * @see RecyclerView.ViewHolder#getAdapterPosition()
//      */
//     void onItemDismiss(int position);
// }
// 
// Path: app/src/main/java/com/teocci/ytinbg/interfaces/ItemTouchViewListener.java
// public interface ItemTouchViewListener
// {
//     /**
//      * Called when the {@link ItemTouchHelper} first registers an item as being moved or swiped.
//      * Implementations should update the item view to indicate it's active state.
//      */
//     void onItemSelected();
// 
// 
//     /**
//      * Called when the {@link ItemTouchHelper} has completed the move or swipe, and the active item
//      * state should be cleared.
//      */
//     void onItemClear();
// }


import android.graphics.Canvas;
import com.teocci.ytinbg.interfaces.ItemTouchListener;
import com.teocci.ytinbg.interfaces.ItemTouchViewListener;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.ItemTouchHelper;
import androidx.recyclerview.widget.RecyclerView;
    {
        // Notify the adapter of the dismissal
        itemTouchListener.onItemDismiss(viewHolder.getAdapterPosition());
    }

    @Override
    public void onChildDraw(
            @NonNull Canvas c,
            @NonNull RecyclerView recyclerView,
            @NonNull RecyclerView.ViewHolder viewHolder,
            float dX,
            float dY,
            int actionState,
            boolean isCurrentlyActive)
    {
        if (actionState == ItemTouchHelper.ACTION_STATE_SWIPE) {
            // Fade out the view as it is swiped out of the parent's bounds
            final float alpha = ALPHA_FULL - Math.abs(dX) / (float) viewHolder.itemView.getWidth();
            viewHolder.itemView.setAlpha(alpha);
            viewHolder.itemView.setTranslationX(dX);
        } else {
            super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive);
        }
    }

    @Override
    public void onSelectedChanged(RecyclerView.ViewHolder viewHolder, int actionState)
    {
        // We only want the active item to change
        if (actionState != ItemTouchHelper.ACTION_STATE_IDLE) {
// Path: app/src/main/java/com/teocci/ytinbg/interfaces/ItemTouchListener.java
// public interface ItemTouchListener
// {
//     /**
//      * Called when an item has been dragged far enough to trigger a move. This is called every time
//      * an item is shifted, and <strong>not</strong> at the end of a "drop" event.<br/>
//      * <br/>
//      * Implementations should call {@link RecyclerView.Adapter#notifyItemMoved(int, int)} after
//      * adjusting the underlying data to reflect this move.
//      *
//      * @param fromPosition The start position of the moved item.
//      * @param toPosition   Then resolved position of the moved item.
//      * @return True if the item was moved to the new adapter position.
//      * @see RecyclerView.ViewHolder#getAdapterPosition()
//      */
//     boolean onItemMove(int fromPosition, int toPosition);
// 
// 
//     /**
//      * Called when an item has been dismissed by a swipe.<br/>
//      * <br/>
//      * Implementations should call {@link RecyclerView.Adapter#notifyItemRemoved(int)} after
//      * adjusting the underlying data to reflect this removal.
//      *
//      * @param position The position of the item dismissed.
//      * @see RecyclerView.ViewHolder#getAdapterPosition()
//      */
//     void onItemDismiss(int position);
// }
// 
// Path: app/src/main/java/com/teocci/ytinbg/interfaces/ItemTouchViewListener.java
// public interface ItemTouchViewListener
// {
//     /**
//      * Called when the {@link ItemTouchHelper} first registers an item as being moved or swiped.
//      * Implementations should update the item view to indicate it's active state.
//      */
//     void onItemSelected();
// 
// 
//     /**
//      * Called when the {@link ItemTouchHelper} has completed the move or swipe, and the active item
//      * state should be cleared.
//      */
//     void onItemClear();
// }


// Path: app/src/main/java/com/teocci/ytinbg/callbacks/SimpleItemTouchCallback.java
import android.graphics.Canvas;
import com.teocci.ytinbg.interfaces.ItemTouchListener;
import com.teocci.ytinbg.interfaces.ItemTouchViewListener;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.ItemTouchHelper;
import androidx.recyclerview.widget.RecyclerView;

    {
        // Notify the adapter of the dismissal
        itemTouchListener.onItemDismiss(viewHolder.getAdapterPosition());
    }

    @Override
    public void onChildDraw(
            @NonNull Canvas c,
            @NonNull RecyclerView recyclerView,
            @NonNull RecyclerView.ViewHolder viewHolder,
            float dX,
            float dY,
            int actionState,
            boolean isCurrentlyActive)
    {
        if (actionState == ItemTouchHelper.ACTION_STATE_SWIPE) {
            // Fade out the view as it is swiped out of the parent's bounds
            final float alpha = ALPHA_FULL - Math.abs(dX) / (float) viewHolder.itemView.getWidth();
            viewHolder.itemView.setAlpha(alpha);
            viewHolder.itemView.setTranslationX(dX);
        } else {
            super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive);
        }
    }

    @Override
    public void onSelectedChanged(RecyclerView.ViewHolder viewHolder, int actionState)
    {
        // We only want the active item to change
        if (actionState != ItemTouchHelper.ACTION_STATE_IDLE) {
            if (viewHolder instanceof ItemTouchViewListener) {