<commit_before>package com.woxthebox.dragitemrecyclerview;

import android.content.Context;
import android.graphics.Canvas;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.GridLayoutManager;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.HorizontalScrollView;
import android.widget.LinearLayout;

import java.util.ArrayList;

public class BoardView extends HorizontalScrollView {

    private LinearLayout mLayout;
    private ArrayList<DragItemRecyclerView> mLists = new ArrayList<>();
    private DragItemRecyclerView mCurrentRecyclerView;
    private DragItemImage mDragItemImage;
    private boolean mDragging;

    public BoardView(Context context) {
        super(context);
    }

    public BoardView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public BoardView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        return mDragging;
    }

    private DragItemRecyclerView getCurrentRecyclerView(float x, float y) {
        for (DragItemRecyclerView list : mLists) {
            if (list.getLeft() <= x && list.getRight() > x) {
                return list;
            }
        }
        return mCurrentRecyclerView;
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        if (mDragging) {
            switch (event.getAction()) {
                case MotionEvent.ACTION_MOVE:
                    DragItemRecyclerView currentList = getCurrentRecyclerView(event.getX(), event.getY());
                    if (mCurrentRecyclerView != currentList) {
                        long itemId = mCurrentRecyclerView.getDragItemId();
                        Object item = mCurrentRecyclerView.removeDragItemAndEnd();
                        mCurrentRecyclerView = currentList;
                        mCurrentRecyclerView.addDragItemAndStart(event.getY(), item, itemId);
                    }
                    event.setLocation(event.getX() - mCurrentRecyclerView.getX(), event.getY());
                    mCurrentRecyclerView.onDragging(event.getX(), event.getY());
                    invalidate();
                    break;
                case MotionEvent.ACTION_UP:
                case MotionEvent.ACTION_CANCEL:
                    mCurrentRecyclerView.onDragEnded();
                    mDragging = false;
                    invalidate();
                    break;
            }
            return true;
        }

        return super.onTouchEvent(event);
    }<commit_msg>Fixed coordinates on drag<commit_after>package com.woxthebox.dragitemrecyclerview;

import android.content.Context;
import android.graphics.Canvas;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.GridLayoutManager;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.HorizontalScrollView;
import android.widget.LinearLayout;

import java.util.ArrayList;

public class BoardView extends HorizontalScrollView {

    private LinearLayout mLayout;
    private ArrayList<DragItemRecyclerView> mLists = new ArrayList<>();
    private DragItemRecyclerView mCurrentRecyclerView;
    private DragItemImage mDragItemImage;
    private boolean mDragging;

    public BoardView(Context context) {
        super(context);
    }

    public BoardView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public BoardView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent event) {
        return mDragging || super.onInterceptTouchEvent(event);
    }

    private DragItemRecyclerView getCurrentRecyclerView(float x, float y) {
        for (DragItemRecyclerView list : mLists) {
            if (list.getLeft() <= x && list.getRight() > x) {
                return list;
            }
        }
        return mCurrentRecyclerView;
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        if (mDragging) {
            switch (event.getAction()) {
                case MotionEvent.ACTION_MOVE:
                    // Updated event to scrollview coordinates
                    event.setLocation(getScrollX() + event.getX(), event.getY());
                    DragItemRecyclerView currentList = getCurrentRecyclerView(event.getX(), event.getY());
                    if (mCurrentRecyclerView != currentList) {
                        long itemId = mCurrentRecyclerView.getDragItemId();
                        Object item = mCurrentRecyclerView.removeDragItemAndEnd();
                        mCurrentRecyclerView = currentList;
                        mCurrentRecyclerView.addDragItemAndStart(event.getY(), item, itemId);
                    }
                    // Updated event to list coordinates
                    event.setLocation(event.getX() - mCurrentRecyclerView.getX(), event.getY());
                    mCurrentRecyclerView.onDragging(event.getX(), event.getY());
                    invalidate();
                    break;
                case MotionEvent.ACTION_UP:
                case MotionEvent.ACTION_CANCEL:
                    mCurrentRecyclerView.onDragEnded();
                    mDragging = false;
                    invalidate();
                    break;
            }
            return true;
        }

        return super.onTouchEvent(event);
    }
{'fraction_non_alphanumeric': 0.0810230727955643, 'fraction_numerical': 0.0007154355213736362, 'mean_word_length': 2.213793103448276, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4941564', 'n_tokens_mistral': 1496, 'n_tokens_neox': 1391, 'n_words': 293}