summaryrefslogtreecommitdiff
path: root/platform/android/src/com/artifex/mupdfdemo/MuPDFReflowAdapter.java
blob: 48625a7e49d5bb877b98b8bbd8a02345acb1dfd1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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;
		if (convertView == null) {
			reflowView = new MuPDFReflowView(mContext, mCore, new Point(parent.getWidth(), parent.getHeight()));
		} else {
			reflowView = (MuPDFReflowView) convertView;
		}

		reflowView.setPage(position, new PointF());

		return reflowView;
	}
}