fix:【光环助手】同步正式环境问题-帮助视频问题 https://jira.shanqu.cc/browse/GHZS-3532
This commit is contained in:
@ -4,6 +4,7 @@ import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.OrientationHelper;
|
||||
import androidx.recyclerview.widget.PagerSnapHelper;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
@ -61,4 +62,29 @@ public class LeftPagerSnapHelper extends PagerSnapHelper {
|
||||
}
|
||||
return mHorizontalHelper;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View findSnapView(RecyclerView.LayoutManager layoutManager) {
|
||||
OrientationHelper helper = layoutManager.canScrollHorizontally() ? getHorizontalHelper(layoutManager) : getVerticalHelper(layoutManager);
|
||||
if (layoutManager instanceof LinearLayoutManager) {
|
||||
int firstChildPosition = ((LinearLayoutManager) layoutManager).findFirstVisibleItemPosition();
|
||||
if (firstChildPosition == RecyclerView.NO_POSITION) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (((LinearLayoutManager) layoutManager).findLastCompletelyVisibleItemPosition() == layoutManager.getItemCount() - 1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
View firstChildView = layoutManager.findViewByPosition(firstChildPosition);
|
||||
if (helper.getDecoratedEnd(firstChildView) >= helper.getDecoratedMeasurement(firstChildView) / 2 && helper.getDecoratedEnd(firstChildView) > 0) {
|
||||
return firstChildView;
|
||||
} else {
|
||||
return layoutManager.findViewByPosition(firstChildPosition + 1);
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user