When search completes successfully but returns 0 results the app crashes with an IndexOutOfBoundsException.
11-09 14:58:58.693 15840-15840/com.mapzen.erasermap E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.mapzen.erasermap, PID: 15840
java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0
at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:255)
at java.util.ArrayList.get(ArrayList.java:308)
at com.mapzen.erasermap.controller.MainActivity.addSearchResultsToMap(MainActivity.kt:720)
at com.mapzen.erasermap.controller.MainActivity.showSearchResults(MainActivity.kt:543)
at com.mapzen.erasermap.presenter.MainPresenterImpl.onSearchResultsAvailable(MainPresenterImpl.kt:89)
at com.mapzen.erasermap.controller.MainActivity$PeliasCallback.success(MainActivity.kt:498)
at com.mapzen.erasermap.controller.MainActivity$PeliasCallback.success(MainActivity.kt:493)
at retrofit.CallbackRunnable$1.run(CallbackRunnable.java:45)
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)
When search completes successfully but returns 0 results the app crashes with an
IndexOutOfBoundsException
.