Skip to content

Commit 2781b0f

Browse files
Dave CoffinPeterStaev
authored andcommitted
Fixes an android crash
Specifically, if you have a view with multiple tabs and you are on a tab that is not the tab containing the GridView, and you use the App Switcher to switch to another app and then BACK to your app, it will crash because owner.items is undefined. Switching the apps appears to lose the context if the tab you are on is not the tab containing the Grid View. So, this is a simple check to avoid the crash.
1 parent 8b61201 commit 2781b0f

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

grid-view.android.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -216,13 +216,16 @@ class GridViewScrollListener extends android.support.v7.widget.RecyclerView.OnSc
216216
}
217217

218218
const lastVisibleItemPos = (view.getLayoutManager() as android.support.v7.widget.GridLayoutManager).findLastCompletelyVisibleItemPosition();
219-
const itemCount = owner.items.length - 1;
220-
if (lastVisibleItemPos === itemCount) {
221-
owner.notify({
222-
eventName: GridViewBase.loadMoreItemsEvent,
223-
object: owner
224-
});
219+
if (owner && owner.items) {
220+
const itemCount = owner.items.length - 1;
221+
if (lastVisibleItemPos === itemCount) {
222+
owner.notify({
223+
eventName: GridViewBase.loadMoreItemsEvent,
224+
object: owner
225+
});
226+
}
225227
}
228+
226229
}
227230

228231
public onScrollStateChanged(view: android.support.v7.widget.RecyclerView, newState: number) {

0 commit comments

Comments
 (0)