Fix crashes on rotation by checking for `null`
This commit is contained in:
parent
b0c0249ce6
commit
d8d9c7e171
|
@ -131,15 +131,14 @@ public abstract class BaseListFragment<I, N> extends BaseStateFragment<I>
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getFocusedPosition() {
|
private int getFocusedPosition() {
|
||||||
View focusedItem = itemsList.getFocusedChild();
|
try {
|
||||||
if (focusedItem != null) {
|
final View focusedItem = itemsList.getFocusedChild();
|
||||||
RecyclerView.ViewHolder itemHolder = itemsList.findContainingViewHolder(focusedItem);
|
final RecyclerView.ViewHolder itemHolder =
|
||||||
if (itemHolder != null) {
|
itemsList.findContainingViewHolder(focusedItem);
|
||||||
return itemHolder.getAdapterPosition();
|
return itemHolder.getAdapterPosition();
|
||||||
}
|
} catch (NullPointerException e) {
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue