Skip to content

Commit 21e044c

Browse files
committed
Merge pull request #3721 from wordpress-mobile/issue/3720-npe-mysitefragment
fix #3720: by null checking mBlog
2 parents cc74572 + 867a9e2 commit 21e044c

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

WordPress/src/main/java/org/wordpress/android/ui/main/MySiteFragment.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,15 @@ public void onEventMainThread(CoreEvents.MainViewPagerScrolled event) {
358358

359359
@SuppressWarnings("unused")
360360
public void onEventMainThread(CoreEvents.BlogListChanged event) {
361-
if (!isAdded() || (mBlog = WordPress.getBlog(mBlog.getLocalTableBlogId())) == null) return;
361+
if (!isAdded() || mBlog == null) {
362+
return;
363+
}
364+
365+
// Update selected blog in case it was changed or deleted / removed.
366+
mBlog = WordPress.getBlog(mBlog.getLocalTableBlogId());
367+
if (mBlog == null) {
368+
return;
369+
}
362370

363371
// Update view if blog has a new name
364372
if (!mBlogTitleTextView.getText().equals(mBlog.getBlogName())) {

0 commit comments

Comments
 (0)