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