lucanicoletti/HiddenSearchWithRecyclerView

Incorrect position of click in Recycler view.

Closed this issue · 10 comments

Hello @lnicolet

It give wrong position on scroll state. if using card view with linear layout manger then it is give wrong position, if you use click on single child of layout like Text View, then click not working when search view open.

please look in to it.

Thanks

Can you provide more specific info on how to reproduce it?

Can you provide more specific info on how to reproduce it?

Hello @lnicolet

Like your example you create list with recycler View.

please do one more thing create click listener of recycler view. to know of click position.

when you click on any item of recycler View with click listener. like you click 3 item (position) of recycler view. then you see, your console log show 4 item value (position) of reclcler View.

// row click listener

    recyclerView.addOnItemTouchListener(new RecyclerTouchListener(getActivity(), recyclerView, new RecyclerTouchListener.ClickListener() {
        @Override
        public void onClick(View view, int position) {
            Play play = filteredList.get(position);
            Log.e(TAG, play.getName() + " is selected!");
        }

        @Override
        public void onLongClick(View view, int position) {

        }
    }));

// Interface of click listener

public class RecyclerTouchListener implements RecyclerView.OnItemTouchListener {

private GestureDetector gestureDetector;
private ClickListener clickListener;

public RecyclerTouchListener(Context context, final RecyclerView recyclerView, final ClickListener clickListener) {
    this.clickListener = clickListener;
    gestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() {
        @Override
        public boolean onSingleTapUp(MotionEvent e) {
            return true;
        }

        @Override
        public void onLongPress(MotionEvent e) {
            View child = recyclerView.findChildViewUnder(e.getX(), e.getY());
            if (child != null && clickListener != null) {
                clickListener.onLongClick(child, recyclerView.getChildPosition(child));
            }
        }
    });
}

@Override
public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) {

    View child = rv.findChildViewUnder(e.getX(), e.getY());
    if (child != null && clickListener != null && gestureDetector.onTouchEvent(e)) {
        clickListener.onClick(child, rv.getChildPosition(child));
    }
    return false;
}

@Override
public void onTouchEvent(RecyclerView rv, MotionEvent e) {
}

@Override
public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {

}

public interface ClickListener {
    void onClick(View view, int position);

    void onLongClick(View view, int position);
}}

If you want to generate this error, this way it is easy to elaborate.

Thanks

Spent the weekend investigating on it, found out what's the problem.
Should be able to fix it in the next few days.

Thanks for raising it.

Spent the weekend investigating on it, found out what's the problem.
Should be able to fix it in the next few days.

Thanks for raising it.

Hello @lnicolet

Very thanks for reply, i use hidden search view in app. This is good library, waiting for your solution
(FIX)
.

Thanks

This should be fixed with the 0.0.6 version of the library.

Please confirm and close the issue if it is, or update it.

This should be fixed with the 0.0.6 version of the library.

Please confirm and close the issue if it is, or update it.

Hello @lnicolet

Very first time in hide state of Search view, recycler view's click listener work fine, When i scroll the list and open search view, i click on any position, it is also work fine, (Second time) but when i again hide the search view with scroll, then click on any position, click listener not work properly, if you use click listener on single item of recycler view, then it is give wrong position, if you click on single child view element of single item of recycler view like (text view), click not work.

Please look in to it

Thanks

Hello @lnicolet

Do you have any solution of that, if you want some more scenario then tell me, i will. but if you did not give any reply with this way your library not go on right path, please check

Thanks

I'm investigating the problem. I am able to reproduce it but have currently no idea why this is happening. Will update the issue as soon as I figure out something

I'm investigating the problem. I am able to reproduce it but have currently no idea why this is happening. Will update the issue as soon as I figure out something

Hello @lnicolet

please look in to it for that issue. may be it have some minor issue or view issue, please check once or if it difficult to find out the issue, please add some alternate in library. so user can use this library easily.

Thanks

I'm investigating the problem. I am able to reproduce it but have currently no idea why this is happening. Will update the issue as soon as I figure out something

Hello @lnicolet

please look in to it for that issue. may be it have some minor issue or view issue, please check once or if it difficult to find out the issue, please add some alternate in library. so user can use this library easily.

Thanks

Sorry but at this time I don't have time to look into this. This is an open-source project so feel free to investigate and propose any solution you can possibly find. I'll go back looking into it as soon as I'll have some more spare time.