diff options
Diffstat (limited to 'android/src/com/artifex/mupdfdemo/MuPDFReflowAdapter.java')
-rw-r--r-- | android/src/com/artifex/mupdfdemo/MuPDFReflowAdapter.java | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/android/src/com/artifex/mupdfdemo/MuPDFReflowAdapter.java b/android/src/com/artifex/mupdfdemo/MuPDFReflowAdapter.java new file mode 100644 index 00000000..5e90be92 --- /dev/null +++ b/android/src/com/artifex/mupdfdemo/MuPDFReflowAdapter.java @@ -0,0 +1,46 @@ +package com.artifex.mupdfdemo; + +import android.content.Context; +import android.graphics.Point; +import android.graphics.PointF; +import android.view.View; +import android.view.ViewGroup; +import android.widget.BaseAdapter; + +public class MuPDFReflowAdapter extends BaseAdapter { + private final Context mContext; + private final MuPDFCore mCore; + + public MuPDFReflowAdapter(Context c, MuPDFCore core) { + mContext = c; + mCore = core; + } + + public int getCount() { + return mCore.countPages(); + } + + public Object getItem(int arg0) { + return null; + } + + public long getItemId(int arg0) { + return 0; + } + + public View getView(int position, View convertView, ViewGroup parent) { + final MuPDFReflowView reflowView; + // Should reuse old views if possible, but WebViews seem to refuse to + // decrease height even when new content is loaded, so create a new view + // each time as a workaround + if (true || convertView == null) { + reflowView = new MuPDFReflowView(mContext, mCore, new Point(parent.getWidth(), parent.getHeight())); + } else { + reflowView = (MuPDFReflowView) convertView; + } + + reflowView.setPage(position, new PointF()); + + return reflowView; + } +} |