Fix BrowseFragment NPE
Bug: 32932465
Test: Run demo app
Change-Id: Iee5afa78b7af80e8a6de84b1cd722b6ac91e6bb9
diff --git a/v17/leanback/src/android/support/v17/leanback/app/BrowseFragment.java b/v17/leanback/src/android/support/v17/leanback/app/BrowseFragment.java
index 48ea0aa..fc6561e 100644
--- a/v17/leanback/src/android/support/v17/leanback/app/BrowseFragment.java
+++ b/v17/leanback/src/android/support/v17/leanback/app/BrowseFragment.java
@@ -1539,9 +1539,11 @@
mHeadersFragment.setAlignment(mContainerListAlignTop);
setMainFragmentAlignment();
- if (mCanShowHeaders && mShowingHeaders && mHeadersFragment.getView() != null) {
+ if (mCanShowHeaders && mShowingHeaders && mHeadersFragment != null
+ && mHeadersFragment.getView() != null) {
mHeadersFragment.getView().requestFocus();
- } else if ((!mCanShowHeaders || !mShowingHeaders) && mMainFragment.getView() != null) {
+ } else if ((!mCanShowHeaders || !mShowingHeaders) && mMainFragment != null
+ && mMainFragment.getView() != null) {
mMainFragment.getView().requestFocus();
}
diff --git a/v17/leanback/src/android/support/v17/leanback/app/BrowseSupportFragment.java b/v17/leanback/src/android/support/v17/leanback/app/BrowseSupportFragment.java
index 6bad0e5..7bcc43d 100644
--- a/v17/leanback/src/android/support/v17/leanback/app/BrowseSupportFragment.java
+++ b/v17/leanback/src/android/support/v17/leanback/app/BrowseSupportFragment.java
@@ -1542,9 +1542,11 @@
mHeadersSupportFragment.setAlignment(mContainerListAlignTop);
setMainFragmentAlignment();
- if (mCanShowHeaders && mShowingHeaders && mHeadersSupportFragment.getView() != null) {
+ if (mCanShowHeaders && mShowingHeaders && mHeadersSupportFragment != null
+ && mHeadersSupportFragment.getView() != null) {
mHeadersSupportFragment.getView().requestFocus();
- } else if ((!mCanShowHeaders || !mShowingHeaders) && mMainFragment.getView() != null) {
+ } else if ((!mCanShowHeaders || !mShowingHeaders) && mMainFragment != null
+ && mMainFragment.getView() != null) {
mMainFragment.getView().requestFocus();
}