@@ -4009,17 +4009,19 @@ class PositionScroller implements Runnable {
40094009 void start (final int position ) {
40104010 stop ();
40114011
4012+ if (mDataChanged ) {
4013+ // Wait until we're back in a stable state to try this.
4014+ post (new Runnable () {
4015+ @ Override public void run () {
4016+ start (position );
4017+ }
4018+ });
4019+ return ;
4020+ }
4021+
40124022 final int childCount = getChildCount ();
40134023 if (childCount == 0 ) {
40144024 // Can't scroll without children.
4015- if (mDataChanged ) {
4016- // But we might have something in a minute.
4017- post (new Runnable () {
4018- @ Override public void run () {
4019- start (position );
4020- }
4021- });
4022- }
40234025 return ;
40244026 }
40254027
@@ -4058,17 +4060,19 @@ void start(final int position, final int boundPosition) {
40584060 return ;
40594061 }
40604062
4063+ if (mDataChanged ) {
4064+ // Wait until we're back in a stable state to try this.
4065+ post (new Runnable () {
4066+ @ Override public void run () {
4067+ start (position , boundPosition );
4068+ }
4069+ });
4070+ return ;
4071+ }
4072+
40614073 final int childCount = getChildCount ();
40624074 if (childCount == 0 ) {
40634075 // Can't scroll without children.
4064- if (mDataChanged ) {
4065- // But we might have something in a minute.
4066- post (new Runnable () {
4067- @ Override public void run () {
4068- start (position , boundPosition );
4069- }
4070- });
4071- }
40724076 return ;
40734077 }
40744078
@@ -4129,9 +4133,26 @@ void startWithOffset(int position, int offset) {
41294133 startWithOffset (position , offset , SCROLL_DURATION );
41304134 }
41314135
4132- void startWithOffset (int position , int offset , int duration ) {
4136+ void startWithOffset (final int position , int offset , final int duration ) {
41334137 stop ();
41344138
4139+ if (mDataChanged ) {
4140+ // Wait until we're back in a stable state to try this.
4141+ final int postOffset = offset ;
4142+ post (new Runnable () {
4143+ @ Override public void run () {
4144+ startWithOffset (position , postOffset , duration );
4145+ }
4146+ });
4147+ return ;
4148+ }
4149+
4150+ final int childCount = getChildCount ();
4151+ if (childCount == 0 ) {
4152+ // Can't scroll without children.
4153+ return ;
4154+ }
4155+
41354156 offset += getPaddingTop ();
41364157
41374158 mTargetPos = position ;
@@ -4141,7 +4162,6 @@ void startWithOffset(int position, int offset, int duration) {
41414162 mMode = MOVE_OFFSET ;
41424163
41434164 final int firstPos = mFirstPosition ;
4144- final int childCount = getChildCount ();
41454165 final int lastPos = firstPos + childCount - 1 ;
41464166
41474167 int viewTravelCount ;
@@ -4514,7 +4534,7 @@ void smoothScrollBy(int distance, int duration, boolean linear) {
45144534
45154535 if (distance == 0 || mItemCount == 0 || childCount == 0 ||
45164536 (firstPos == 0 && getChildAt (0 ).getTop () == topLimit && distance < 0 ) ||
4517- (lastPos == mItemCount - 1 &&
4537+ (lastPos == mItemCount &&
45184538 getChildAt (childCount - 1 ).getBottom () == bottomLimit && distance > 0 )) {
45194539 mFlingRunnable .endFling ();
45204540 if (mPositionScroller != null ) {
0 commit comments