Skip to content

Commit

Permalink
Merge pull request #8362 from wordpress-mobile/fix/crash_in_activity_log
Browse files Browse the repository at this point in the history
Fix missing site crash in ActivityLogListActivity
  • Loading branch information
malinajirka authored Sep 25, 2018
2 parents 73fb889 + 87349ac commit 2a0faca
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,10 @@ public static void viewPluginDetail(Activity context, SiteModel site, String slu
}

public static void viewActivityLogList(Activity activity, SiteModel site) {
if (site == null) {
ToastUtils.showToast(activity, R.string.blog_not_found, ToastUtils.Duration.SHORT);
return;
}
AnalyticsUtils.trackWithSiteDetails(AnalyticsTracker.Stat.ACTIVITY_LOG_LIST_OPENED, site);
Intent intent = new Intent(activity, ActivityLogListActivity.class);
intent.putExtra(WordPress.SITE, site);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,25 @@ class ActivityLogListFragment : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

log_list_view.layoutManager = LinearLayoutManager(activity, LinearLayoutManager.VERTICAL, false)
val nonNullActivity = checkNotNull(activity)

log_list_view.layoutManager = LinearLayoutManager(nonNullActivity, LinearLayoutManager.VERTICAL, false)

swipeToRefreshHelper = buildSwipeToRefreshHelper(swipe_refresh_layout) {
if (NetworkUtils.checkConnection(activity)) {
if (NetworkUtils.checkConnection(nonNullActivity)) {
viewModel.onPullToRefresh()
} else {
swipeToRefreshHelper.isRefreshing = false
}
}

(activity?.application as WordPress).component()?.inject(this)
(nonNullActivity.application as WordPress).component()?.inject(this)

viewModel = ViewModelProviders.of(this, viewModelFactory).get(ActivityLogViewModel::class.java)

val site = if (savedInstanceState == null) {
activity?.intent?.getSerializableExtra(WordPress.SITE) as SiteModel
val nonNullIntent = checkNotNull(nonNullActivity.intent)
nonNullIntent.getSerializableExtra(WordPress.SITE) as SiteModel
} else {
savedInstanceState.getSerializable(WordPress.SITE) as SiteModel
}
Expand Down

0 comments on commit 2a0faca

Please sign in to comment.