Skip to content

Commit feea71a

Browse files
authored
Fix the onItemsMoved animation. (#448)
Remove the unneeded guard condition in the updateDirtyPosition. The mPendingScrollPosition (the position that is considered as the starting point when the next layout starts) needed to be updated regardless of the if statement of comparing firstVisiblePosition and the positionStart Fixes #439
1 parent 357dc51 commit feea71a

File tree

3 files changed

+9
-12
lines changed

3 files changed

+9
-12
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ buildscript {
2121
minSdkVersion = 14
2222
targetSdkVersion = 27
2323
compileSdkVersion = 27
24-
androidGradlePluginVersion = "3.0.1"
24+
androidGradlePluginVersion = "3.1.3"
2525
androidMavenGradlePluginVersion = "1.5"
2626
gradleBintrayPluginVersion = "1.6"
2727
kotlinVersion = "1.2.30"

flexbox/src/main/java/com/google/android/flexbox/FlexboxLayoutManager.java

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import android.graphics.Rect;
2525
import android.os.Parcel;
2626
import android.os.Parcelable;
27+
import android.support.annotation.NonNull;
2728
import android.support.v4.view.ViewCompat;
2829
import android.support.v7.widget.LinearLayoutManager;
2930
import 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.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Mon Nov 27 14:52:10 JST 2017
1+
#Thu Jul 19 22:58:08 JST 2018
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.3.1-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip

0 commit comments

Comments
 (0)