DataForm: [Android] NullPointerException is thrown when using DataFormPasswordEditor
Setting DataFormPasswordEditor inside a custom renderer on Android leads to the following exception:
Java.Lang.NullPointerException: Attempt to invoke virtual method 'java.util.Iterator java.util.ArrayList.iterator()' on a null object reference
3 comments
Jesse
Posted on:23 Mar 2020 16:37
Yana, I had to make a few tweaks to fit our implementation, but that got me on the right path. I'm not crashing anymore.
Thank you!
ADMIN
Yana
Posted on:23 Mar 2020 16:02
Hello Jesse,
I am sorry to hear you've come across this error.
We've researched this and came up with a fairy simple workaround you can apply in the custom renderer to resolve it.
First, you would need to set TextEditor for the Password field and override the UpdateEditor method of the custom renderer. Inside this method find the Android EditText control and apply some settings to make it show a password (actually that's the same approach we're using in our code).
The snippet below shows exactly what I mean:
publicI hope this would be of help. Let me know if you experience any issues with the approach. classCustomDataFormRenderer : DataFormRenderer
{
publicCustomDataFormRenderer(Context context)
: base(context)
{
}
protectedoverridevoidUpdateEditor(EntityPropertyEditor editor, IEntityProperty property)
{
base.UpdateEditor(editor, property);
if (property.PropertyName == nameof(ThomasPwdEditor.Portable.User.Password))
{
var editText = editor.EditorView.JavaCast<AppCompatEditText>();
editText.InputType = InputTypes.TextFlagNoSuggestions;
editText.TransformationMethod = new PasswordTransformationMethod();
}
}
}
I hope this would be of help. Let me know if you experience any issues with the approach.
Regards,
Yana
Progress Telerik
Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic. Our thoughts here at Progress are with those affected by the outbreak.
Jesse
Posted on:23 Mar 2020 15:42
I am getting this as well. We have not made any changes in our implementation since this was working previously.