use of com.hackvg.model.entities.Review in project Material-Movies by saulmm.
the class MovieDetailActivity method showReviews.
/**
* Creates a TextView with a Spannable format programmatically
* containing the author by whom was the review written and the
* review text
*
* @param reviewList a list containing reviews of the film
*/
@Override
public void showReviews(List<Review> reviewList) {
final int reviewMarginTop = getResources().getDimensionPixelOffset(R.dimen.activity_vertical_margin_half);
final LayoutParams layoutParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
layoutParams.setMargins(0, reviewMarginTop, 0, 0);
movieHeaders.get(REVIEWS_HEADER).setVisibility(View.VISIBLE);
for (Review result : reviewList) {
// Creates a TextView
TextView reviewTextView = new TextView(this);
reviewTextView.setTextAppearance(this, R.style.MaterialMoviesReviewTextView);
if (mReviewsColor != -1)
reviewTextView.setTextColor(mReviewsColor);
// Configure the review text
String reviewCredit = "Review written by " + result.getAuthor();
String reviewText = String.format("%s - %s", reviewCredit, result.getContent());
Spannable spanColorString = new SpannableString(reviewText);
spanColorString.setSpan(new ForegroundColorSpan(mReviewsAuthorColor), 0, reviewCredit.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
reviewTextView.setText(spanColorString);
mMovieDescriptionContainer.addView(reviewTextView, layoutParams);
}
}
Aggregations