diff options
author | Paul Gardiner <paulg.artifex@glidos.net> | 2013-02-02 11:36:48 +0000 |
---|---|---|
committer | Paul Gardiner <paulg.artifex@glidos.net> | 2013-02-02 11:36:48 +0000 |
commit | ef66c129e2451d4d929c21339fa6c36f9ece1a37 (patch) | |
tree | eddb545b96ce2ace05d178cbbb8c4fe4018e94ef /android | |
parent | 05d8a59af925b23a8d05c7ec95dcd9bbb0697f97 (diff) | |
download | mupdf-ef66c129e2451d4d929c21339fa6c36f9ece1a37.tar.xz |
Android: introduce common interface for normal and reflowed views
Diffstat (limited to 'android')
-rw-r--r-- | android/src/com/artifex/mupdfdemo/MuPDFActivity.java | 26 | ||||
-rw-r--r-- | android/src/com/artifex/mupdfdemo/MuPDFPageView.java | 2 | ||||
-rw-r--r-- | android/src/com/artifex/mupdfdemo/MuPDFView.java | 24 |
3 files changed, 38 insertions, 14 deletions
diff --git a/android/src/com/artifex/mupdfdemo/MuPDFActivity.java b/android/src/com/artifex/mupdfdemo/MuPDFActivity.java index 5ad3d630..f432c734 100644 --- a/android/src/com/artifex/mupdfdemo/MuPDFActivity.java +++ b/android/src/com/artifex/mupdfdemo/MuPDFActivity.java @@ -433,7 +433,7 @@ public class MuPDFActivity extends Activity LinkInfo link = null; if (!mSelecting && !showButtonsDisabled) { - MuPDFPageView pageView = (MuPDFPageView) mDocView.getDisplayedView(); + MuPDFView pageView = (MuPDFView) mDocView.getDisplayedView(); if (MuPDFCore.javascriptSupported() && pageView.passClickEvent(e.getX(), e.getY())) { // If the page consumes the event do nothing else } else if (mLinkHighlight && pageView != null && (link = pageView.hitLink(e.getX(), e.getY())) != null) { @@ -479,7 +479,7 @@ public class MuPDFActivity extends Activity return super.onScroll(e1, e2, distanceX, distanceY); } else { - MuPDFPageView pageView = (MuPDFPageView) mDocView.getDisplayedView(); + MuPDFView pageView = (MuPDFView) mDocView.getDisplayedView(); if (pageView != null) pageView.selectText(e1.getX(), e1.getY(), e2.getX(), e2.getY()); return true; @@ -512,18 +512,18 @@ public class MuPDFActivity extends Activity protected void onChildSetup(int i, View v) { if (SearchTaskResult.get() != null && SearchTaskResult.get().pageNumber == i) - ((PageView)v).setSearchBoxes(SearchTaskResult.get().searchBoxes); + ((MuPDFView)v).setSearchBoxes(SearchTaskResult.get().searchBoxes); else - ((PageView)v).setSearchBoxes(null); + ((MuPDFView)v).setSearchBoxes(null); - ((PageView)v).setLinkHighlighting(mLinkHighlight); + ((MuPDFView)v).setLinkHighlighting(mLinkHighlight); - ((MuPDFPageView)v).setChangeReporter(new Runnable() { + ((MuPDFView)v).setChangeReporter(new Runnable() { public void run() { mDocView.applyToChildren(new ReaderView.ViewMapper() { @Override void applyToView(View view) { - ((MuPDFPageView)view).update(); + ((MuPDFView)view).update(); } }); } @@ -545,18 +545,18 @@ public class MuPDFActivity extends Activity protected void onSettle(View v) { // When the layout has settled ask the page to render // in HQ - ((PageView)v).addHq(false); + ((MuPDFView)v).addHq(false); } protected void onUnsettle(View v) { // When something changes making the previous settled view // no longer appropriate, tell the page to remove HQ - ((PageView)v).removeHq(); + ((MuPDFView)v).removeHq(); } @Override protected void onNotInUse(View v) { - ((PageView)v).releaseResources(); + ((MuPDFView)v).releaseResources(); } }; mDocView.setAdapter(new MuPDFPageAdapter(this, core)); @@ -603,7 +603,7 @@ public class MuPDFActivity extends Activity mCancelSelectButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { - PageView pageView = (PageView) mDocView.getDisplayedView(); + MuPDFView pageView = (MuPDFView) mDocView.getDisplayedView(); if (pageView != null) pageView.deselectText(); mSelecting = false; @@ -614,7 +614,7 @@ public class MuPDFActivity extends Activity final Context context = this; mCopySelectButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { - PageView pageView = (PageView) mDocView.getDisplayedView(); + MuPDFView pageView = (MuPDFView) mDocView.getDisplayedView(); boolean copied = false; if (pageView != null) copied = pageView.copySelection(); @@ -655,7 +655,7 @@ public class MuPDFActivity extends Activity mStrikeOutButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { - PageView pageView = (PageView) mDocView.getDisplayedView(); + MuPDFView pageView = (MuPDFView) mDocView.getDisplayedView(); if (pageView != null) pageView.strikeOutSelection(); mSelecting = false; diff --git a/android/src/com/artifex/mupdfdemo/MuPDFPageView.java b/android/src/com/artifex/mupdfdemo/MuPDFPageView.java index 69157209..9dcae615 100644 --- a/android/src/com/artifex/mupdfdemo/MuPDFPageView.java +++ b/android/src/com/artifex/mupdfdemo/MuPDFPageView.java @@ -55,7 +55,7 @@ class PassClickResultChoice extends PassClickResult { } } -public class MuPDFPageView extends PageView { +public class MuPDFPageView extends PageView implements MuPDFView { private final MuPDFCore mCore; private AsyncTask<Void,Void,PassClickResult> mPassClick; private RectF mWidgetAreas[]; diff --git a/android/src/com/artifex/mupdfdemo/MuPDFView.java b/android/src/com/artifex/mupdfdemo/MuPDFView.java new file mode 100644 index 00000000..4be7f271 --- /dev/null +++ b/android/src/com/artifex/mupdfdemo/MuPDFView.java @@ -0,0 +1,24 @@ +package com.artifex.mupdfdemo; + +import android.graphics.PointF; +import android.graphics.Rect; +import android.graphics.RectF; + +public interface MuPDFView { + public void setPage(int page, PointF size); + public int getPage(); + public void blank(int page); + public boolean passClickEvent(float x, float y); + public LinkInfo hitLink(float x, float y); + public void selectText(float x0, float y0, float x1, float y1); + public void deselectText(); + public boolean copySelection(); + public void strikeOutSelection(); + public void setSearchBoxes(RectF searchBoxes[]); + public void setLinkHighlighting(boolean f); + public void setChangeReporter(Runnable reporter); + public void update(); + public void addHq(boolean update); + public void removeHq(); + public void releaseResources(); +} |