Skip to content

Commit

Permalink
fix: Save Product Images to the database only when there is an update…
Browse files Browse the repository at this point in the history
…/change
  • Loading branch information
kaushiknsanji committed Nov 8, 2019
1 parent fd9a813 commit d4b641e
Showing 1 changed file with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -798,13 +798,11 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {
private void onExtraProductImagesReceived() {
//If this was received for an Existing Product, update it immediately
//without the user's command
if (mProductId != ProductConfigContract.NEW_PRODUCT_INT) {
int noOfExistingProductImages = mExistingProduct.getProductImages().size();
int noOfProductImagesReceived = mProductImages.size();
if (mProductId > ProductConfigContract.NEW_PRODUCT_INT) {

if (!(noOfExistingProductImages == 0 && noOfProductImagesReceived == noOfExistingProductImages)) {
//Updating the Images to the Database via the Repository when both are not 0
//This check avoids unnecessary updates when both are 0.
if (!mProductImages.equals(mExistingProduct.getProductImages())) {
//Updating the Images to the Database via the Repository when
//there is a mismatch between the list of existing and updated product images

//Saving Product Images via the repository
mStoreRepository.saveProductImages(mExistingProduct, mProductImages, new DataRepository.DataOperationsCallback() {
Expand Down

0 comments on commit d4b641e

Please sign in to comment.