Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue with Fling #8

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
* Created by chensuilun on 2016/11/18.
*/
public class GalleryLayoutManager extends RecyclerView.LayoutManager implements RecyclerView.SmoothScroller.ScrollVectorProvider {

private static final boolean DEBUG = false;

private static final String TAG = "GalleryLayoutManager";
final static int LAYOUT_START = -1;

Expand Down Expand Up @@ -909,6 +912,18 @@ public void attach(RecyclerView recyclerView, int selectedPosition) {
recyclerView.setLayoutManager(this);
mSnapHelper.attachToRecyclerView(recyclerView);
recyclerView.addOnScrollListener(mInnerScrollListener);

//SnapHelper dft implement an RecyclerView.OnFlingListener, so if there
//is only 3 item, fling from 1 to 0, the onItemSelected callback will not call.
//so we set an OnFlingListener with no process, that is ok.
RecyclerView.OnFlingListener onFlingListener = new RecyclerView.OnFlingListener() {
@Override
public boolean onFling(final int velocityX, final int velocityY) {
Log.e(TAG, "onFling: onTouchEvent 1 mState=" + mState);
return false;
}
};
recyclerView.setOnFlingListener(onFlingListener);
}

RecyclerView mRecyclerView;
Expand Down