diff options
Diffstat (limited to 'platform/android')
2 files changed, 53 insertions, 22 deletions
diff --git a/platform/android/example/mupdf/src/main/java/com/artifex/mupdf/android/DocPageView.java b/platform/android/example/mupdf/src/main/java/com/artifex/mupdf/android/DocPageView.java index e862d87a..60611b2a 100644 --- a/platform/android/example/mupdf/src/main/java/com/artifex/mupdf/android/DocPageView.java +++ b/platform/android/example/mupdf/src/main/java/com/artifex/mupdf/android/DocPageView.java @@ -126,23 +126,11 @@ public class DocPageView extends View implements Callback // make a new page object. if (thePageNum != mPageNum) { - mPageNum = thePageNum; - - // de-cache contents and annotations - if (pageContents != null) - { - pageContents.destroy(); - pageContents = null; - } - if (annotContents != null) - { - annotContents.destroy(); - annotContents = null; - } + // destroy current page and lists + destroyPageAndLists(); - // destroy the page before making a new one. - if (mPage != null) - mPage.destroy(); + // switch to the new page + mPageNum = thePageNum; mPage = mDoc.loadPage(mPageNum); } @@ -157,6 +145,26 @@ public class DocPageView extends View implements Callback mSize = new Point((int) (pagew * mZoom), (int) (pageH * mZoom)); } + private void destroyPageAndLists() + { + // de-cache contents and annotations + if (pageContents != null) + { + pageContents.destroy(); + pageContents = null; + } + if (annotContents != null) + { + annotContents.destroy(); + annotContents = null; + } + + // destroy the page before making a new one. + if (mPage != null) + mPage.destroy(); + mPage = null; + } + public Page getPage() { return mPage; @@ -364,6 +372,7 @@ public class DocPageView extends View implements Callback catch (RuntimeException e) { pageContents.destroy(); + pageContents = null; dispDev.destroy(); throw (e); } @@ -392,6 +401,7 @@ public class DocPageView extends View implements Callback catch (RuntimeException e) { annotContents.destroy(); + annotContents = null; annotDev.destroy(); throw (e); } @@ -806,12 +816,8 @@ public class DocPageView extends View implements Callback { mFinished = true; - // destroy the page - if (mPage != null) - { - mPage.destroy(); - mPage = null; - } + // destroy page and lists + destroyPageAndLists(); } public boolean getMostVisible() {return isMostVisible;} diff --git a/platform/android/example/mupdf/src/main/java/com/artifex/mupdf/android/ProofActivity.java b/platform/android/example/mupdf/src/main/java/com/artifex/mupdf/android/ProofActivity.java index 0d11f063..04ba3089 100644 --- a/platform/android/example/mupdf/src/main/java/com/artifex/mupdf/android/ProofActivity.java +++ b/platform/android/example/mupdf/src/main/java/com/artifex/mupdf/android/ProofActivity.java @@ -29,7 +29,11 @@ import com.artifex.mupdf.fitz.Page; import com.artifex.mupdf.fitz.R; import com.artifex.mupdf.fitz.Separation; +import java.io.File; +import java.io.FileFilter; import java.util.LinkedList; +import java.util.regex.Matcher; +import java.util.regex.Pattern; public class ProofActivity extends Activity implements View.OnClickListener, DocViewBase.IdleRenderListener { @@ -112,9 +116,30 @@ public class ProofActivity extends Activity implements View.OnClickListener, Doc // stop the view mDocView.finish(); + // kill the document + mDoc.destroy(); + // delete the .gproof file Utilities.deleteFile(mPath); + // delete temp files left by the proofing. + // these are of the form gprf_n_xxxxxx + File dir = new File(mPath).getParentFile(); + final Pattern pattern = Pattern.compile("gprf_.*_.*"); + File[] files = dir.listFiles(new FileFilter() + { + public boolean accept(File file) + { + Matcher matcher = pattern.matcher(file.getName()); + return matcher.matches(); + } + }); + for (File file:files) + { + System.out.println(String.format("deleting %s", file.getAbsolutePath())); + file.delete(); + } + super.finish(); } |