|
@@ -5,6 +5,7 @@ import android.content.Context;
|
|
|
import android.os.Build;
|
|
|
import android.os.Bundle;
|
|
|
import android.preference.EditTextPreference;
|
|
|
+import android.preference.PreferenceManager;
|
|
|
import android.support.annotation.NonNull;
|
|
|
import android.util.AttributeSet;
|
|
|
import android.view.LayoutInflater;
|
|
@@ -24,6 +25,9 @@ import com.afollestad.materialdialogs.R;
|
|
|
import com.afollestad.materialdialogs.internal.MDTintHelper;
|
|
|
import com.afollestad.materialdialogs.util.DialogUtils;
|
|
|
|
|
|
+import java.lang.reflect.InvocationTargetException;
|
|
|
+import java.lang.reflect.Method;
|
|
|
+
|
|
|
/**
|
|
|
* @author Aidan Follestad (afollestad)
|
|
|
*/
|
|
@@ -95,6 +99,17 @@ public class MaterialEditTextPreference extends EditTextPreference {
|
|
|
}
|
|
|
mBuilder.customView(layout, false);
|
|
|
|
|
|
+ PreferenceManager pm = getPreferenceManager();
|
|
|
+ try {
|
|
|
+ Method method = pm.getClass().getDeclaredMethod(
|
|
|
+ "registerOnActivityDestroyListener",
|
|
|
+ PreferenceManager.OnActivityDestroyListener.class);
|
|
|
+ method.setAccessible(true);
|
|
|
+ method.invoke(pm, this);
|
|
|
+ } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
mDialog = mBuilder.build();
|
|
|
if (state != null)
|
|
|
mDialog.onRestoreInstanceState(state);
|