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

Crashing Caused by Index Out of bound #3

Open
Mr-Ramzan opened this issue Jun 3, 2024 · 0 comments
Open

Crashing Caused by Index Out of bound #3

Mr-Ramzan opened this issue Jun 3, 2024 · 0 comments

Comments

@Mr-Ramzan
Copy link

getting this index out of bound exception Error No reason at all

  java.lang.StringIndexOutOfBoundsException: begin 0, end 32, length 31
                 	at java.lang.String.checkBoundsBeginEnd(String.java:4466)
                 	at java.lang.String.substring(String.java:2517)
                 	at java.lang.String.subSequence(String.java:2567)
                 	at com.nitish.typewriterview.TypeWriterView$1.run(TypeWriterView.java:31)
                 	at android.os.Handler.handleCallback(Handler.java:942)
                 	at android.os.Handler.dispatchMessage(Handler.java:99)
                 	at android.os.Looper.loopOnce(Looper.java:204)
                 	at android.os.Looper.loop(Looper.java:291)
                 	at android.app.ActivityThread.main(ActivityThread.java:8134)
                 	at java.lang.reflect.Method.invoke(Native Method)
                 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:601)
                 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1019)

here is my Implementation if you can help narrow down the issue please help

` private fun makeTypingText() {

    homeBinding.searchWriterView.setCharacterDelay(80)
    homeBinding.searchWriterView.animateText("Explore Deliciousness in Every Search..")


    homeBinding.searchWriterView.setOnAnimationChangeListener {
        Handler(Looper.getMainLooper()).postDelayed(Runnable {
            if (!this@HomeFragment.isDetached) {
                try {
                    if (index == 4) {
                        index = 0
                    }
                    index++

                    homeBinding.searchWriterView.animateText(makeTestList(index))
                }catch (e:Exception){
                    e.printStackTrace()
                }

            }
        }, 1500)
    }



}
val animatableText: ArrayList<String> = ArrayList()

private fun makeTestList(index: Int): String {
    if(animatableText.isEmpty()) {
        animatableText.add("Explore Deliciousness in Every Search..")
        animatableText.add("Find Flavorful Delights Here...")
        animatableText.add("Explore Deliciousness...")
        animatableText.add("Where Every Bite Speaks Flavor...")
        animatableText.add("Uncover Delicious Treasures Instantly...")
    }
    return animatableText[index]
}`
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

1 participant