Android Open Source - doubanbook4android Book Adapter From Project Back to project page doubanbook4android .
License The source code is released under:
Eclipse Public License - v 1.0
THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC
LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM
CONSTITUTES RECI...
If you think the Android project doubanbook4android 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 com.study.doubanbook_for_android.adapter;
/ / w w w . j a v a 2 s . c o m
import java.util.ArrayList;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.study.doubanbook_for_android.R;
import com.study.doubanbook_for_android.imagedownloader.ImageDownloader;
import com.study.doubanbook_for_android.model.BookItem;
public class BookAdapter extends BaseAdapter {
private ArrayList<BookItem> books;
private Context context;
public BookAdapter(ArrayList<BookItem> books, Context context) {
super ();
this.books = books;
this.context = context;
}
@Override
public int getCount() {
return books.size();
// return 5;
}
@Override
public Object getItem(int position) {
return position;
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ImageDownloader imgDownloader = new ImageDownloader(context);
BookItem item = books.get(position);
ViewHolder holder = new ViewHolder();
if (convertView == null) {
convertView = LayoutInflater.from(context).inflate(
R.layout.i_bookserchlist, null);
holder.img = (ImageView) convertView.findViewById(R.id.bookImg_iv);
holder.title = (TextView) convertView
.findViewById(R.id.bookName_tv);
holder.author = (TextView) convertView
.findViewById(R.id.bookAuthor_tv);
holder.price = (TextView) convertView
.findViewById(R.id.bookPrice_tv);
holder.publisher = (TextView) convertView
.findViewById(R.id.bookPublisher_tv);
holder.grade = (TextView) convertView
.findViewById(R.id.bookGrade_tv);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
/* ?? */
holder.title.setText(item.getTitle());
holder.price.setText(item.getPrice());
holder.publisher.setText(item.getPublisher() + " " + item.getPubdate());
if (item.getRating() != null)
holder.grade.setText(item.getRating().getAverage() + "? "
+ item.getRating().getNumRaters() + "????" );
// TODO GET THE image's size DONE h:W =3:2,I name it by 7:5
imgDownloader.download(item.getImage(), holder.img, null);
StringBuffer stringBuffer = new StringBuffer();
for (String s : item.getAuthor()) {
stringBuffer.append(s);
stringBuffer.append(" " );
}
holder.author.setText(stringBuffer.toString());
return convertView;
}
static class ViewHolder {
ImageView img;
TextView title;
TextView author;
TextView price;
TextView publisher;
TextView grade;
}
}
Java Source Code List .UserListAdapter.java com.study.doubanbook_for_android.activity.BaseActivity.java com.study.doubanbook_for_android.activity.BaseP2RActivity.java com.study.doubanbook_for_android.activity.BookDetailActivity.java com.study.doubanbook_for_android.activity.BookListsActivity.java com.study.doubanbook_for_android.activity.BookNoteListActivity.java com.study.doubanbook_for_android.activity.CollectDetailActivity.java com.study.doubanbook_for_android.activity.NoteAndUserDetailActivity.java com.study.doubanbook_for_android.activity.SerchInputActivity.java com.study.doubanbook_for_android.activity.TextActivity1.java com.study.doubanbook_for_android.activity.UserDetailActivity.java com.study.doubanbook_for_android.activity.UserListActivity.java com.study.doubanbook_for_android.activity.UserNoteActivity.java com.study.doubanbook_for_android.adapter.BookAdapter.java com.study.doubanbook_for_android.adapter.CommentAdapter.java com.study.doubanbook_for_android.adapter.UserNoteAdapter.java com.study.doubanbook_for_android.api.NetUtils.java com.study.doubanbook_for_android.api.SSLSocketFactoryEx.java com.study.doubanbook_for_android.api.WrongMsg.java com.study.doubanbook_for_android.auth.AccessToken.java com.study.doubanbook_for_android.auth.DoubanDialogError.java com.study.doubanbook_for_android.auth.DoubanDialog.java com.study.doubanbook_for_android.auth.DoubanException.java com.study.doubanbook_for_android.auth.DoubanOAuthListener.java com.study.doubanbook_for_android.auth.DoubanParameters.java com.study.doubanbook_for_android.auth.DoubanRequest.java com.study.doubanbook_for_android.auth.Douban.java com.study.doubanbook_for_android.auth.KeepToken.java com.study.doubanbook_for_android.auth.SimpleDoubanOAuthListener.java com.study.doubanbook_for_android.auth.Token.java com.study.doubanbook_for_android.business.DoubanBusiness.java com.study.doubanbook_for_android.callback.AsynCallback.java com.study.doubanbook_for_android.imagedownloader.FileCache.java com.study.doubanbook_for_android.imagedownloader.INetImageDownloader.java com.study.doubanbook_for_android.imagedownloader.ImageCache.java com.study.doubanbook_for_android.imagedownloader.ImageDownloaderListener.java com.study.doubanbook_for_android.imagedownloader.ImageDownloader.java com.study.doubanbook_for_android.model.Annotations.java com.study.doubanbook_for_android.model.AuthorUser.java com.study.doubanbook_for_android.model.BookItem.java com.study.doubanbook_for_android.model.CollectBookMsg.java com.study.doubanbook_for_android.model.CollectSuccessResult.java com.study.doubanbook_for_android.model.CommentItem.java com.study.doubanbook_for_android.model.Comment.java com.study.doubanbook_for_android.model.CurrenUserCollection.java com.study.doubanbook_for_android.model.GeneralNoteResult.java com.study.doubanbook_for_android.model.GeneralResult.java com.study.doubanbook_for_android.model.GeneralUserResult.java com.study.doubanbook_for_android.model.ImageItem.java com.study.doubanbook_for_android.model.Rating.java com.study.doubanbook_for_android.model.RequestGrantScope.java com.study.doubanbook_for_android.model.TagItem.java com.study.doubanbook_for_android.model.URLMananeger.java com.study.doubanbook_for_android.utils.EncodeUtils.java com.study.doubanbook_for_android.utils.JsonParser.java com.study.doubanbook_for_android.utils.JsonUtil.java com.study.doubanbook_for_android.utils.UriUtils.java