diff options
author | Svetoslav Ganov <svetoslavganov@google.com> | 2013-08-29 01:21:05 -0700 |
---|---|---|
committer | nicolasroard <nicolasroard@google.com> | 2013-08-29 16:02:28 -0700 |
commit | 2775ff37d7a71fb6e3018468420118bd328e9977 (patch) | |
tree | 2297ead120de250e0214b8a65fdbaa75f06199c2 /src/com/android/gallery3d | |
parent | 834efce0da12e6a4664c3f3c63bfd2e77b6e750a (diff) | |
download | android_packages_apps_Gallery2-2775ff37d7a71fb6e3018468420118bd328e9977.tar.gz android_packages_apps_Gallery2-2775ff37d7a71fb6e3018468420118bd328e9977.tar.bz2 android_packages_apps_Gallery2-2775ff37d7a71fb6e3018468420118bd328e9977.zip |
Updated Gallery to avoid breaking the build - API change
Change-Id: Iaf80496629773dfffab4d1475a711384fa96e010
Diffstat (limited to 'src/com/android/gallery3d')
-rw-r--r-- | src/com/android/gallery3d/util/PrintJob.java | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/com/android/gallery3d/util/PrintJob.java b/src/com/android/gallery3d/util/PrintJob.java index 1bdbce7ec..83cb96aa4 100644 --- a/src/com/android/gallery3d/util/PrintJob.java +++ b/src/com/android/gallery3d/util/PrintJob.java @@ -23,6 +23,7 @@ import android.graphics.RectF; import android.net.Uri; import android.os.Bundle; import android.os.CancellationSignal; +import android.os.ParcelFileDescriptor; import android.print.PageRange; import android.print.PrintAttributes; import android.print.PrintDocumentAdapter; @@ -33,8 +34,8 @@ import android.print.pdf.PrintedPdfDocument; import com.android.gallery3d.filtershow.cache.ImageLoader; -import java.io.FileDescriptor; import java.io.FileOutputStream; +import java.io.IOException; public class PrintJob { private final static int MAX_PRINT_SIZE = 2048; @@ -61,6 +62,7 @@ public class PrintJob { PrintDocumentInfo info = new PrintDocumentInfo .Builder(jobName, newPrintAttributes) .setContentType(PrintDocumentInfo.CONTENT_TYPE_PHOTO) + .setColorMode(PrintAttributes.COLOR_MODE_COLOR) .setPageCount(1) .create(); @@ -68,7 +70,7 @@ public class PrintJob { } @Override - public void onWrite(PageRange[] pageRanges, FileDescriptor fileDescriptor, + public void onWrite(PageRange[] pageRanges, ParcelFileDescriptor fileDescriptor, CancellationSignal cancellationSignal, WriteResultCallback writeResultCallback) { try { @@ -140,13 +142,21 @@ public class PrintJob { // Write the document. pdfDocument.finishPage(page); - pdfDocument.writeTo(new FileOutputStream(fileDescriptor)); + pdfDocument.writeTo(new FileOutputStream( + fileDescriptor.getFileDescriptor())); pdfDocument.close(); // Done. writeResultCallback.onWriteFinished( new PageRange[] { PageRange.ALL_PAGES }); } finally { + if (fileDescriptor != null) { + try { + fileDescriptor.close(); + } catch (IOException ioe) { + /* ignore */ + } + } writeResultCallback.onWriteFailed(null); } } |