Android Open Source - PictureBookReader Recent G Books Adapter

From Project

Back to project page PictureBookReader.


The source code is released under:

GNU General Public License

If you think the Android project PictureBookReader 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.uyghurdev.avaroid.picturebookreader;
/*from w  w  w  .j  av  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.RelativeLayout;
import android.widget.RelativeLayout.LayoutParams;

public class RecentGBooksAdapter extends BaseAdapter {
  private Activity activity;
  private ArrayList<File> map;
  private LayoutInflater inflater;

private int _wt, _ht;

  public RecentGBooksAdapter(Activity a, ArrayList<File> books,int wt, int ht) {

    activity = a;
    map = books;
    inflater = (LayoutInflater) activity
    _wt = wt;

  public int getCount() {
    // TODO Auto-generated method stub
    return map.size();

  public Object getItem(int arg0) {
    // TODO Auto-generated method stub
    return map.get(arg0);


  public long getItemId(int position) {
    // TODO Auto-generated method stub
    return position;

  public View getView(int position, View convertView, ViewGroup parent) {
    // TODO Auto-generated method stub

    View vi = convertView;
    if (convertView == null) {
      vi = inflater.inflate(R.layout.local_book, null);
    RelativeLayout imagerelative=new RelativeLayout(activity);
    ImageView img=new ImageView(activity);
    RelativeLayout rLayout = (RelativeLayout) vi
    //int width=localbook.wt;
    RelativeLayout.LayoutParams lpl = new  RelativeLayout.LayoutParams(
        _wt, _ht);//((int) (_wt*(1.3))));
    RelativeLayout.LayoutParams lpi = new  RelativeLayout.LayoutParams(
        LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
    lpi.setMargins(13, 15, 15, 10);
    lpl.setMargins(4, 2, 4, 0);
    imagerelative.addView(img, lpi);
    rLayout.addView(imagerelative, lpl);

    DecompressReader dr;
    Bitmap b = null;
    try {
      dr = new DecompressReader(map.get(position).getPath());
      b = dr.getCover();

    } catch (IOException e) {
      // TODO Auto-generated catch block


    if (b != null) {
    } else {

    return vi;


Java Source Code List