Simple-Contacts [4.0.3] - Fatal exception when deleting only contact on list multiple times

Project Information

Repository: https://github.com/SimpleMobileTools/Simple-Contacts/
Project Name: Simple-Contacts
Publisher: https://github.com/SimpleMobileTools

Expected behaviour

When I attempt to delete a contact from contact list it should be deleted following the press of delete (no warning pop up should be provided and it should be deleted instantly).

Actual behaviour

Following the press of delete, the application will not update the view to indicate the contact has been deleted. Upon a second press of delete, the application will crash.

Note: I assume the contact has been deleted and the view has been updated, hence it can't find what it's trying to delete, therefore the crash occurs.

Pre-requisites

  • This issue only seems to occur when you have 1 contact in the list, therefore you should start with an empty contact list and create one contact only and then delete it.
  • I can only replicate on Android 8.0, all other version of Android tested don't seem to show this issue.

How to reproduce

  1. From either a fresh install or existing install go to the contact page.
  2. At the bottom right of the page a floating icon is present, press this icon to create a new contact.
  3. You can name the contact anything, for clarity let's call it "testContact"
  4. Save the contact and the application will show it's been created.
  5. Long Press the "testContact" contact item and additional options will appear
  6. Press the options menu located in the top right of the page
  7. Select delete from this list
  8. The contact will not be removed from the list, repeat steps 5 - 7 and a fatal exception will occur.

Logs

05-27 10:10:37.508 5332-5332/com.simplemobiletools.contacts E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.simplemobiletools.contacts, PID: 5332
    java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
        at java.util.ArrayList.get(ArrayList.java:437)
        at com.simplemobiletools.contacts.a.a.v(SourceFile:148)
        at com.simplemobiletools.contacts.a.a.a(SourceFile:30)
        at com.simplemobiletools.contacts.a.a$b.b(SourceFile:137)
        at com.simplemobiletools.contacts.a.a$b.a(SourceFile:30)
        at com.simplemobiletools.commons.b.c.a(SourceFile:40)
        at com.simplemobiletools.commons.b.c.a(SourceFile:19)
        at com.simplemobiletools.commons.b.c$a.onClick(SourceFile:28)
        at android.support.v7.app.AlertController$b.handleMessage(SourceFile:166)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6494)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

Environment

Tested on multiple different Android versions both using a physical device and emulators.

DeviceAndroid VersionEmulator/PhysicalReproducible?
Motorola 3 (3rd Generation)6.0.1PhysicalNo
Pixel 26.0EmulatedNo
Pixel 27.1EmulatedNo
Pixel 28.0EmulatedYes

Application Version: 4.0.3

Recording of the issue

The following video shows the issue in more detail, the video was taken on the 8.0 emulator.

Proof of work

H2
H3
H4
3 columns
2 columns
1 column
6 Comments