Skip to content

Crashing Caused by Index Out of bound  #3

Description

@Mr-Ramzan

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]
}`

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions