Android Open Source - PDF2ImageForEP Mu P D F Page Adapter






From Project

Back to project page PDF2ImageForEP.

License

The source code is released under:

GNU General Public License

If you think the Android project PDF2ImageForEP 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.artifex.mupdf;
/* ww w .  j a v  a  2s .com*/
import android.content.Context;
import android.graphics.Point;
import android.graphics.PointF;
import android.util.SparseArray;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

public class MuPDFPageAdapter extends BaseAdapter {
  private final Context mContext;
  private final MuPDFCore mCore;
  private final SparseArray<PointF> mPageSizes = new SparseArray<PointF>();

  public MuPDFPageAdapter(Context c, MuPDFCore core) {
    mContext = c;
    mCore = core;
  }

  public int getCount() {
    return mCore.countPages();
  }

  public Object getItem(int position) {
    return null;
  }

  public long getItemId(int position) {
    return 0;
  }

  public View getView(final int position, View convertView, ViewGroup parent) {
    final MuPDFPageView pageView;
    if (convertView == null) {
      pageView = new MuPDFPageView(mContext, mCore, new Point(parent.getWidth(), parent.getHeight()));
    } else {
      pageView = (MuPDFPageView) convertView;
    }

    PointF pageSize = mPageSizes.get(position);
    if (pageSize != null) {
      // We already know the page size. Set it up
      // immediately
      pageView.setPage(position, pageSize);
    } else {
      // Page size as yet unknown. Blank it for now, and
      // start a background task to find the size
      pageView.blank(position);
      SafeAsyncTask<Void,Void,PointF> sizingTask = new SafeAsyncTask<Void,Void,PointF>() {
        @Override
        protected PointF doInBackground(Void... arg0) {
          return mCore.getPageSize(position);
        }

        @Override
        protected void onPostExecute(PointF result) {
          super.onPostExecute(result);
          // We now know the page size
          mPageSizes.put(position, result);
          // Check that this view hasn't been reused for
          // another page since we started
          if (pageView.getPage() == position)
            pageView.setPage(position, result);
        }
      };

      sizingTask.safeExecute((Void)null);
    }
    return pageView;
  }
}




Java Source Code List

com.artifex.mupdf.ChoosePDFActivity.java
com.artifex.mupdf.LinkInfo.java
com.artifex.mupdf.MuPDFActivity.java
com.artifex.mupdf.MuPDFCore.java
com.artifex.mupdf.MuPDFPageAdapter.java
com.artifex.mupdf.MuPDFPageView.java
com.artifex.mupdf.OutlineActivityData.java
com.artifex.mupdf.OutlineActivity.java
com.artifex.mupdf.OutlineAdapter.java
com.artifex.mupdf.OutlineItem.java
com.artifex.mupdf.PageView.java
com.artifex.mupdf.ReaderView.java
com.artifex.mupdf.SafeAsyncTask.java
com.artifex.mupdf.SearchTaskResult.java
jp.co.muratec.pdf2image.DeepRadioGroup.java
jp.co.muratec.pdf2image.FilerActivity.java
jp.co.muratec.pdf2image.LoadLibrary.java
jp.co.muratec.pdf2image.PDF2ImageActivity.java
jp.co.muratec.pdf2image.PDF2ImageService.java