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

PinField.kt line 208 #45

Open
muhammadahkamahmad opened this issue Apr 20, 2021 · 10 comments
Open

PinField.kt line 208 #45

muhammadahkamahmad opened this issue Apr 20, 2021 · 10 comments

Comments

@muhammadahkamahmad
Copy link

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?

@poovamraj
Copy link
Owner

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

@poovamraj
Copy link
Owner

Are you setting textAllCaps?

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

@muhammadahkamahmad
Copy link
Author

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">

</com.poovam.pinedittextfield.LinePinField>

if (otp.length == 5)
pinCode?.setText(otp)

@poovamraj
Copy link
Owner

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

@muhammadahkamahmad
Copy link
Author

Its on Main Thread but its an occasional crash

@mohanK22
Copy link

@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

@poovamraj
Copy link
Owner

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

@mohanK22
Copy link

mohanK22 commented Jun 16, 2022

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

@rajikotta
Copy link

@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

@MaryiaR
Copy link

MaryiaR commented Oct 21, 2024

@poovamraj still no fix for this issue? We are also seeing 'offset(6) should be less than line limit(0)' crash on Samsung devices, but didn't find steps to reproduce

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

5 participants