From e7708ef439871a2db7fc8002ad5ff64f4944c0af Mon Sep 17 00:00:00 2001 From: Eric House Date: Wed, 19 Mar 2014 20:17:53 -0700 Subject: [PATCH] fix NPE when serializing --- .../XWords4/src/org/eehouse/android/xw4/DlgState.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgState.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgState.java index d424f2969..d9702eb2f 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgState.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgState.java @@ -84,7 +84,7 @@ public class DlgState implements Parcelable { public void writeToParcel( Parcel out, int flags ) { out.writeInt( m_id.ordinal() ); out.writeInt( m_posButton ); - out.writeInt( m_action.ordinal() ); + out.writeInt( null == m_action ? -1 : m_action.ordinal() ); out.writeInt( m_prefsKey ); out.writeString( m_msg ); } @@ -94,7 +94,8 @@ public class DlgState implements Parcelable { public DlgState createFromParcel(Parcel in) { DlgID id = DlgID.values()[in.readInt()]; int posButton = in.readInt(); - Action action = Action.values()[in.readInt()]; + int tmp = in.readInt(); + Action action = 0 > tmp ? null : Action.values()[tmp]; int prefsKey = in.readInt(); String msg = in.readString(); return new DlgState( id, msg, posButton, action, prefsKey );