@Override public void onReceiveResult(int resultCode, Bundle resultData) { switch (resultCode) { case DownloadService.STATUS_RUNNING: Logger.log("download_service", "STATUS_RUNNING"); break; case DownloadService.STATUS_FINISHED: /* Hide progress & extract result from bundle */ List<Film> downFilms = resultData.getParcelableArrayList("films"); ((App) getActivity().getApplicationContext()).downloadedFilms = downFilms; setFilms(downFilms); /* Update ListView with result */ Logger.log("download_service", "STATUS_FINISHED"); break; case DownloadService.STATUS_ERROR: /* Handle the error */ String error = resultData.getString(Intent.EXTRA_TEXT); if (getActivity() != null) { Toast.makeText(getActivity(), R.string.download_error, Toast.LENGTH_LONG).show(); } Logger.log("download_service", "STATUS_ERROR: " + error); break; } }
private void setFilms(List<Film> films) { Logger.log("favourite", "setFilms"); mFilms.clear(); if (!films.isEmpty()) { mFilms.addAll(films); } if (mGridView != null) { mFilmAdapter.notifyDataSetChanged(); } // tablet if (mFragmentFilmDetail != null && !mFilms.isEmpty()) { Logger.log("film_list", "setting fragment detail (tablet)"); mFragmentFilmDetail.setFilm(mFilms.get(0)); mFragmentFilmDetail.refreshLayout(); } }