From 841001f2ed44000d8869f3af520bea6e4d32f46f Mon Sep 17 00:00:00 2001 From: pshadlyn Date: Mon, 9 Nov 2015 15:17:32 -0500 Subject: [PATCH] fixed NPE when saving conversion state --- .../fragments/ConversionFragment.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/physphil/android/unitconverterultimate/fragments/ConversionFragment.java b/app/src/main/java/com/physphil/android/unitconverterultimate/fragments/ConversionFragment.java index 3972bcca..7c2f2414 100644 --- a/app/src/main/java/com/physphil/android/unitconverterultimate/fragments/ConversionFragment.java +++ b/app/src/main/java/com/physphil/android/unitconverterultimate/fragments/ConversionFragment.java @@ -27,6 +27,7 @@ import android.text.Editable; import android.text.InputType; import android.text.TextWatcher; +import android.util.Log; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; @@ -189,7 +190,11 @@ public void onPause() mTxtValue.removeTextChangedListener(mTextWatcher); mPrefs.setLastValue(mTxtValue.getText().toString()); mPrefs.setLastConversion(mConversionId); - DataAccess.getInstance(getActivity()).saveConversionState(mState); + + if (mState != null) + { + DataAccess.getInstance(getActivity()).saveConversionState(mState); + } } @Override