2424import android .graphics .Rect ;
2525import android .os .Parcel ;
2626import android .os .Parcelable ;
27+ import android .support .annotation .NonNull ;
2728import android .support .v4 .view .ViewCompat ;
2829import android .support .v7 .widget .LinearLayoutManager ;
2930import android .support .v7 .widget .LinearSmoothScroller ;
@@ -598,38 +599,37 @@ public void onRestoreInstanceState(Parcelable state) {
598599 }
599600
600601 @ Override
601- public void onItemsAdded (RecyclerView recyclerView , int positionStart , int itemCount ) {
602+ public void onItemsAdded (@ NonNull RecyclerView recyclerView , int positionStart , int itemCount ) {
602603 super .onItemsAdded (recyclerView , positionStart , itemCount );
603604 updateDirtyPosition (positionStart );
604605 }
605606
606607 @ Override
607- public void onItemsUpdated (RecyclerView recyclerView , int positionStart , int itemCount ,
608+ public void onItemsUpdated (@ NonNull RecyclerView recyclerView , int positionStart , int itemCount ,
608609 Object payload ) {
609610 super .onItemsUpdated (recyclerView , positionStart , itemCount , payload );
610611 updateDirtyPosition (positionStart );
611612 }
612613
613614 @ Override
614- public void onItemsUpdated (RecyclerView recyclerView , int positionStart , int itemCount ) {
615+ public void onItemsUpdated (@ NonNull RecyclerView recyclerView , int positionStart , int itemCount ) {
615616 super .onItemsUpdated (recyclerView , positionStart , itemCount );
616617 updateDirtyPosition (positionStart );
617618 }
618619
619620 @ Override
620- public void onItemsRemoved (RecyclerView recyclerView , int positionStart , int itemCount ) {
621+ public void onItemsRemoved (@ NonNull RecyclerView recyclerView , int positionStart , int itemCount ) {
621622 super .onItemsRemoved (recyclerView , positionStart , itemCount );
622623 updateDirtyPosition (positionStart );
623624 }
624625
625626 @ Override
626- public void onItemsMoved (RecyclerView recyclerView , int from , int to , int itemCount ) {
627+ public void onItemsMoved (@ NonNull RecyclerView recyclerView , int from , int to , int itemCount ) {
627628 super .onItemsMoved (recyclerView , from , to , itemCount );
628629 updateDirtyPosition (Math .min (from , to ));
629630 }
630631
631632 private void updateDirtyPosition (int positionStart ) {
632- int firstVisiblePosition = findFirstVisibleItemPosition ();
633633 int lastVisiblePosition = findLastVisibleItemPosition ();
634634 if (positionStart >= lastVisiblePosition ) {
635635 return ;
@@ -650,9 +650,6 @@ private void updateDirtyPosition(int positionStart) {
650650 if (firstView == null ) {
651651 return ;
652652 }
653- if (firstVisiblePosition <= positionStart && positionStart <= lastVisiblePosition ) {
654- return ;
655- }
656653
657654 // Assign the pending scroll position and offset so that the first visible position is
658655 // restored in the next layout.
0 commit comments