Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug with spinner for vitamin_a in ProductEditNutritionFactsFragment #3821

Conversation

naivekook
Copy link
Contributor

@naivekook naivekook commented Feb 8, 2021

Description

Found a bug for "vitamin_a" nutrinion in ProductEditNutritionFactsFragment.kt when we try to add row

2021-02-08 19:01:00.312 869-869/openfoodfacts.github.scrachx.openfood.debug E/AndroidRuntime: FATAL EXCEPTION: main
    Process: openfoodfacts.github.scrachx.openfood.debug, PID: 869
    java.lang.ArrayIndexOutOfBoundsException: length=3; index=4
        at java.util.Arrays$ArrayList.get(Arrays.java:3769)
        at android.widget.ArrayAdapter.getItem(ArrayAdapter.java:393)
        at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:449)
        at android.widget.ArrayAdapter.getView(ArrayAdapter.java:415)
        at android.widget.Spinner.makeView(Spinner.java:712)
        at android.widget.Spinner.layout(Spinner.java:660)
        at android.widget.Spinner.onLayout(Spinner.java:622)

Related issues

not found

Related PRs

not found

Screenshots

|Screenshot_1613045536

@teolemon teolemon requested a review from VaiTon February 8, 2021 18:50
@teolemon teolemon added the editing Issues relating to allowing the user to edit products label Feb 8, 2021
@teolemon teolemon requested a review from a team February 9, 2021 13:33
@teolemon teolemon force-pushed the bug/fix-product-edit-nutrinions-vitamins branch from dff7c4f to 25cbf62 Compare February 10, 2021 18:58
@naivekook
Copy link
Contributor Author

@VaiTon please take a look again

@@ -647,16 +640,18 @@ class ProductEditNutritionFactsFragment : ProductEditFragment() {
}

private fun displayAddNutrientDialog() {
val origNutrients = resources.getStringArray(R.array.nutrients_array).toMutableList()
usedNutrientsIndexes.forEach { origNutrients.removeAt(it) }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there was an IndexOutOfBoundsException

@naivekook naivekook force-pushed the bug/fix-product-edit-nutrinions-vitamins branch from a0d2a4c to 3aa79f9 Compare February 15, 2021 07:44
@sonarcloud
Copy link

sonarcloud bot commented Feb 15, 2021

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@naivekook
Copy link
Contributor Author

@teolemon PR is ready to go

@VaiTon VaiTon merged commit c0c11ce into openfoodfacts:develop Feb 17, 2021
@naivekook naivekook deleted the bug/fix-product-edit-nutrinions-vitamins branch February 18, 2021 07:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
editing Issues relating to allowing the user to edit products
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants