Var mShouldScroll:Boolean = false var mShouldScroll:Boolean = false var mShouldScroll:Boolean = false  smoothMoveToPosition(mRecyclerView: RecyclerView, position: Int) {/ / position of the first visible var firstItem = mRecyclerView getChildLayoutPosition (mRecyclerView. GetChildAt (0)) / / the last visible position var lastItem = mRecyclerView. GetChildLayoutPosition (mRecyclerView. GetChildAt (mRecyclerView. ChildCount - 1)) If (position < firstItem){// If (position < firstItem){ SmoothScrollToPosition can jump straight mRecyclerView. SmoothScrollToPosition (position)} else if (position < = lastItem) {/ / SmoothScrollToPosition does not move at all, Var movePosition = position-Firstitem if (movePosition >= 0 && movePosition<mRecyclerView.childCount){ var top = mRecyclerView.getChildAt(movePosition).top MRecyclerView. SmoothScrollBy (0, top)}} else {/ / if you want to jump the position after the last visible items, Call smoothScrollToPosition to scroll to visible location and onScrollStateChanged to call smoothMoveToPosition again. Execute on a judgment method of mRecyclerView. SmoothScrollToPosition (position) mToPosition = position mShouldScroll = true}}Copy the code
  • Load recycleView item one by one, run horselight effect
Rv_diagnosis. ScrollToPosition (multList. Size - 1) the disposable = Flowable. The interval (1, 1, TimeUnit. SECONDS). DoOnNext {the if (it.toInt()>=multList.size){ disposable?.dispose() } // multList[it.toInt()].itemType multListSingle.add(multList[it.toInt()]) } .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(Consumer { diagnosisAdapter.notifyDataSetChanged() smoothMoveToPosition(rv_diagnosis,it.toInt()) })Copy the code