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

StringIndexOutOfBoundsException when trying to load String that ends with \n #41

Closed
lpbas opened this issue Nov 28, 2016 · 1 comment
Closed

Comments

@lpbas
Copy link

lpbas commented Nov 28, 2016

Hello. I found out that when trying to load a String that ends with newline, AutoFitTextView crashes the app with a StringIndexOutOfBoundsException. This does not always happen, but I am able to reproduce this bug with the following string:

String test  = "(WLAN)\n";
myAutoFitTextView.setText(test);

My app crashes when the settext is excecuted. Thanks for this library, it's really needed on the Android platform.

The full stacktrace follows:

java.lang.StringIndexOutOfBoundsException: length=7; index=7
                                                                        at java.lang.String.indexAndLength(String.java:500)
                                                                        at java.lang.String.charAt(String.java:494)
                                                                        at com.lb.auto_fit_textview.AutoResizeTextView$1.onTestSize(AutoResizeTextView.java:89)
                                                                        at com.lb.auto_fit_textview.AutoResizeTextView.binarySearch(AutoResizeTextView.java:227)
                                                                        at com.lb.auto_fit_textview.AutoResizeTextView.superSetTextSize(AutoResizeTextView.java:219)
                                                                        at com.lb.auto_fit_textview.AutoResizeTextView.adjustTextSize(AutoResizeTextView.java:213)
                                                                        at com.lb.auto_fit_textview.AutoResizeTextView.onSizeChanged(AutoResizeTextView.java:251)
                                                                        at android.view.View.sizeChange(View.java:15804)
                                                                        at android.view.View.setFrame(View.java:15769)
                                                                        at android.widget.TextView.setFrame(TextView.java:4661)
                                                                        at android.view.View.layout(View.java:15685)
                                                                        at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1703)
                                                                        at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1557)
                                                                        at android.widget.LinearLayout.onLayout(LinearLayout.java:1466)
                                                                        at android.view.View.layout(View.java:15689)
                                                                        at android.view.ViewGroup.layout(ViewGroup.java:5040)
                                                                        at android.widget.FrameLayout.layoutChildren(FrameLayout.java:579)
                                                                        at android.widget.FrameLayout.onLayout(FrameLayout.java:514)
                                                                        at android.view.View.layout(View.java:15689)
                                                                        at android.view.ViewGroup.layout(ViewGroup.java:5040)
                                                                        at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1703)
                                                                        at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1557)
                                                                        at android.widget.LinearLayout.onLayout(LinearLayout.java:1466)
                                                                        at android.view.View.layout(View.java:15689)
                                                                        at android.view.ViewGroup.layout(ViewGroup.java:5040)
                                                                        at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1703)
                                                                        at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1557)
                                                                        at android.widget.LinearLayout.onLayout(LinearLayout.java:1466)
                                                                        at android.view.View.layout(View.java:15689)
                                                                        at android.view.ViewGroup.layout(ViewGroup.java:5040)
                                                                        at android.support.design.widget.CoordinatorLayout.layoutChild(CoordinatorLayout.java:1091)
                                                                        at android.support.design.widget.CoordinatorLayout.onLayoutChild(CoordinatorLayout.java:801)
                                                                        at android.support.design.widget.CoordinatorLayout.onLayout(CoordinatorLayout.java:815)
                                                                        at android.view.View.layout(View.java:15689)
                                                                        at android.view.ViewGroup.layout(ViewGroup.java:5040)
                                                                        at android.widget.FrameLayout.layoutChildren(FrameLayout.java:579)
                                                                        at android.widget.FrameLayout.onLayout(FrameLayout.java:514)
                                                                        at android.view.View.layout(View.java:15689)
                                                                        at android.view.ViewGroup.layout(ViewGroup.java:5040)
                                                                        at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1703)
                                                                        at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1557)
                                                                        at android.widget.LinearLayout.onLayout(LinearLayout.java:1466)
                                                                        at android.view.View.layout(View.java:15689)
                                                                        at android.view.ViewGroup.layout(ViewGroup.java:5040)
                                                                        at android.widget.FrameLayout.layoutChildren(FrameLayout.java:579)
                                                                        at android.widget.FrameLayout.onLayout(FrameLayout.java:514)
                                                                        at android.view.View.layout(View.java:15689)
                                                                        at android.view.ViewGroup.layout(ViewGroup.java:5040)
                                                                        at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1703)
                                                                        at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1557)
                                                                        at android.widget.LinearLayout.onLayout(LinearLayout.java:1466)
                                                                        at android.view.View.layout(View.java:15689)
                                                                        at android.view.ViewGroup.layout(ViewGroup.java:5040)
                                                                        at android.widget.FrameLayout.layoutChildren(FrameLayout.java:579)
                                                                        at android.widget.FrameLayout.onLayout(FrameLayout.java:514)
                                                                        at android.view.View.layout(View.java:15689)
                                                                        at android.view.ViewGroup.layout(ViewGroup.java:5040)
                                                                        at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2116)
                                                                        at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1873)
                                                                        at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1084)
                                                                        at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5990)
                                                                    	at android.view.Choreographer$CallbackRecord.run(Choreographer
@AndroidDeveloperLB
Copy link
Owner

duplicate of this:
#37

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