android-network-manager
android-network-manager copied to clipboard
ArrayIndexOutOfBoundsException in TaskAdapter
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
I can confirm this: happens when you start the network-manager-start app and click delete very fast.
Exactly when I am getting the error. Try adding many Requests and delete first one.
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.
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.