public override int FindTargetSnapPosition(RecyclerView.LayoutManager layoutManager, int velocityX, int velocityY) { //throw new NotImplementedException(); int target = RecyclerView.NoPosition;//.NO_POSITION; Loge("findTargetSnapPosition, velocityX = " + velocityX + ", velocityY" + velocityY); if (null != layoutManager && layoutManager is PagerGridLayoutManager) { PagerGridLayoutManager manager = (PagerGridLayoutManager)layoutManager; if (manager.CanScrollHorizontally()) { if (velocityX > PagerConfig.GetFlingThreshold()) { target = manager.FindNextPageFirstPos(); } else if (velocityX < -PagerConfig.GetFlingThreshold()) { target = manager.FindPrePageFirstPos(); } } else if (manager.CanScrollVertically()) { if (velocityY > PagerConfig.GetFlingThreshold()) { target = manager.FindNextPageFirstPos(); } else if (velocityY < -PagerConfig.GetFlingThreshold()) { target = manager.FindPrePageFirstPos(); } } } Loge("findTargetSnapPosition, target = " + target); return(target); }
public override View FindSnapView(RecyclerView.LayoutManager layoutManager) { //throw new NotImplementedException(); if (layoutManager is PagerGridLayoutManager) { PagerGridLayoutManager manager = (PagerGridLayoutManager)layoutManager; return(manager.FindSnapView()); } return(null); }
public override int[] CalculateDistanceToFinalSnap(RecyclerView.LayoutManager layoutManager, View targetView) { //throw new NotImplementedException(); int pos = layoutManager.GetPosition(targetView); Loge("findTargetSnapPosition, pos = " + pos); int[] offset = new int[2]; if (layoutManager is PagerGridLayoutManager) { PagerGridLayoutManager manager = (PagerGridLayoutManager)layoutManager; offset = manager.GetSnapOffset(pos); } return(offset); }
protected override void OnTargetFound(View targetView, RecyclerView.State state, Action action) { RecyclerView.LayoutManager manager = mRecyclerView.GetLayoutManager(); if (null == manager) { return; } if (manager is PagerGridLayoutManager) { PagerGridLayoutManager layoutManager = (PagerGridLayoutManager)manager; int pos = mRecyclerView.GetChildAdapterPosition(targetView); int[] snapDistances = layoutManager.GetSnapOffset(pos); int dx = snapDistances[0]; int dy = snapDistances[1]; Logi("dx = " + dx); Logi("dy = " + dy); int time = CalculateTimeForScrolling(Math.Max(Math.Abs(dx), Math.Abs(dy))); if (time > 0) { action.Update(dx, dy, time, new DecelerateInterpolator()); } } }