PinEditTextField
PinEditTextField copied to clipboard
PinField.kt line 208
Found Crash "Caused by java.lang.IndexOutOfBoundsException: offset(5) should be less than line limit(0)" on below code
override fun onSelectionChanged(selStart: Int, selEnd: Int) { this.setSelection(this.text.length) }
Any solution?
Can you share the xml definition in your layout and also the text that you are setting that is causing this error?
Are you setting textAllCaps?
It could possibly be this issue - https://stackoverflow.com/a/28803492/5202830
Layout:
<com.poovam.pinedittextfield.LinePinField android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="numberPassword" android:textSize="16sp" app:highlightType="completedFields" android:textSelectHandle="@drawable/text_handle" app:noOfFields="5" app:distanceInBetween="10dp" app:fieldColor="@color/dark_gray" app:highlightColor="@color/colorAccent" app:lineThickness="1dp" android:password="true" app:isCustomBackground="true" android:background="@android:color/transparent" app:isCursorEnabled="false" app:bottomTextPaddingDp="15dp" android:layout_below="@id/choosePin" android:cursorVisible="true" android:id="@+id/pinCode"> <requestFocus/> </com.poovam.pinedittextfield.LinePinField>
if (otp.length == 5) pinCode?.setText(otp)
I am doing the same and it doesn't seem to crash for me.
Are you sure you are calling this from the main thread? Seems like this can happen if it is not called from the main thread - https://stackoverflow.com/a/58513784/5202830
Its on Main Thread but its an occasional crash
@poovamraj -- I'm also facing same crash which is an occasional crash, which is occurs in the most of Samsung devices. Any solutions? please suggest.
@mohanK22 do you have a reliable way to reproduce this issue? It will be really helpful to fix it.
@poovamraj -- I tried to replicate this issue several times, but I couldn't able to replicate this issue.
@poovamraj we are also facing this crash only in samsung devices, could not reproduce this issue, can you please tell us how we can avoid it from our side