@Nullable @Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Bind view with id View view = inflater.inflate(R.layout.detail_movie_fragment, container, false); titleView = (TextView) view.findViewById(R.id.title); releaseYearView = (TextView) view.findViewById(R.id.release_year); scoreView = (TextView) view.findViewById(R.id.score); overviewView = (TextView) view.findViewById(R.id.overview); imagePoster = (ImageView) view.findViewById(R.id.image); insertTrailerPoint = (ViewGroup) view.findViewById(R.id.insert_trailer_point); insertReviewPoint = (ViewGroup) view.findViewById(R.id.insert_review_point); trailerVideo = new ArrayList<>(); reviewsList = new ArrayList<>(); // Parse json movie from intent extra Gson gson = new Gson(); String jsonMovie = getArguments().getString("movie"); Movie movie = gson.fromJson(jsonMovie, Movie.class); // Set text and source picture. titleView.setText(movie.getTitle()); releaseYearView.setText(movie.getRelease_date()); scoreView.setText(movie.getscore() + "/10"); String url = "http://image.tmdb.org/t/p/w185/" + movie.getimage_path(); Picasso.with(getActivity()).load(url).into(imagePoster); overviewView.setText(movie.getOverview()); // Start new thread FetchTrailerTask task = new FetchTrailerTask(); task.execute(movie.getId()); return view; }
@TargetApi(Build.VERSION_CODES.KITKAT) @Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_movie_description, container, false); // Pull data from the intent passed from MainAcitivy Bundle b = getActivity().getIntent().getExtras(); // Get the Movie object from the Bundle Movie movie = b.getParcelable("MOVIE"); /* Test (and log results) to see if the movie object was successfully passed to the movie description fragment before loading content into the rootview. */ if (movie == null) { Log.v("THIS MOVIE: ", "IS <----- EMPTY ------"); } else { Log.v("THIS MOVIE BACK: ", movie.getBackdrop_path()); Log.v("BACKDROP PATH: ", movie.getBackdrop_path()); // Loading the backdrop image String checker = "empty"; ImageView image2 = (ImageView) rootView.findViewById(R.id.imageView); if (Objects.equals(movie.getBackdrop_path(), checker)) { Picasso.with(getActivity()).load(R.drawable.ic_insert_photo_black_24dp).into(image2); } else { Picasso.with(getActivity()).load(movie.getBackdrop_path()).into(image2); } // Loading the movie poster image ImageView image = (ImageView) rootView.findViewById(R.id.descImageView); if (Objects.equals(movie.getPoster_path(), checker)) { Picasso.with(getActivity()).load(R.drawable.ic_insert_photo_black_24dp).into(image); } else { Picasso.with(getActivity()).load(movie.getPoster_path()).into(image); } // Loading movie description ((TextView) rootView.findViewById(R.id.textView)).setText(movie.getDescription()); // Loading movie title ((TextView) rootView.findViewById(R.id.textView2)).setText(movie.getTitle()); // Loading movie rating ((TextView) rootView.findViewById(R.id.textView4)) .setText("Rating: " + movie.getVote_average()); // Loading movie release date ((TextView) rootView.findViewById(R.id.textView3)) .setText("Release date: " + movie.getRelease_date().toString()); } return rootView; }
@Override public View getView(int position, View convertView, ViewGroup parent) { View view = convertView; holder = new ViewHolder(); if (view == null) { LayoutInflater vi = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); view = vi.inflate(R.layout.movie_item, parent, false); holder.poster = (ImageView) view.findViewById(R.id.poster); holder.title = (TextView) view.findViewById(R.id.title); holder.rating = (TextView) view.findViewById(R.id.rating); holder.critics_consensus = (TextView) view.findViewById(R.id.critics_consensus); holder.release_date = (TextView) view.findViewById(R.id.release_date); holder.rated = (TextView) view.findViewById(R.id.rated); holder.synopsis = (TextView) view.findViewById(R.id.synopsis); holder.year = (TextView) view.findViewById(R.id.year); holder.runtime = (TextView) view.findViewById(R.id.runtime); view.setTag(holder); } else { holder = (ViewHolder) view.getTag(); } Movie movie = movieData.get(position); if (movie != null) { Typeface typeface = Typeface.createFromAsset(getContext().getAssets(), "fonts/robotocondensed-bold.ttf"); holder.rating.setTypeface(typeface); holder.rating.setText("Rating: " + movie.getRating()); holder.title.setText("Title: " + movie.getTitle()); holder.title.setTag(movie.getTitle()); Log.i("TAG", "" + holder.title.getTag()); holder.poster.setImageBitmap(null); holder.critics_consensus.setText("consensus: " + movie.getCritics_consensus()); holder.release_date.setText("date: " + movie.getRelease_date()); holder.rated.setText("rated: " + movie.getRated()); holder.synopsis.setText("synopsis: " + movie.getSynopsis()); holder.year.setText("year: " + movie.getYear()); holder.runtime.setText("runtime: " + movie.getRuntime()); if (!movie.getPoster().equals("not found")) { new DownloadTask(holder, movie, manage).execute(movie.getPoster()); } } return view; }