private View getReviewPageView(ViewGroup container) { final View view = getActivity().getLayoutInflater().inflate(R.layout.review_page, container, false); int movieId = getArguments().getInt(MovieDetailActivity.MOVIE_ID); Call<ReviewDatas> call = MyMovieDbApi.getInstance().getMoviesReviewsDatas(movieId, Constants.MOVIEDB_API_KEY); call.enqueue( new Callback<ReviewDatas>() { @Override public void onResponse(Response<ReviewDatas> response, Retrofit retrofit) { ReviewDatas data = response.body(); List<ReviewData> reviewDatas = data.getReviewDatas(); if (reviewDatas.size() > 0) { ListView reviewListView = (ListView) view.findViewById(R.id.review_list); reviewListView.setAdapter(new ReviewAdapter(getActivity(), reviewDatas)); } else { TextView noReviewTextView = (TextView) view.findViewById(R.id.no_review_textview); noReviewTextView.setVisibility(View.VISIBLE); } } @Override public void onFailure(Throwable t) {} }); return view; }
/** * Create the component views of the detail page * * @param container * @return the view of the detail page */ public View getDetailPageView(ViewGroup container) { final View view = getActivity().getLayoutInflater().inflate(R.layout.movie_detail_page, container, false); int movieId = getArguments().getInt(MovieDetailActivity.MOVIE_ID); Result movieData = FetchedMovieData.getInstance().getMovieDataByMovieId(movieId); if (movieData != null) { // The title TextView TextView titleTextView = (TextView) view.findViewById(R.id.movie_title_detail); titleTextView.setText(movieData.getOriginalTitle()); // Rating bar RatingBar ratingBar = (RatingBar) view.findViewById(R.id.rating_bar); ratingBar.setRating(movieData.getVoteAverage()); // The poster ImageView ImageView posterImageView = (ImageView) view.findViewById(R.id.poster_detail); String imageUrl = MovieUtils.getPosterUrl( getResources().getInteger(R.integer.thumbnail_poster_width), movieData.getPosterPath()); Glide.with(getActivity()) .load(imageUrl) .diskCacheStrategy(DiskCacheStrategy.ALL) .into(posterImageView); // The release date TextView TextView dateReleaseTextView = (TextView) view.findViewById(R.id.movie_release_date_detail); Date releaseDate; try { releaseDate = new SimpleDateFormat("yyyy-MM-dd").parse(movieData.getReleaseDate()); String formattedDateString = new SimpleDateFormat("MMM yyy").format(releaseDate); dateReleaseTextView.setText(formattedDateString); } catch (ParseException e) { e.printStackTrace(); } // The description TextView TextView descriptionTextView = (TextView) view.findViewById(R.id.movie_description_detail); descriptionTextView.setText(movieData.getOverview()); /** The trailer part */ // Request the trailer data by querying through themoviedb.org API Call<TrailerDatas> call = MyMovieDbApi.getInstance().getMoviesTrailerDatas(movieId, Constants.MOVIEDB_API_KEY); call.enqueue( new Callback<TrailerDatas>() { @Override public void onResponse(Response<TrailerDatas> response, Retrofit retrofit) { TrailerDatas data = response.body(); List<TrailerData> trailerDataList = data.getTrailerDatas(); FullHeightGridView trailerGridView = (FullHeightGridView) view.findViewById(R.id.gridview_trailer); trailerGridView.setAdapter(new TrailerAdapter(trailerDataList)); } @Override public void onFailure(Throwable t) {} }); } return view; }