Source:
public void onLoadFinished(Loader<AsyncTaskResult<List<EnrolledCoursesResponse>>> asyncTaskResultLoader, AsyncTaskResult<List<EnrolledCoursesResponse>> result) { adapter.clear(); if (result.getEx() != null) { if (result.getEx() instanceof AuthException) { loginPrefs.clear(); getActivity().finish(); } else if (result.getEx() instanceof HttpStatusException) { final HttpStatusException httpStatusException = (HttpStatusException) result.getEx(); switch (httpStatusException.getStatusCode()) { case HttpStatus.UNAUTHORIZED:{ environment.getRouter().forceLogout(getContext(), environment.getAnalyticsRegistry(), environment.getNotificationDelegate()); break; } default: { errorNotification.showError(R.string.network_connected_error, FontAwesomeIcons.fa_exclamation_circle, R.string.lbl_reload, new View.OnClickListener() { @Override public void onClick(View v) { if (NetworkUtil.isConnected(getContext())) { onRefresh(); } } }); } } } else { logger.error(result.getEx()); } } else if (result.getResult() != null) { ArrayList<EnrolledCoursesResponse> newItems = new ArrayList<EnrolledCoursesResponse>(result.getResult()); ((MyCoursesListActivity) getActivity()).updateDatabaseAfterDownload(newItems); if (result.getResult().size() > 0) { adapter.setItems(newItems); adapter.notifyDataSetChanged(); } } binding.swipeContainer.setRefreshing(false); binding.loadingIndicator.getRoot().setVisibility(View.GONE); if (adapter.isEmpty() && !environment.getConfig().getCourseDiscoveryConfig().isCourseDiscoveryEnabled()) { errorNotification.showError(R.string.no_courses_to_display, FontAwesomeIcons.fa_exclamation_circle, 0, null); binding.myCourseList.setVisibility(View.GONE); } else { binding.myCourseList.setVisibility(View.VISIBLE); errorNotification.hideError(); } }

Target:
public void onLoadFinished(Loader<AsyncTaskResult<List<EnrolledCoursesResponse>>> asyncTaskResultLoader, AsyncTaskResult<List<EnrolledCoursesResponse>> result) { adapter.clear(); final Exception exception = result.getEx(); if (exception != null) { if (exception instanceof AuthException) { loginPrefs.clear(); getActivity().finish(); } else if (exception instanceof HttpStatusException) { final HttpStatusException httpStatusException = (HttpStatusException) exception; switch (httpStatusException.getStatusCode()) { case HttpStatus.UNAUTHORIZED:{ environment.getRouter().forceLogout(getContext(), environment.getAnalyticsRegistry(), environment.getNotificationDelegate()); break; } } } else { logger.error(exception); } errorNotification.showError(getActivity(), exception, R.string.lbl_reload, new View.OnClickListener() { @Override public void onClick(View v) { if (NetworkUtil.isConnected(getContext())) { onRefresh(); } } }); } else if (result.getResult() != null) { ArrayList<EnrolledCoursesResponse> newItems = new ArrayList<EnrolledCoursesResponse>(result.getResult()); ((MyCoursesListActivity) getActivity()).updateDatabaseAfterDownload(newItems); if (result.getResult().size() > 0) { adapter.setItems(newItems); adapter.notifyDataSetChanged(); } if (adapter.isEmpty() && !environment.getConfig().getCourseDiscoveryConfig().isCourseDiscoveryEnabled()) { errorNotification.showError(R.string.no_courses_to_display, FontAwesomeIcons.fa_exclamation_circle, 0, null); binding.myCourseList.setVisibility(View.GONE); } else { binding.myCourseList.setVisibility(View.VISIBLE); errorNotification.hideError(); } } binding.swipeContainer.setRefreshing(false); binding.loadingIndicator.getRoot().setVisibility(View.GONE); isInitialServerCallDone = true; if (!(NetworkUtil.isConnected(getActivity()))) { onOffline(); } else { onOnline(); } }