android-network-manager icon indicating copy to clipboard operation
android-network-manager copied to clipboard

ArrayIndexOutOfBoundsException in TaskAdapter

Open ghost opened this issue 9 years ago • 4 comments

Process: com.google.codelab.networkmanager, PID: 17258 java.lang.ArrayIndexOutOfBoundsException: length=12; index=-1 at java.util.ArrayList.get(ArrayList.java:310) at com.google.codelab.networkmanager.TaskAdapter$1.onClick(TaskAdapter.java:98) at android.view.View.performClick(View.java:5198) at android.view.View$PerformClick.run(View.java:21147) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5417) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

Error occurs when try to delete an item from list

ghost avatar Dec 16 '15 08:12 ghost

I can confirm this: happens when you start the network-manager-start app and click delete very fast.

tmtron avatar Jul 22 '16 18:07 tmtron

Exactly when I am getting the error. Try adding many Requests and delete first one.

umang6891 avatar Jul 27 '16 06:07 umang6891

Classic issue with the second call of onClick not being expected. The disable doesn't happen fast enough. The best way to deal with this is using the onClick annotation of ButterKnife, which handles debouncing for you. Alternatively, you can add a boolean that's checked for, so that the onClick cannot be called twice. Likely not worth adding to the codelab though since it would be additional distracting code that doesn't serve to illustrate the point of the exercise.

AniketSK avatar Jul 27 '16 07:07 AniketSK

I agree that Codelabs should have as little code as possible. But they should also be (like any other software) technically correct: crashes or severe bugs are not acceptable.

At least, there should be a comment to explain that there are some known problems and how to fix them.

tmtron avatar Jul 29 '16 08:07 tmtron