Java 类com.parse.CountCallback 实例源码

项目:Fitness-Buddy-Group-Project    文件:TrainerListAdapter.java   
private void setNumReviews(TrainerViewHolder holder, Trainer trainer) {
    final TextView tvNumReviews = holder.tvNumReviews;
    ParseQuery<ParseObject> query = ParseQuery.getQuery("Review");
    query.whereEqualTo("reviewee", trainer);
    query.countInBackground(new CountCallback() {
        public void done(int count, ParseException e) {
            if (e == null) {
                Log.d("DEBUG", "Number of reviews: " + count);
                if (count == 1) {
                    tvNumReviews.setText(count + " Review");
                } else {
                    tvNumReviews.setText(count + " Reviews");
                }
            } else {
                Log.d("DEBUG", "Failed to get number of reviews");
            }
        }
    });
}