From e3bbb3d6c09a29cddeb544308e5b3210908fa256 Mon Sep 17 00:00:00 2001 From: Svetoslav Date: Thu, 12 Jun 2014 10:43:20 -0700 Subject: [PATCH] Fix NPE in PrintActivity. It is possible that the orientation is chosen before the media size. The code handling orientation change was wrognly expecting to have a selected media size all the time resulting in a NPE. bug:15512333 Change-Id: I9f2786af314641144a24c1d1363c8d2590b0df57 --- .../src/com/android/printspooler/ui/PrintActivity.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java b/packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java index f71cafe584ccc..3e0d7e557de1b 100644 --- a/packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java +++ b/packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java @@ -1735,10 +1735,12 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat } else if (spinner == mOrientationSpinner) { SpinnerItem orientationItem = mOrientationSpinnerAdapter.getItem(position); PrintAttributes attributes = mPrintJob.getAttributes(); - if (orientationItem.value == ORIENTATION_PORTRAIT) { - attributes.copyFrom(attributes.asPortrait()); - } else { - attributes.copyFrom(attributes.asLandscape()); + if (mMediaSizeSpinner.getSelectedItem() != null) { + if (orientationItem.value == ORIENTATION_PORTRAIT) { + attributes.copyFrom(attributes.asPortrait()); + } else { + attributes.copyFrom(attributes.asLandscape()); + } } }