Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android] fix news ntp gps crash #16890

Merged
merged 1 commit into from
Jan 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a minor suggestion, that if, could be combined with if (mNtpAdapter == null)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we combined with if (mNtpAdapter == null) then we have to change else with else if(mNtpAdapter!=null) so I think it's fine to keep as it is. wdyt?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, you are right, my bad, let's keep as is.

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 {
Expand Down