Android Open Source - AndroidMooch Book List Adapter






From Project

Back to project page AndroidMooch.

License

The source code is released under:

Copyright (c) 2010 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software witho...

If you think the Android project AndroidMooch 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.github.stchris.models;
/*from  ww w.j  a  va 2  s .c om*/
import android.content.Context;
import android.graphics.Bitmap;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.github.stchris.R;
import com.github.stchris.util.Util;

public class BookListAdapter extends BaseAdapter {

  private Book[] books;
  private Context context;

  public BookListAdapter(Context context, Book[] books) {
    this.context = context;
    this.books = books;
  }

  public int getCount() {
    return books.length;
  }

  public Object getItem(int pos) {
    return books[pos];
  }

  public long getItemId(int pos) {
    return pos;
  }

  public View getView(int position, View convertView, ViewGroup parent) {
    final Book book = books[position];
    RelativeLayout rowLayout = null;
    if (convertView == null) {
      rowLayout = (RelativeLayout) LayoutInflater.from(context).inflate(
          R.layout.booklistview, parent, false);
      TextView tv = (TextView) rowLayout.findViewById(R.id.tvBookListAuthor);
      tv.setText(book.author);
      tv = (TextView) rowLayout.findViewById(R.id.tvBookListTitle);
      tv.setText(book.title);
      ImageView img = (ImageView) rowLayout.findViewById(R.id.imgBookList);
      Bitmap bmp = Util.loadBitmap(book.smallImgUrl);
      if (bmp != null) {
        img.setImageBitmap(bmp);
      };
    } else {
      rowLayout = (RelativeLayout) convertView;
    }
    return rowLayout;
  }

}




Java Source Code List

com.github.stchris.activities.BookInfoActivity.java
com.github.stchris.activities.BookSearchActivity.java
com.github.stchris.activities.BookSearchListActivity.java
com.github.stchris.activities.InventoryActivity.java
com.github.stchris.activities.MainActivity.java
com.github.stchris.activities.ShowImageActivity.java
com.github.stchris.activities.WishlistActivity.java
com.github.stchris.models.BookListAdapter.java
com.github.stchris.models.Book.java
com.github.stchris.queries.Constants.java
com.github.stchris.util.JSONUtil.java
com.github.stchris.util.Util.java
com.github.stchris.views.BookListView.java