private void getReviews() { IMovieProvider provider = new MovieProvider(); provider.getReviews( movie.Id, new ICallbackListener<ReviewResponse>() { @Override public void onComplete(ReviewResponse result) { if (result != null && result.Results != null && result.Results.size() > 0) { if (mReviewAdapter != null) { mReviewAdapter.setReviews(result.Results); mReviewAdapter.notifyDataSetChanged(); } else { mReviewAdapter = new ReviewAdapter(result.Results); } lvReviews.setAdapter(mReviewAdapter); tvReviews.setText(R.string.review); lvReviews.setVisibility(View.VISIBLE); } else { tvReviews.setText(R.string.noreviews); mReviewAdapter = new ReviewAdapter(new ArrayList<ReviewResponse.Review>()); lvReviews.setAdapter(mReviewAdapter); lvReviews.setVisibility(View.GONE); } } @Override public void onError(MovieException exception) { Toast.makeText(getActivity(), "Error getting reviews", Toast.LENGTH_LONG).show(); } }); }
private void getTrailers() { IMovieProvider provider = new MovieProvider(); provider.getMovieTrailer( movie.Id, new ICallbackListener<TrailerResponse>() { @Override public void onComplete(final TrailerResponse result) { if (result != null && result.Trailers != null && result.Trailers.size() > 0) { if (mTrailerAdapter != null) { mTrailerAdapter.setTrailers(result.Trailers); mTrailerAdapter.notifyDataSetChanged(); } else { mTrailerAdapter = new TrailerListAdapter(result.Trailers); } lvTrailers.setAdapter(mTrailerAdapter); tvTrailers.setText(R.string.trailers); if (shareMenuItem != null) { shareMenuItem.setVisible(true); } lvTrailers.setVisibility(View.VISIBLE); firstTrailer = result.Trailers.get(0); setShareIntent(); } else { tvTrailers.setText(R.string.notrailer); mTrailerAdapter = new TrailerListAdapter(new ArrayList<TrailerResponse.Trailer>()); lvTrailers.setAdapter(mTrailerAdapter); lvTrailers.setVisibility(View.GONE); if (shareMenuItem != null) { shareMenuItem.setVisible(false); } firstTrailer = null; } } @Override public void onError(MovieException exception) { Toast.makeText(getActivity(), "Error getting trailers", Toast.LENGTH_LONG).show(); } }); }