Skip to content

Fix delete button crashes - #148

Open
kvanc99peltek wants to merge 1 commit into
karlmorris:masterfrom
kvanc99peltek:fix-bugs
Open

Fix delete button crashes#148
kvanc99peltek wants to merge 1 commit into
karlmorris:masterfrom
kvanc99peltek:fix-bugs

Conversation

@kvanc99peltek

@kvanc99peltek kvanc99peltek commented Feb 18, 2026

Copy link
Copy Markdown

Summary

  • Bug 1 – Hardcoded getCount(): CustomAdapter.getCount() was always returning 5 instead of names.size. After deleting a name the adapter still thought there were 5 items, so it tried to access indices that didn't exist anymore and threw an IndexOutOfBoundsException. Fixed it by returning names.size instead.
  • Bug 2 – No empty-list guard on delete: If you deleted all the names and hit delete again, the app crashed because removeAt() was called on an empty list. Added an isNotEmpty() check before removing, and also clear the text view when the list is empty.

Bug 1: CustomAdapter.getCount() was hardcoded to return 5 instead of
the actual list size. After deleting a name, the adapter still reported
5 items, causing an IndexOutOfBoundsException. Fixed by returning
names.size.

Bug 2: The delete button had no guard for an empty list. Pressing
delete after all names were removed caused a crash. Fixed by checking
names.isNotEmpty() before removing, and clearing the text view when
the list becomes empty.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant