diff --git a/android/java/org/chromium/chrome/browser/ntp/BraveNewTabPageLayout.java b/android/java/org/chromium/chrome/browser/ntp/BraveNewTabPageLayout.java index 6d77622a66f8..e6f0590ca4a5 100644 --- a/android/java/org/chromium/chrome/browser/ntp/BraveNewTabPageLayout.java +++ b/android/java/org/chromium/chrome/browser/ntp/BraveNewTabPageLayout.java @@ -397,19 +397,22 @@ private void setNtpRecyclerView(LinearLayoutManager linearLayoutManager) { mIsBraveStatsEnabled = shouldDisplayBraveStats(); if (mNtpAdapter == null) { - mNtpAdapter = new BraveNtpAdapter(mActivity, this, Glide.with(mActivity), - mNewsItemsFeedCard, mBraveNewsController, mMvTilesContainerLayout, - mNtpImageGlobal, mSponsoredTab, mWallpaper, mSponsoredLogo, - mNTPBackgroundImagesBridge, false, mRecyclerView.getHeight(), - mIsTopSitesEnabled, mIsBraveStatsEnabled, mIsDisplayNews, mIsDisplayNewsOptin); - - mRecyclerView.setAdapter(mNtpAdapter); - - if (mRecyclerView.getItemAnimator() != null) { - RecyclerView.ItemAnimator itemAnimator = mRecyclerView.getItemAnimator(); - if (itemAnimator instanceof SimpleItemAnimator) { - SimpleItemAnimator simpleItemAnimator = (SimpleItemAnimator) itemAnimator; - simpleItemAnimator.setSupportsChangeAnimations(false); + if (mActivity != null && !mActivity.isDestroyed() && !mActivity.isFinishing()) { + mNtpAdapter = new BraveNtpAdapter(mActivity, this, Glide.with(mActivity), + mNewsItemsFeedCard, mBraveNewsController, mMvTilesContainerLayout, + mNtpImageGlobal, mSponsoredTab, mWallpaper, mSponsoredLogo, + mNTPBackgroundImagesBridge, false, mRecyclerView.getHeight(), + mIsTopSitesEnabled, mIsBraveStatsEnabled, mIsDisplayNews, + mIsDisplayNewsOptin); + + mRecyclerView.setAdapter(mNtpAdapter); + + if (mRecyclerView.getItemAnimator() != null) { + RecyclerView.ItemAnimator itemAnimator = mRecyclerView.getItemAnimator(); + if (itemAnimator instanceof SimpleItemAnimator) { + SimpleItemAnimator simpleItemAnimator = (SimpleItemAnimator) itemAnimator; + simpleItemAnimator.setSupportsChangeAnimations(false); + } } } } else {