Source:
protected void onHandleIntent(Intent intent) { try { TrucksForVendorResponse response = truckService.getTrucksForVendor(new TrucksForVendorRequest()); List<Truck> trucks = response.trucks; ContentValues[] contentValues = new ContentValues[trucks.size()]; for (int i = 0, max = trucks.size(); i < max; i++) { Truck truck = trucks.get(i); ContentValues values = new ContentValues(); values.put(PublicContract.Truck.ID, truck.id); values.put(PublicContract.Truck.NAME, truck.name); values.put(PublicContract.Truck.IMAGE_URL, truck.imageUrl); values.put(PublicContract.Truck.KEYWORDS, Contract.convertListToString(truck.keywords)); values.put(PublicContract.Truck.COLOR_PRIMARY, truck.primaryColor); values.put(PublicContract.Truck.COLOR_SECONDARY, truck.secondaryColor); values.put(PublicContract.Truck.OWNED_BY_CURRENT_USER, 1); contentValues[i] = values; } getContentResolver().bulkInsert(Contract.TRUCK_PROPERTIES_URI, contentValues); } catch (SocialCredentialsException sce) { throw new UnsupportedOperationException("not yet implemented"); } catch (ExpiredSessionException ese) { AuthResponse response = authService.getAuth(new AuthRequest()); Account account = AccountGeneral.getStoredAccount(accountManager); accountManager.setUserData(account, AuthenticatedRequestInterceptor.SESSION_TOKEN, response.sessionToken); startService(intent); } catch (ApiException e) { Timber.e("Got an error while getting trucks for vendor."); Intent errorIntent = new Intent(); errorIntent.putExtra(ARG_MESSAGE, e.getMessage()); LocalBroadcastManager.getInstance(VendorTrucksService.this).sendBroadcast(errorIntent); } }

Target:
protected void onHandleIntent(Intent intent) { try { TrucksForVendorResponse response = truckService.getTrucksForVendor(new TrucksForVendorRequest()); List<Truck> trucks = response.trucks; ContentValues[] propertiesContentValues = new ContentValues[trucks.size()]; ContentValues[] stateContentValues = new ContentValues[trucks.size()]; for (int i = 0, max = trucks.size(); i < max; i++) { Truck truck = trucks.get(i); ContentValues propertiesValues = new ContentValues(); propertiesValues.put(PublicContract.Truck.ID, truck.id); propertiesValues.put(PublicContract.Truck.NAME, truck.name); propertiesValues.put(PublicContract.Truck.IMAGE_URL, truck.imageUrl); propertiesValues.put(PublicContract.Truck.KEYWORDS, Contract.convertListToString(truck.keywords)); propertiesValues.put(PublicContract.Truck.COLOR_PRIMARY, truck.primaryColor); propertiesValues.put(PublicContract.Truck.COLOR_SECONDARY, truck.secondaryColor); propertiesContentValues[i] = propertiesValues; ContentValues stateValues = new ContentValues(); stateValues.put(PublicContract.Truck.ID, truck.id); stateValues.put(PublicContract.Truck.OWNED_BY_CURRENT_USER, true); stateContentValues[i] = stateValues; } getContentResolver().bulkInsert(Contract.suppressNotify(Contract.TRUCK_PROPERTIES_URI), propertiesContentValues); getContentResolver().bulkInsert(Contract.TRUCK_STATE_URI, stateContentValues); } catch (SocialCredentialsException sce) { throw new UnsupportedOperationException("not yet implemented"); } catch (ExpiredSessionException ese) { AuthResponse response = authService.getAuth(new AuthRequest()); Account account = AccountGeneral.getStoredAccount(accountManager); accountManager.setUserData(account, AuthenticatedRequestInterceptor.SESSION_TOKEN, response.sessionToken); startService(intent); } catch (ApiException e) { Timber.e("Got an error while getting trucks for vendor."); Intent errorIntent = new Intent(); errorIntent.putExtra(ARG_MESSAGE, e.getMessage()); LocalBroadcastManager.getInstance(VendorTrucksService.this).sendBroadcast(errorIntent); } }