Skip to content

Commit

Permalink
Removing unnecessary multi-threading to avoid relevance issues
Browse files Browse the repository at this point in the history
  • Loading branch information
hamza-vd committed Aug 4, 2023
1 parent e9eaac7 commit a5c5151
Showing 1 changed file with 39 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -372,41 +372,37 @@ public Pair<String[], JSONObject> getCalculationAddressAndValue(View view) throw

@Override
public void refreshCalculationLogic(String parentKey, String childKey, boolean popup, String stepName, boolean isForNextStep) {
appExecutors.diskIO().execute(() ->{
Set<String> viewsIds = calculationDependencyMap.get(stepName + "_" + parentKey);
if (parentKey == null || viewsIds == null)
viewsIds = calculationLogicViews.keySet();
for (String viewId : viewsIds) {
try {
View curView = calculationLogicViews.get(viewId);
if (curView == null) {
Timber.w("calculationLogicViews Missing %s", viewId);
continue;
Set<String> viewsIds = calculationDependencyMap.get(stepName + "_" + parentKey);
if (parentKey == null || viewsIds == null)
viewsIds = calculationLogicViews.keySet();
for (String viewId : viewsIds) {
try {
View curView = calculationLogicViews.get(viewId);
if (curView == null) {
Timber.w("calculationLogicViews Missing %s", viewId);
continue;
}
Pair<String[], JSONObject> addressAndValue = getCalculationAddressAndValue(curView);
if (addressAndValue != null && addressAndValue.first != null) {
String[] address = addressAndValue.first;
JSONObject valueSource = addressAndValue.second;
Facts curValueMap;
if (valueSource.length() > 0) {
curValueMap = getValueFromAddress(address, popup, valueSource);
} else {
curValueMap = getValueFromAddress(address, popup);
}
Pair<String[], JSONObject> addressAndValue = getCalculationAddressAndValue(curView);
if (addressAndValue != null && addressAndValue.first != null) {
String[] address = addressAndValue.first;
JSONObject valueSource = addressAndValue.second;
Facts curValueMap;
if (valueSource.length() > 0) {
curValueMap = getValueFromAddress(address, popup, valueSource);
} else {
curValueMap = getValueFromAddress(address, popup);
}
//update ui
appExecutors.mainThread().execute(() -> {
updateCalculation(curValueMap, curView, address, isForNextStep);
});
//update ui
updateCalculation(curValueMap, curView, address, isForNextStep);

}
}

} catch (Exception e) {
Timber.e(e, "%s refreshCalculationLogic()", this.getClass().getCanonicalName());
} catch (Exception e) {
Timber.e(e, "%s refreshCalculationLogic()", this.getClass().getCanonicalName());

}
}
}

});

}

Expand Down Expand Up @@ -629,26 +625,24 @@ public JSONObject getObjectUsingAddress(String[] address, boolean popup, JSONObj
*/
@Override
public void refreshConstraints(String parentKey, String childKey, boolean popup) {
appExecutors.diskIO().execute(()->{
initComparisons();
initComparisons();

// Priorities constraints on the view that has just been changed
String changedViewKey = parentKey;
if (changedViewKey != null && childKey != null) {
changedViewKey = changedViewKey + ":" + childKey;
}
// Priorities constraints on the view that has just been changed
String changedViewKey = parentKey;
if (changedViewKey != null && childKey != null) {
changedViewKey = changedViewKey + ":" + childKey;
}

if (changedViewKey != null && (constrainedViews != null && constrainedViews.containsKey(changedViewKey))) {
checkViewConstraints(constrainedViews.get(changedViewKey), popup);
}
if (changedViewKey != null && (constrainedViews != null && constrainedViews.containsKey(changedViewKey))) {
checkViewConstraints(constrainedViews.get(changedViewKey), popup);
}

for (View curView : constrainedViews.values()) {
String viewKey = getViewKey(curView);
if (changedViewKey == null || (!TextUtils.isEmpty(viewKey) && !viewKey.equals(changedViewKey))) {
checkViewConstraints(curView, popup);
}
for (View curView : constrainedViews.values()) {
String viewKey = getViewKey(curView);
if (changedViewKey == null || (!TextUtils.isEmpty(viewKey) && !viewKey.equals(changedViewKey))) {
checkViewConstraints(curView, popup);
}
});
}

}

Expand Down

0 comments on commit a5c5151

Please sign in to comment.