From 8d1047d05c3a0e1e1310fb1a47dc6d4f80b2c0f4 Mon Sep 17 00:00:00 2001 From: Ashley Hughes Date: Thu, 6 Feb 2014 22:52:22 +0000 Subject: [PATCH] fix a crash --- .../keychain/ui/widget/KeyEditor.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java index ba10c7603..fa220313c 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java @@ -88,11 +88,15 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { if (mDatePickerResultCount++ == 0) { GregorianCalendar date = new GregorianCalendar(TimeZone.getTimeZone("UTC")); date.set(year, monthOfYear, dayOfMonth); - long numDays = (date.getTimeInMillis() / 86400000) - (mOriginalExpiryDate.getTimeInMillis() / 86400000); - if (numDays == 0) - setExpiryDate(mOriginalExpiryDate); - else + if (mOriginalExpiryDate != null) { + long numDays = (date.getTimeInMillis() / 86400000) - (mOriginalExpiryDate.getTimeInMillis() / 86400000); + if (numDays == 0) + setExpiryDate(mOriginalExpiryDate); + else + setExpiryDate(date); + } else { setExpiryDate(date); + } if (mEditorListener != null) { mEditorListener.onEdited(); }