PinEditTextField icon indicating copy to clipboard operation
PinEditTextField copied to clipboard

PinField.kt line 208

Open muhammadahkamahmad opened this issue 4 years ago • 10 comments

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?

muhammadahkamahmad avatar Apr 20 '21 06:04 muhammadahkamahmad

Can you share the xml definition in your layout and also the text that you are setting that is causing this error?

poovamraj avatar Apr 20 '21 06:04 poovamraj

Are you setting textAllCaps?

It could possibly be this issue - https://stackoverflow.com/a/28803492/5202830

poovamraj avatar Apr 20 '21 06:04 poovamraj

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)

muhammadahkamahmad avatar Apr 20 '21 06:04 muhammadahkamahmad

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

poovamraj avatar Apr 20 '21 07:04 poovamraj

Its on Main Thread but its an occasional crash

muhammadahkamahmad avatar Apr 20 '21 08:04 muhammadahkamahmad

@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.

Screenshot 2022-05-31 at 3 52 52 PM

mohanK22 avatar May 31 '22 10:05 mohanK22

@mohanK22 do you have a reliable way to reproduce this issue? It will be really helpful to fix it.

poovamraj avatar Jun 01 '22 22:06 poovamraj

@poovamraj -- I tried to replicate this issue several times, but I couldn't able to replicate this issue.

mohanK22 avatar Jun 16 '22 11:06 mohanK22

@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

rajikotta avatar Feb 25 '24 05:02 rajikotta