summaryrefslogtreecommitdiffstats
path: root/packages/PrintSpooler/src
diff options
context:
space:
mode:
Diffstat (limited to 'packages/PrintSpooler/src')
-rw-r--r--packages/PrintSpooler/src/com/android/printspooler/model/PageContentRepository.java26
-rw-r--r--packages/PrintSpooler/src/com/android/printspooler/ui/PageAdapter.java6
-rw-r--r--packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java10
-rw-r--r--packages/PrintSpooler/src/com/android/printspooler/ui/PrintPreviewController.java4
4 files changed, 33 insertions, 13 deletions
diff --git a/packages/PrintSpooler/src/com/android/printspooler/model/PageContentRepository.java b/packages/PrintSpooler/src/com/android/printspooler/model/PageContentRepository.java
index 0923649..90875c0 100644
--- a/packages/PrintSpooler/src/com/android/printspooler/model/PageContentRepository.java
+++ b/packages/PrintSpooler/src/com/android/printspooler/model/PageContentRepository.java
@@ -106,12 +106,26 @@ public final class PageContentRepository {
mRenderer.close(callback);
}
- public void destroy() {
+ public void destroy(final Runnable callback) {
+ if (mState == STATE_OPENED) {
+ close(new Runnable() {
+ @Override
+ public void run() {
+ destroy(callback);
+ }
+ });
+ return;
+ }
+
mState = STATE_DESTROYED;
if (DEBUG) {
Log.i(LOG_TAG, "STATE_DESTROYED");
}
mRenderer.destroy();
+
+ if (callback != null) {
+ callback.run();
+ }
}
public void startPreload(int firstShownPage, int lastShownPage) {
@@ -158,7 +172,7 @@ public final class PageContentRepository {
try {
if (mState != STATE_DESTROYED) {
mCloseGuard.warnIfOpen();
- destroy();
+ destroy(null);
}
} finally {
super.finalize();
@@ -455,6 +469,10 @@ public final class PageContentRepository {
public void close(final Runnable callback) {
cancelAllRendering();
+ if (mOpenTask != null) {
+ mOpenTask.cancel();
+ }
+
new AsyncTask<Void, Void, Void>() {
@Override
protected void onPreExecute() {
@@ -492,10 +510,6 @@ public final class PageContentRepository {
mContext.unbindService(AsyncRenderer.this);
}
- if (mOpenTask != null) {
- mOpenTask.cancel();
- }
-
mPageContentCache.invalidate();
mPageContentCache.clear();
mDestroyed = true;
diff --git a/packages/PrintSpooler/src/com/android/printspooler/ui/PageAdapter.java b/packages/PrintSpooler/src/com/android/printspooler/ui/PageAdapter.java
index 0d2e736..2757b81 100644
--- a/packages/PrintSpooler/src/com/android/printspooler/ui/PageAdapter.java
+++ b/packages/PrintSpooler/src/com/android/printspooler/ui/PageAdapter.java
@@ -493,13 +493,13 @@ public final class PageAdapter extends Adapter {
return selectedPages;
}
- public void destroy() {
- mPageContentRepository.destroy();
+ public void destroy(Runnable callback) {
mCloseGuard.close();
mState = STATE_DESTROYED;
if (DEBUG) {
Log.i(LOG_TAG, "STATE_DESTROYED");
}
+ mPageContentRepository.destroy(callback);
}
@Override
@@ -507,7 +507,7 @@ public final class PageAdapter extends Adapter {
try {
if (mState != STATE_DESTROYED) {
mCloseGuard.warnIfOpen();
- destroy();
+ destroy(null);
}
} finally {
super.finalize();
diff --git a/packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java b/packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java
index 71d5340..352b545 100644
--- a/packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java
+++ b/packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java
@@ -1635,9 +1635,15 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat
mSpoolerProvider.destroy();
mPrintedDocument.finish();
mPrintedDocument.destroy();
- mPrintPreviewController.destroy();
+ mPrintPreviewController.destroy(new Runnable() {
+ @Override
+ public void run() {
+ finish();
+ }
+ });
+ } else {
+ finish();
}
- finish();
}
private final class SpinnerItem<T> {
diff --git a/packages/PrintSpooler/src/com/android/printspooler/ui/PrintPreviewController.java b/packages/PrintSpooler/src/com/android/printspooler/ui/PrintPreviewController.java
index 15342ae..8716fd2 100644
--- a/packages/PrintSpooler/src/com/android/printspooler/ui/PrintPreviewController.java
+++ b/packages/PrintSpooler/src/com/android/printspooler/ui/PrintPreviewController.java
@@ -192,10 +192,10 @@ class PrintPreviewController implements MutexFileProvider.OnReleaseRequestCallba
});
}
- public void destroy() {
+ public void destroy(Runnable callback) {
mHandler.cancelQueuedOperations();
mRecyclerView.setAdapter(null);
- mPageAdapter.destroy();
+ mPageAdapter.destroy(callback);
}
@Override