Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate Underlabels When Validating Twice #78

Open
mbobic93 opened this issue Oct 18, 2019 · 2 comments
Open

Duplicate Underlabels When Validating Twice #78

mbobic93 opened this issue Oct 18, 2019 · 2 comments

Comments

@mbobic93
Copy link

I encountered an error when using the UNDERLABEL style.

java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first. at android.view.ViewGroup.addViewInner(ViewGroup.java:5034) at android.view.ViewGroup.addView(ViewGroup.java:4865) at android.view.ViewGroup.addView(ViewGroup.java:4805) at com.basgeekball.awesomevalidation.utility.ViewsInfo.restoreViews(SourceFile:32) at com.basgeekball.awesomevalidation.validators.UnderlabelValidator$2.onTextChanged(SourceFile:131) at android.widget.TextView.sendOnTextChanged(TextView.java:9754) at android.widget.TextView.handleTextChanged(TextView.java:9851) at android.widget.TextView$ChangeWatcher.onTextChanged(TextView.java:12509) at android.text.SpannableStringBuilder.sendTextChanged(SpannableStringBuilder.java:1263) at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:575) at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:506) at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:36) at android.view.inputmethod.BaseInputConnection.replaceText(BaseInputConnection.java:843) at android.view.inputmethod.BaseInputConnection.commitText(BaseInputConnection.java:197) at com.android.internal.widget.EditableInputConnection.commitText(EditableInputConnection.java:183) at com.android.internal.view.IInputConnectionWrapper.executeMessage(IInputConnectionWrapper.java:341) at com.android.internal.view.IInputConnectionWrapper$MyHandler.handleMessage(IInputConnectionWrapper.java:85) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:6669) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

I have 4 EditText views, two of which are using basic regex validation, and two that are using SimpleCustomValidation. My validations are run on a button click. If there has already been an underlabel added, a duplicate one gets right below. When an attempt is made to change the value in the EditText, the above exception gets thrown. I tried adding in a validation.clear() after all my validation.addValidation() calls.

It may also be worth mentioning that I am using androidx libraries. My other validations are working as intended. The only difference here is that this is on an Activity instead of a Fragment.

@thyrlian
Copy link
Owner

It sounds like a race condition. Could you please check this?

@mbobic93
Copy link
Author

I did check that link out. But it's talking Fragments. While I do have validation on my Fragments, this issue I discovered when I'm using an Activity instead. I have the validations set in in the onCreate method of that Activity, within my onClickListener of the button. I do not see the same issue occurring within my Fragment validations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants