This version contains a lot of changes both in the UI and the back-end of the code base.
All the major changes are listed below:
🛠 Implementation of a ListView: The main activity of the App (CatalogActivity.java) now consists of a ListView instead of the TextView as in v1.3 of the app. The ListView shows the list of the pets saved in the database. The ListView uses the CursorAdapter to request for data (more info about this below).
🛠 Implementation of a CursorAdapter: This version uses a custom PetCursorAdapter which extends from the CursorAdapter. The PetCursorAdapter takes a cursor as an input and inflates an item and passes it off to the ListView.
🛠 Adding of an EmptyView: When there are no pets in the database or no "data" in the database table, the CatalogActivity shows an Empty View which asks user to add some pets. This feature was added for the betterment of the User Experience(UX).
🛠 Implementation of the CursorLoader: Implementation of CursorLoader using a LoaderManager. Loaders run on separate thread to prevent unresponsive UI while querying the database. They simplify thread management by providing callback events when events occur.
🛠Two modes of the EditorActivity: The EditorActivity has now two different modes. One is when the user wants to add a new pet while the other is for when the data of an existing pet needs to be modified. The latter part consists of querying the database for the current data on the pet and load it into corresponding views.
🛠 Preventing app crash when entering blank data: The app crashed when the user did not entered any data into the fields of the EditorActivity. This has now been resolved by adding certain checks. So, no more crashing😉.
🛠 Unsaved Changes Warning: If the user presses the back or the "up" button by mistake while editing the data for a pet the app now shows the user a warning message about the unsaved changes. The user has the option to keep continuing editing the data or discard the changes made.
🛠 Delete functionality added: Delete functionality has now been added to the app. Delete pets by clicking on them and selecting the delete pet option in the menu of the EditorActivity that opens up.
🛠 Hiding the Delete Pet option for a new Pet: When adding a new pet, deleting the pet just doesn't make sense. You can't delete something that just never existed! Therefore, the menu option Delete Pet is hidden when adding a new pet into the database.
🛠 Delete All Pets: You can delete all of the pets in the database just by tapping on the Delete All Pets option in the CatalogActivity. Beware that this will clear out the entire database and delete all the pets data.
🛠 Adding the Unknown Breed in the ListView: When a breed of a pet is not known, the ListView just shows a blank space there. To improve the User Experience (UX), "Unknown Breed" is now being displayed instead of just a blank space.
Before the change: