[GrowTracker][v2.5.1] The app crashed when I canceled the photo-taking step.

View this thread on: d.buzz | hive.blog | peakd.com | ecency.com
·@sagorahmed·
0.000 HBD
[GrowTracker][v2.5.1] The app crashed when I canceled the photo-taking step.
#### Related Informations
* Repository: https://github.com/7LPdWcaW/GrowTracker-Android
* Project Name: Grow Tracker
* My Submitted Issue: [here](https://github.com/7LPdWcaW/GrowTracker-Android/issues/87)
* Closes Commit: [here](https://github.com/7LPdWcaW/GrowTracker-Android/commit/660abd7738bd13f4ba0559cd8bf90f837f3f5bca)
* My GitHub Account: [here](https://github.com/sagorahmed)

#### Expected behavior
The users should be able to cancel the photo-taking step before adding a photo to plant details.

#### Actual behavior
When I tried to add a photo in a planted details and canceled the photo-taking step, then the app crashed.

#### How to reproduce
Here is every possible detail to reproduce the bug.
1. Open the app.
2. Add a new plant and save it.
3. Open that created plant.
4. Then go to the "Photo" tab and select "From camera" to add a photo in that plant details.
5. The list of the camera apps would appear on your phone's screen.
6. Don't click on anything, just press the back button of your phone and notice the crash. 

* App version: 2.5.1
* Operating system: Android 6.0.1

#### Recording Of The Bug
![bug](https://media.giphy.com/media/UWhsCMiU54f20t2nie/giphy.gif)

#### LogCat
```
06-26 23:41:44.812  6155  6155 E AndroidRuntime: FATAL EXCEPTION: main

06-26 23:41:44.812  6155  6155 E AndroidRuntime: Process: me.anon.grow, PID: 6155

06-26 23:41:44.812  6155  6155 E AndroidRuntime: java.lang.RuntimeException: Failure delivering result ResultInfo{who=android:fragment:1, request=1, result=0, data=null} to activity {me.anon.grow/me.anon.grow.PlantDetailsActivity}: java.lang.ArrayIndexOutOfBoundsException: length=12; index=-1

06-26 23:41:44.812  6155  6155 E AndroidRuntime: 	at android.app.ActivityThread.deliverResults(ActivityThread.java:4998)

06-26 23:41:44.812  6155  6155 E AndroidRuntime: 	at android.app.ActivityThread.handleSendResult(ActivityThread.java:5041)

06-26 23:41:44.812  6155  6155 E AndroidRuntime: 	at android.app.ActivityThread.access$1600(ActivityThread.java:229)

06-26 23:41:44.812  6155  6155 E AndroidRuntime: 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1875)

06-26 23:41:44.812  6155  6155 E AndroidRuntime: 	at android.os.Handler.dispatchMessage(Handler.java:102)

06-26 23:41:44.812  6155  6155 E AndroidRuntime: 	at android.os.Looper.loop(Looper.java:148)

06-26 23:41:44.812  6155  6155 E AndroidRuntime: 	at android.app.ActivityThread.main(ActivityThread.java:7325)

06-26 23:41:44.812  6155  6155 E AndroidRuntime: 	at java.lang.reflect.Method.invoke(Native Method)

06-26 23:41:44.812  6155  6155 E AndroidRuntime: 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)

06-26 23:41:44.812  6155  6155 E AndroidRuntime: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)

06-26 23:41:44.812  6155  6155 E AndroidRuntime: Caused by: java.lang.ArrayIndexOutOfBoundsException: length=12; index=-1

06-26 23:41:44.812  6155  6155 E AndroidRuntime: 	at java.util.ArrayList.get(ArrayList.java:310)

06-26 23:41:44.812  6155  6155 E AndroidRuntime: 	at me.anon.grow.fragment.PlantDetailsFragment.onActivityResult(PlantDetailsFragment.java:445)

06-26 23:41:44.812  6155  6155 E AndroidRuntime: 	at android.app.Activity.dispatchActivityResult(Activity.java:7189)

06-26 23:41:44.812  6155  6155 E AndroidRuntime: 	at android.app.ActivityThread.deliverResults(ActivityThread.java:4994)

06-26 23:41:44.812  6155  6155 E AndroidRuntime: 	... 9 more
```
👍 , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,