Android Open Source - Book-MetaSearch Search Result Adapter From Project Back to project page Book-MetaSearch .
License The source code is released under:
Apache License
If you think the Android project Book-MetaSearch 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 package net.grosinger.bookmetasearch.search;
/ / w w w . j a v a 2 s . c o m
import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.RatingBar;
import android.widget.TextView;
import net.grosinger.bookmetasearch.R;
import net.grosinger.bookmetasearch.book.Book;
import java.util.ArrayList;
import java.util.List;
/**
* Created by tony on 11/2/13.
*/
public class SearchResultAdapter extends BaseAdapter {
private List<Book> results;
private LayoutInflater mInflater;
public SearchResultAdapter(Context context, List<Book> results) {
if (results != null) {
this.results = results;
} else {
this.results = new ArrayList<Book>();
}
Log.d(getClass().getSimpleName(), "Creating adapter with array size " + this.results.size());
mInflater = LayoutInflater.from(context);
}
@Override
public int getCount() {
return results.size();
}
@Override
public Object getItem(int i) {
return results.get(i);
}
@Override
public long getItemId(int position) {
return position;
}
public void clear() {
results = null;
}
public void addAll(List<Book> results) {
Log.d(getClass().getSimpleName(), "Updating adapter results to size " + results.size());
this.results = results;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
Log.d(getClass().getSimpleName(), "Building view from results" );
ViewHolder holder;
if (convertView == null) {
convertView = mInflater.inflate(R.layout.search_result_item, null);
holder = new ViewHolder();
holder.txtBookName = (TextView) convertView.findViewById(R.id.textView_bookName);
holder.txtAuthorName = (TextView) convertView.findViewById(R.id.textView_authorName);
holder.rating = (RatingBar) convertView.findViewById(R.id.ratingBar_bookRating);
holder.largeImg = (ImageView) convertView.findViewById(R.id.imageView_coverImg);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
Book currentResult = results.get(position);
Log.d(getClass().getSimpleName(), "Current book: " + currentResult);
holder.txtBookName.setText(currentResult.getTitle());
holder.txtAuthorName.setText(currentResult.getAuthor().getName());
holder.rating.setRating((float ) currentResult.getAvg_rating());
currentResult.getImageAsync(holder.largeImg);
return convertView;
}
static class ViewHolder {
TextView txtBookName;
TextView txtAuthorName;
RatingBar rating;
ImageView largeImg;
}
}
Java Source Code List com.ECS.client.jax.Accessories.java com.ECS.client.jax.Arguments.java com.ECS.client.jax.BrowseNode.java com.ECS.client.jax.BrowseNodes.java com.ECS.client.jax.Collections.java com.ECS.client.jax.CustomerReviews.java com.ECS.client.jax.DecimalWithUnits.java com.ECS.client.jax.EditorialReview.java com.ECS.client.jax.EditorialReviews.java com.ECS.client.jax.Errors.java com.ECS.client.jax.ImageSet.java com.ECS.client.jax.Image.java com.ECS.client.jax.ItemAttributes.java com.ECS.client.jax.ItemLink.java com.ECS.client.jax.ItemLinks.java com.ECS.client.jax.Item.java com.ECS.client.jax.LoyaltyPoints.java com.ECS.client.jax.Merchant.java com.ECS.client.jax.NewReleases.java com.ECS.client.jax.NonNegativeIntegerWithUnits.java com.ECS.client.jax.OfferAttributes.java com.ECS.client.jax.OfferListing.java com.ECS.client.jax.OfferSummary.java com.ECS.client.jax.Offer.java com.ECS.client.jax.Offers.java com.ECS.client.jax.Price.java com.ECS.client.jax.Promotion.java com.ECS.client.jax.Promotions.java com.ECS.client.jax.Property.java com.ECS.client.jax.RelatedItem.java com.ECS.client.jax.RelatedItems.java com.ECS.client.jax.SimilarProducts.java com.ECS.client.jax.TopItemSet.java com.ECS.client.jax.TopSellers.java com.ECS.client.jax.Tracks.java com.ECS.client.jax.VariationAttribute.java com.ECS.client.jax.VariationDimensions.java com.ECS.client.jax.VariationSummary.java com.ECS.client.jax.Variations.java net.grosinger.bookmetasearch.BookDetail.java net.grosinger.bookmetasearch.BookInventoryAdapter.java net.grosinger.bookmetasearch.Home.java net.grosinger.bookmetasearch.SearchActivity.java net.grosinger.bookmetasearch.book.Author.java net.grosinger.bookmetasearch.book.Book.java net.grosinger.bookmetasearch.book.provider.BookProvider.java net.grosinger.bookmetasearch.book.provider.LibraryBookProvider.java net.grosinger.bookmetasearch.book.provider.RetailBookProvider.java net.grosinger.bookmetasearch.fragment.DetailFragment.java net.grosinger.bookmetasearch.fragment.HomeFragment.java net.grosinger.bookmetasearch.fragment.SearchResultsFragment.java net.grosinger.bookmetasearch.inventory.AvailableBook.java net.grosinger.bookmetasearch.inventory.InventoryHeader.java net.grosinger.bookmetasearch.inventory.InventoryListItem.java net.grosinger.bookmetasearch.loader.AmazonQuery.java net.grosinger.bookmetasearch.loader.AsyncImageLoader.java net.grosinger.bookmetasearch.loader.GoodreadsQuery.java net.grosinger.bookmetasearch.loader.GoogleQuery.java net.grosinger.bookmetasearch.loader.InventoryLoader.java net.grosinger.bookmetasearch.loader.InventoryQuery.java net.grosinger.bookmetasearch.loader.ProductLoader.java net.grosinger.bookmetasearch.loader.ProductQuery.java net.grosinger.bookmetasearch.search.RecentBookSearchSuggestionsProvider.java net.grosinger.bookmetasearch.search.SearchResultAdapter.java