openfoodfacts / openfoodfacts-androidapp

(Legacy) Native version of Open Food Facts on Android - Coders & Decoders welcome 🤳🥫
https://android.openfoodfacts.org
Apache License 2.0
767 stars 447 forks source link

Clean LoadTaxonomiesService#doTask #2904

Closed deniger closed 3 years ago

deniger commented 4 years ago

openfoodfacts.github.scrachx.openfood.views.LoadTaxonomiesService#doTask this method loads labels,tags, allergens, ingredients, countries, additivces and categories according to the application

this task can be simplified as the configuration is now done in openfoodfacts.github.scrachx.openfood.views.splash.SplashPresenter#refreshData

Abhisek2090 commented 4 years ago

I'd like to work on the issue. Can you please more in detail about the issue and expected changes to be done.

deniger commented 4 years ago

in openfoodfacts.github.scrachx.openfood.views.splash.SplashPresenter#refreshData we specify what should be downloaded or not.

But in LoadTaxonomiesService#doTask we use a if/elseif to filter what should be downloaded. So only the lines 48 -> 72 ( off) should be kept

Abhisek2090 commented 4 years ago

In LoadTaxonomiesService#doTask the if/elseif filter is based on BuildConfig.FLAVOR while the if else in SplashPresenter.refreshData is not based on the same criteria. Correct me if am wrong.

deniger commented 4 years ago

in refreshData, we initialize settings based on BuildConfig.FLAVOR in order to activate downloads in doTask we use BuildConfig.FLAVOR to filter download and then in ProductRepository#getXXX we use the settings to perform or not the downloads...

Abhisek2090 commented 4 years ago

"in refreshData, we initialize settings based on BuildConfig.FLAVOR". can you point out in the code where this is happening. I'm unable to find this.

deniger commented 4 years ago

here: https://github.com/openfoodfacts/openfoodfacts-androidapp/blob/fed0f18ffd017b047da455b6e8f50e983ae13c26/app/src/main/java/openfoodfacts/github/scrachx/openfood/views/splash/SplashPresenter.java#L43

and then this intialization is used in ProductRepository : https://github.com/openfoodfacts/openfoodfacts-androidapp/blob/fed0f18ffd017b047da455b6e8f50e983ae13c26/app/src/main/java/openfoodfacts/github/scrachx/openfood/repositories/ProductRepository.java#L491

deniger commented 4 years ago

@Abhisek2090 I will work on https://github.com/openfoodfacts/openfoodfacts-androidapp/pull/2871/files. A new taxonomy is downloaded and we will simplify the whole thing This issue will be closed. I propose that you review my modifications to be sure everything is ok Is it ok for you ?

Abhisek2090 commented 4 years ago

@deniger .Yes, its fine with me. Will review the modifications when done. Thank you for your guidance.