Work around AbsListView.confirmCheckedPositionsById() not respecting adapter count.
When restoring instance state, AbsListView tries to reconstruct the checked positions from checked ids saved in instance state, however it didn't take changing adapter content into consideration so that it may call Adapter.getItemId() with a position greater than or equal to Adapter.getCount(), breaking the contract. We can work around this by returning ListView.INVALID_ROW_ID when getItemId() is called with an invalid position, and since we are already manually restoring the checked item (because we need to differentiate between a user-checked item v.s. an item checked because it's current default), it's okay to lose the checked state restoration provided by AbsListView. Fixes: 147613076 Fixes: 154801645 Test: Enable "Don't keep activities" in Settings, open an app that requests a role, select an item in list and switch apps back and forth. This way RequestRoleFragment is crashing before the fix, and not crashing after the fix. State is also still preserved after rotation after the fix. Change-Id: Id29328ba6cb2e54fef58042dd3c87404e3958e56
Loading
Please register or sign in to comment