Skip to content

Commit

Permalink
Merge pull request #17012 from brave/fix_crash_enable_news_no_connect…
Browse files Browse the repository at this point in the history
…ion_android

[Android] fix crash enable brave news when no internet connection
  • Loading branch information
tapanmodh authored Feb 3, 2023
2 parents 5e987c4 + b2a2cdc commit 564e28c
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,6 @@ public int getItemCount() {
int statsCount = getStatsCount();
int topSitesCount = getTopSitesCount();
int newsLoadingCount = shouldDisplayNewsLoading() ? 1 : 0;

if (mIsDisplayNewsOptin) {
return statsCount + topSitesCount + TWO_ITEMS_SPACE + newsLoadingCount;
} else if (mIsDisplayNews) {
Expand Down Expand Up @@ -468,6 +467,11 @@ public int getTopMarginImageCredit() {

public void setNewsLoading(boolean isNewsLoading) {
mIsNewsLoading = isNewsLoading;
if (isNewsLoading) {
notifyItemInserted(getStatsCount() + getTopSitesCount() + ONE_ITEM_SPACE);
} else {
notifyItemRemoved(getStatsCount() + getTopSitesCount() + ONE_ITEM_SPACE);
}
notifyItemRangeChanged(getStatsCount() + getTopSitesCount(), TWO_ITEMS_SPACE);
}

Expand Down

0 comments on commit 564e28c

Please sign in to comment.