tommybuonomo / dotsindicator

Three material Dots Indicators for view pagers in Android !
Apache License 2.0
3.44k stars 353 forks source link

Fix NPE when the adapter of the ViewPager is manually set to null #129

Closed Flyktsodan closed 2 years ago

Flyktsodan commented 3 years ago

To avoid memory leaks, many will manually set the adapter of the ViewPager(or 2) to null when destroying a fragment: https://charlesmuchene.com/a-subtle-memory-leak-fragment-recyclerview-and-its-adapter

The force unwrap of the adapter will sometimes crash with a NPE. Fixed this by adding small private extensions to safely get the size of the adapter instead.

giacomozama commented 3 years ago

This is very much needed, we're seeing crashes in production due to this exact issue.

tommybuonomo commented 2 years ago

Hello @Flyktsodan thanks for your contribution This issue is now fixed in the new version 4.3 Thanks 🔥