Skip to content

Commit

Permalink
fix(android): fix Ti.UI.ListView scroll state restoration (#13493)
Browse files Browse the repository at this point in the history
* fix(android): fix list view scroll state restoration

* chore: use proper constants
  • Loading branch information
hansemannn committed Jun 26, 2022
1 parent cb6ccc1 commit 6f96424
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import android.graphics.drawable.Drawable;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.RectShape;
import android.os.Parcelable;
import android.view.MotionEvent;
import android.view.View;

Expand Down Expand Up @@ -193,7 +194,7 @@ public void onLayoutChange(View v, int left, int top, int right, int bottom, int

final SelectionTracker.Builder trackerBuilder = new SelectionTracker.Builder("list_view_selection",
this.recyclerView,
new ItemKeyProvider(1)
new ItemKeyProvider(ItemKeyProvider.SCOPE_CACHED)
{
@Nullable
@Override
Expand Down Expand Up @@ -738,6 +739,8 @@ public void update(boolean force)
this.proxy.fireEvent(TiC.EVENT_NO_RESULTS, null);
}

Parcelable recyclerViewState = recyclerView.getLayoutManager().onSaveInstanceState();

// Notify adapter of changes on UI thread.
this.adapter.update(this.items, force);

Expand Down Expand Up @@ -778,6 +781,8 @@ public void run()
}
}
}

recyclerView.getLayoutManager().onRestoreInstanceState(recyclerViewState);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public void onLayoutChange(View v, int left, int top, int right, int bottom, int

final SelectionTracker.Builder trackerBuilder = new SelectionTracker.Builder("table_view_selection",
this.recyclerView,
new ItemKeyProvider(1)
new ItemKeyProvider(ItemKeyProvider.SCOPE_CACHED)
{
@Nullable
@Override
Expand Down

0 comments on commit 6f96424

Please sign in to comment.