fixed NPEs

This commit is contained in:
Mariotaku Lee 2017-08-14 00:29:03 +08:00
parent e51db26094
commit 460d8559c5
No known key found for this signature in database
GPG Key ID: 15C10F89D7C33535
1 changed files with 6 additions and 3 deletions

View File

@ -49,10 +49,13 @@ public class RecyclerViewUtils {
focusFallback(layoutManager);
} else {
final View view;
if (direction > 0 && currentFocus == layoutManager.findLastVisibleItemPosition()) {
view = recyclerView.focusSearch(recyclerView.getFocusedChild(), View.FOCUS_DOWN);
final View focusedChild = recyclerView.getFocusedChild();
if (focusedChild == null) {
view = null;
} else if (direction > 0 && currentFocus == layoutManager.findLastVisibleItemPosition()) {
view = recyclerView.focusSearch(focusedChild, View.FOCUS_DOWN);
} else if (direction < 0 && currentFocus == layoutManager.findFirstVisibleItemPosition()) {
view = recyclerView.focusSearch(recyclerView.getFocusedChild(), View.FOCUS_UP);
view = recyclerView.focusSearch(focusedChild, View.FOCUS_UP);
} else {
view = null;
}