@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { mMenu = menu; if (!appState.getTwoPane()) { Utility.makeMenuItemInvisible(mMenu, R.id.action_settings); // for crate home button AppCompatActivity activity = (AppCompatActivity) getActivity(); activity.getSupportActionBar().setDisplayHomeAsUpEnabled(true); activity.getSupportActionBar().setTitle("MovieDetail"); } else { AppCompatActivity activity = (AppCompatActivity) getActivity(); activity.getSupportActionBar().setTitle("Pop Movies"); } shareMenuItem = menu.findItem(R.id.action_share); mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(shareMenuItem); }
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor data) { Uri uri = ((CursorLoader) loader).getUri(); if (!data.moveToFirst()) data = null; int match = sUriMatcher.match(uri); switch (match) { case MovieProvider.MOVIE_WITH_ID: mMovieAdapter.swapCursor(data); Log.v(LOG_TAG, "In onLoadFinished Movie "); if (!movieDetailsModified.get()) { if (data == null || !data.moveToFirst()) { Toast.makeText( getContext(), "No Data Loaded. Please go back and select movie again", Toast.LENGTH_LONG) .show(); getActivity().onBackPressed(); return; } mMovieData = SerializationUtils.deserialize(data.getBlob(1)); movieRowId = data.getLong(MovieQuery.COL_MOVIEID); mMovieId = mMovieData.id; title = mMovieData.original_title; Log.v(LOG_TAG, "Movie Title = " + title); ((TextView) rootView.findViewById(R.id.title_text)).setText(title); ImageView imageView = (ImageView) rootView.findViewById(R.id.imageView); Picasso.with(getContext()) .load(String.format(sImgUrl, sImgSize, mMovieData.poster_path)) .error(R.drawable.abc_btn_rating_star_off_mtrl_alpha) // .fit() .into(imageView); if (data.getInt(3) <= 0) movieMinutesModified.set(false); else { movieMinutesModified.set(true); ((TextView) rootView.findViewById(R.id.runtime_text)) .setText(Integer.toString(data.getInt(MovieQuery.COL_MOVIE_RUNTIME)) + "min"); } String mMovieVoteAverage = Double.toString(mMovieData.vote_average); ((TextView) rootView.findViewById(R.id.voteaverage_text)) .setText(mMovieVoteAverage + "/10"); Float f = Float.parseFloat(mMovieVoteAverage); ((RatingBar) rootView.findViewById(R.id.ratingBar)).setRating(f); ((TextView) rootView.findViewById(R.id.release_text)) .setText(Utility.getYear(mMovieData.release_date)); btnToggle = (Button) rootView.findViewById(R.id.chkState); if (data.getInt(MovieQuery.COL_MOVIE_FAVOURITE) != 0) btnToggle.setText("Favourite"); else btnToggle.setText("Mark as Favourite"); ((TextView) rootView.findViewById(R.id.overview_text)).setText(mMovieData.overview); movieDetailsModified.set(true); if (!movieMinutesModified.get()) { updateMinutesDataOrAskServer(data); } Log.v(LOG_TAG, "Out of Load Finish Movie"); } break; case MovieProvider.MOVIE_TRAILERS: Log.v(LOG_TAG, "In Trailer load finish loader"); if (!trailerDataModified.get()) updateTrailerDataOrAskServer(data); Log.v(LOG_TAG, "out Trailer load finish loader"); break; case MovieProvider.MOVIE_REVIEWS: Log.v(LOG_TAG, "In Review load finish loader"); if (!reviewDataModified.get()) updateReviewDataOrAskServer(data); Log.v(LOG_TAG, "out Review load finish loader"); break; } }