Samagra-Development / odk-collect-extension

ODK Collect is an Android app for filling out forms. ODK Collect Extensions is a layer on top of ODK Collect to make it easier to integrate inside existing Android apps.
https://docs.getodk.org/collect-intro
Apache License 2.0
5 stars 18 forks source link

Fixed Sample app crash caused by accessing uninitialized object #53

Closed 098suraj closed 1 year ago

098suraj commented 1 year ago

Closes #52

What has been done to verify that this works as intended?

Built and tested the app on emulator and physical device.

Why is this the best possible solution? Were any other approaches considered?

while the formsDatabaseInteractor, networkInteractor objects are being initialized, we use a circular progress bar to show the loading state of app, in addition to that we can disable the buttons downloadFormsButton , downloadAllFormsButton , clearAllFormsButton to prevent exception and once the objects are initialized we can enable them. fix -> when not Initialized

downloadFormsButton.isEnabled=false
downloadAllFormsButton.isEnabled=false
clearAllFormsButton.isEnabled=false

once they are initialized

 downloadFormsButton.isEnabled=true
 downloadAllFormsButton.isEnabled=true
 clearAllFormsButton.isEnabled=true

the case when the crash was happening - when the user taps on these buttons downloadFormsButton , downloadAllFormsButton , clearAllFormsButton while object is not initialized.

How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?

it will help in preventing app crash caused by accessing uninitialized object formsDatabaseInteractor, networkInteractor

Do we need any specific form for testing your changes? If so, please attach one.

No

chinmoy12c commented 1 year ago

Hey, @098suraj thanks for the contribution. This looks fine :+1: . Could you also change the commit message to reflect what the actual fix was?

098suraj commented 1 year ago

Hey, @chinmoy12c thanks for looking into the PR, I changed the commit message and Issue title for a better idea, please let me know if there is anything yet to be changed .