evrencoskun / TableView

TableView is a powerful Android library for displaying complex data structures and rendering tabular data composed of rows, columns and cells.
MIT License
3.14k stars 459 forks source link

TableViewSampleApp ColumnHeaderLongPressed vs ColumnHeaderClicked #197

Closed vkhaitan closed 5 years ago

vkhaitan commented 5 years ago

I find it quite strange that OnColumnHeaderClicked listener is not called when column is touched. Instead the LongPressed version is called. You tableviewsampleapp too execute code in LongPress listener. Why did you not write code in Clicked version, instead of LongPress ? Why Clicked version is not even called ?

vkhaitan commented 5 years ago

Okay. It was working in 0.8.6 . It stopped working after that. I find that you did some changes to fix #133 and that fix created this new issue. Need another fix now.

vkhaitan commented 5 years ago

Okay. So I fixed it in my C# source code. Basically you just forgot to update other files in fix of #133 . e.g. In ClickAction() function

protected internal override bool ClickAction(RecyclerView view, MotionEvent e)
        {
            // Get interacted view from x,y coordinate.
            Android.Views.View childView = view.FindChildViewUnder(e.GetX(), e.GetY());
            if (childView != null && mGestureDetector.OnTouchEvent(e))
            {
                // Find the view holder
                AbstractViewHolder holder = (AbstractViewHolder) mRecyclerView.GetChildViewHolder(childView);
                // Get y position from adapter
                CellRowRecyclerViewAdapter adapter = (CellRowRecyclerViewAdapter) mRecyclerView.GetAdapter();
                int column = holder.AdapterPosition;
                int row = adapter.GetYPosition();
                // Control to ignore selection color
                if (!mTableView.IsIgnoreSelectionColors())
                {
                    mSelectionHandler.SetSelectedCellPositions(holder, column, row);
                }

                if (GetTableViewListener() != null)
                {
                    // Call ITableView listener for item click
                    GetTableViewListener().OnCellClicked(holder, column, row);
                }

                return true;
            }

            return false;
        } 

In this code mGestureDetector.OnTouchEvent(e) is spurious now, since you are already calling it in Listener interface. You need to remove it all 3 files, then commit. I did it for myself in C# code and after that correct methods are being called.

vkhaitan commented 5 years ago

Okay, I just found that there is already a pull request for this via #181 . So marking it closed.