@OnClick(R.id.fab) public void onSaveClicked() { try { if (isMovieAlreadyFavorited()) { // long cursorId = c.getLong(0); getActivity() .getContentResolver() .delete( FavoriteContentProvider.Favorites.CONTENT_URI, FavoriteColumns.COLUMN_NAME_MOVIEID + "= ?", new String[] {String.valueOf(movie.Id)}); fab.setImageDrawable(getResources().getDrawable(R.drawable.ic_unfav)); if (mListener != null) { mListener.onMovieRemoved(movie); } } else { getActivity() .getContentResolver() .insert(FavoriteContentProvider.Favorites.CONTENT_URI, movie.toContentValues()); fab.setImageDrawable(getResources().getDrawable(R.drawable.ic_fav)); if (mListener != null) { mListener.onMovieAdded(movie); } } } catch (Exception e) { // TODO log or send details to remote server new MovieException(getString(R.string.error_save)).showToast(Toast.LENGTH_LONG); } }
public void bind() { if (movie != null) { if (movie.PosterPath != null && movie.PosterPath != "" && ivMoviePoster != null) { Picasso.with(getActivity()) .load(movie.getThumbnailUrl("w342")) .transform(transformation) .into(ivMoviePoster); } double roundOff = Math.round(movie.Popularity * 100.0) / 100.0; tvPopularity.setText(roundOff + "%"); tvTitle.setText(movie.Title); tvAverage.setText(movie.VoteAvg + ""); tvOverView.setText(movie.OverView); tvReleaseDate.setText(movie.ReleaseDate); if (isMovieAlreadyFavorited()) { fab.setImageDrawable(getResources().getDrawable(R.drawable.ic_fav)); } else { fab.setImageDrawable(getResources().getDrawable(R.drawable.ic_unfav)); } // get reviews getReviews(); getTrailers(); } }