ArrayIndexOutOfBoundsException occuring when attempting to edit an already existing item in the database.
License and Copyright Notice
By submitting this issue or commenting on this issue, or contributing any content to this issue, you certify under the Developer Certificate of Origin that the content you post may be licensed under GPLv3 (for code) or CC-BY-SA 4.0 International (for non-code content).
Summary
When scanning an item that has already been scanned at least once, ie it already exists in the database, if the user chooses incorrect and attempts to edit the data for the scanned item, if the user hits Accept after providing new data for the item, the app crashes.
Steps to reproduce
I like to clear all data associated with the app by uninstalling the app from the device I am testing it on and reinstalling it via Android Studio.
Scan the item.
You will be taken to SelectItemFragment:
Input Brand Name
Input Description
Select a "Category", "Product", and "Type" (if required)
Hit "Accept"
You will be taken to SelectPrintedExpirationDateFragment:
Input the expiration date
Hit "Accept"
You will be taken to DisplayTrueExpirationFragment:
Hit "Display True Expiration Date"
Close the app, and restart the app.
Scan the item again.
You will be taken to ConfirmItemFragment:
Hit "Incorrect"
You will be taken to SelectItemFragment:
Input Brand Name
Input Description
Select a "Category", "Product", and "Type" (if required)
Hit "Accept"
What is the current bug behavior?
As soon as the user hits the "Accept" button after following the above sequence of steps, the app crashes completely.
What is the expected correct behavior?
The expected behavior is that once a new set of information is input for the item (after hitting Incorrect while in ConfirmItemFragment), the app should accept the newly edited information and replace the data in the entry with this new data without crashing such that the user can reach DisplayTrueExpirationFragment and get an accurate True Expiration Date.
Relevant logs and/or screenshots
E/AndroidRuntime: FATAL EXCEPTION: main
Process: edu.ncc.nest.nestapp, PID: 12141
android.view.InflateException: Binary XML file line #30 in edu.ncc.nest.nestapp:layout/activity_check_expiration_date: Binary XML file line #35 in edu.ncc.nest.nestapp:layout/content_check_expiration_date: Error inflating class fragment
Caused by: android.view.InflateException: Binary XML file line #35 in edu.ncc.nest.nestapp:layout/content_check_expiration_date: Error inflating class fragment
Caused by: java.lang.IllegalArgumentException: Binary XML file line #35: Duplicate id 0x7f090224, tag null, or parent id 0xffffffff with another fragment for androidx.navigation.fragment.NavHostFragment
at androidx.fragment.app.FragmentLayoutInflaterFactory.onCreateView(FragmentLayoutInflaterFactory.java:116)
at androidx.fragment.app.FragmentController.onCreateView(FragmentController.java:135)
at androidx.fragment.app.FragmentActivity.dispatchFragmentsOnCreateView(FragmentActivity.java:319)
at androidx.fragment.app.FragmentActivity.onCreateView(FragmentActivity.java:298)
at android.view.LayoutInflater.tryCreateView(LayoutInflater.java:1067)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:995)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:959)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:1121)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1082)
at android.view.LayoutInflater.parseInclude(LayoutInflater.java:1261)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:1117)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1082)
at android.view.LayoutInflater.inflate(LayoutInflater.java:680)
at android.view.LayoutInflater.inflate(LayoutInflater.java:532)
at android.view.LayoutInflater.inflate(LayoutInflater.java:479)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:707)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:195)
at edu.ncc.nest.nestapp.CheckExpirationDate.Activities.CheckExpirationDateActivity.onLoadSuccess(CheckExpirationDateActivity.java:53)
at edu.ncc.nest.nestapp.CheckExpirationDate.DatabaseClasses.NestDBDataSource$NestDBActivity$1.lambda$onPostExecute$0$NestDBDataSource$NestDBActivity$1(NestDBDataSource.java:423)
at edu.ncc.nest.nestapp.CheckExpirationDate.DatabaseClasses.-$$Lambda$NestDBDataSource$NestDBActivity$1$Yb2zWoyGLWKNfP2WWUyvnV_5_DM.onClick(Unknown Source:4)
at androidx.appcompat.app.AlertController$ButtonHandler.handleMessage(AlertController.java:167)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:246)
at android.app.ActivityThread.main(ActivityThread.java:8512)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
Possible fixes
This crash is occurring because the code for handling database edits hasn't yet been written in, so the fix will require filling in that code block with relevant code for updating database entries.
Weight
I want to justify the weight I gave to this. I think this issue should be weighted at 3 because I could see users accidentally inputting wrong information, going back to the SelectItemFragment screen, re-entering correct information, only to have the app crash. It would make it impossible to move forward with determining true expiration dates for those incorrectly input items. For this reason, I believe this issue should be weighted at a level 3.
Labels
component::check-expiration-date
type::bug
status::doing