@Override
    public View getView(int i, View convertView, ViewGroup viewGroup) {

      View view;

      if (convertView == null) {
        LayoutInflater inflater = getActivity().getLayoutInflater();
        view = inflater.inflate(R.layout.trailer_gridview_item, viewGroup, false);

      } else {
        view = convertView;
      }

      TrailerData trailerData = mTrailerDataList.get(i);
      final String youtubeId = trailerData.getKey();

      // The thumbnail image of the trailer on Youtube
      ImageView thumbnailImage = (ImageView) view.findViewById(R.id.trailer_thumbnail_image);
      String thumbnailImageUrl = MovieUtils.getTrailerYoutubeImageUrl(youtubeId);
      Glide.with(getActivity()).load(thumbnailImageUrl).into(thumbnailImage);

      // The title of trailer textView
      TextView trailerTitle = (TextView) view.findViewById(R.id.trailer_thumbnail_title);
      trailerTitle.setText(trailerData.getName());

      // Click event to create the intent to show the trailer using the youtube url
      String youtubeVideoUrl = MovieUtils.getTrailerYoutubeUrl(youtubeId);
      view.setTag(youtubeVideoUrl);
      view.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View view) {
              Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse((String) view.getTag()));
              startActivity(intent);
            }
          });

      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;
  }