If you think the Android project AndroidPlaces listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
/*
* Copyright (C) 2014 Brian Lee//fromwww.java2s.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/package com.tigerpenguin.demo.places;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import com.tigerpenguin.places.model.Review;
import com.tigerpenguin.widget.simpleratingbar.SimpleRatingBar;
import java.util.ArrayList;
publicclass PlaceReviewAdapter extends ArrayAdapter<Review> {
public PlaceReviewAdapter(Context context) {
super(context, R.layout.place_review_item, new ArrayList<Review>());
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
LayoutInflater inflater = LayoutInflater.from(getContext());
convertView = inflater.inflate(R.layout.place_review_item, parent, false);
convertView.setTag(new ReviewViewHolder(convertView));
}
ReviewViewHolder reviewViewHolder = (ReviewViewHolder) convertView.getTag();
Review review = getItem(position);
if (review.getAuthorName() != null) {
reviewViewHolder.authorName.setVisibility(View.VISIBLE);
reviewViewHolder.authorName.setText(review.getAuthorName());
} else {
reviewViewHolder.authorName.setVisibility(View.GONE);
}
reviewViewHolder.rating.setRating(review.getRating());
if (review.getText() != null) {
reviewViewHolder.review.setVisibility(View.VISIBLE);
reviewViewHolder.review.setText(review.getText());
} else {
reviewViewHolder.review.setVisibility(View.GONE);
}
return convertView;
}
privatestaticclass ReviewViewHolder {
final TextView authorName, review;
final SimpleRatingBar rating;
ReviewViewHolder(View view) {
authorName = (TextView) view.findViewById(R.id.authorName);
rating = (SimpleRatingBar) view.findViewById(R.id.rating);
review = (TextView) view.findViewById(R.id.review);
}
}
}