From 822775eb9d7ca7ba5aef8b25d817a70ceec373d4 Mon Sep 17 00:00:00 2001 From: "codrut.topliceanu" Date: Thu, 7 Oct 2021 10:48:42 +0300 Subject: [PATCH] [fenix] For https://github.com/mozilla-mobile/fenix/issues/20992 - Speculative fix for TopSitesPagerAdapter crash --- .../org/mozilla/fenix/home/topsites/TopSitesPagerAdapter.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/mozilla/fenix/home/topsites/TopSitesPagerAdapter.kt b/app/src/main/java/org/mozilla/fenix/home/topsites/TopSitesPagerAdapter.kt index 0d35277da9..1a1c08c822 100644 --- a/app/src/main/java/org/mozilla/fenix/home/topsites/TopSitesPagerAdapter.kt +++ b/app/src/main/java/org/mozilla/fenix/home/topsites/TopSitesPagerAdapter.kt @@ -59,7 +59,10 @@ class TopSitesPagerAdapter( // Update new list with the changed items currentPageChangedItems.forEach { item -> - refreshedItems[item.first - (position * TOP_SITES_PER_PAGE)] = item.second + val index = item.first - (position * TOP_SITES_PER_PAGE) + if (index in refreshedItems.indices) { + refreshedItems[index] = item.second + } } // Display the updated list without any of the removed items