DarkionAvey/SwipeSpinnerWidget

How to get the current item?

Opened this issue · 6 comments

How to get the position when the selection is complete?

I didn't include a method in the helper class to do that since there are many ways to achieve this with recyclerview.
For example (using the demo app, and assuming your items have the same height as yourRecyclerView):

int mScrolledDistance; 

yourRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
            @Override
            public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
                super.onScrollStateChanged(recyclerView, newState);

                int position = mScrolledDistance/ yourRecyclerView.getHeight();
                String value = ((DataAdapter) yourRecyclerView.getAdapter()).mData.get(position);
                Log.e("TAG", "Current selection: " + position + " " + value);
            }

            @Override
            public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
                super.onScrolled(recyclerView, dx, dy);
                mScrolledDistance+= dy;
            }
        });

@DarkionAvey OK,Is the id in the snapToItem() in the helper class the current location, why not call it back?

@Anzhi-Meiying whoops! I actually forgot that part! I will create an interface to retrieve selected item position soon.

Can i use this in my app >

Can i use this in my app >

Yes