Skip to content
Next Next commit
Added updateTargetStateWithErrorState() method
  • Loading branch information
ChloeMJM committed Sep 13, 2022
commit 769349c965901d1e10a8bad5cb2599710138a492
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.smartdevicelink.managers.screen;

import android.util.Log;

import com.livio.taskmaster.Task;
import com.smartdevicelink.managers.CompletionListener;
import com.smartdevicelink.managers.ISdl;
Expand All @@ -24,6 +26,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;

/**
* Created by Julian Kast on 8/23/20.
Expand All @@ -40,6 +43,8 @@ class TextAndGraphicUpdateOperation extends Task {
private final CompletionListener listener;
private Show fullShow;

private boolean errorState;

TextAndGraphicUpdateOperation(ISdl internalInterface, FileManager fileManager, WindowCapability currentCapabilities,
TextAndGraphicState currentScreenData, TextAndGraphicState newState, CompletionListener listener, TextAndGraphicManager.CurrentScreenDataUpdatedListener currentScreenDataUpdateListener) {
super("TextAndGraphicUpdateOperation");
Expand Down Expand Up @@ -92,6 +97,29 @@ public void onComplete(boolean success) {
}
}

void updateTargetStateWithErrorState(TextAndGraphicState errorState){
updatedState.setTextField1(errorState.getTextField1().equals(updatedState.getTextField1()) ? currentScreenData.getTextField1() : updatedState.getTextField1());
updatedState.setTextField2(errorState.getTextField2().equals(updatedState.getTextField2()) ? currentScreenData.getTextField2() : updatedState.getTextField2());
updatedState.setTextField3(errorState.getTextField3().equals(updatedState.getTextField3()) ? currentScreenData.getTextField3() : updatedState.getTextField3());
updatedState.setTextField4(errorState.getTextField4().equals(updatedState.getTextField4()) ? currentScreenData.getTextField4() : updatedState.getTextField4());

updatedState.setMediaTrackTextField(errorState.getMediaTrackTextField().equals(updatedState.getMediaTrackTextField()) ? currentScreenData.getMediaTrackTextField() : updatedState.getMediaTrackTextField());

updatedState.setTitle(errorState.getTitle().equals(updatedState.getTitle()) ? currentScreenData.getTitle() : updatedState.getTitle());

updatedState.setPrimaryGraphic(errorState.getPrimaryGraphic().equals(updatedState.getPrimaryGraphic()) ? currentScreenData.getPrimaryGraphic() : updatedState.getPrimaryGraphic());
updatedState.setSecondaryGraphic(errorState.getSecondaryGraphic().equals(updatedState.getSecondaryGraphic()) ? currentScreenData.getSecondaryGraphic() : updatedState.getSecondaryGraphic());

updatedState.setTextAlignment(errorState.getTextAlignment().equals(updatedState.getTextAlignment()) ? currentScreenData.getTextAlignment() : updatedState.getTextAlignment());

updatedState.setTextField1Type(errorState.getTextField1Type().equals(updatedState.getTextField1Type()) ? currentScreenData.getTextField1Type() : updatedState.getTextField1Type());
updatedState.setTextField2Type(errorState.getTextField2Type().equals(updatedState.getTextField2Type()) ? currentScreenData.getTextField2Type() : updatedState.getTextField2Type());
updatedState.setTextField3Type(errorState.getTextField3Type().equals(updatedState.getTextField3Type()) ? currentScreenData.getTextField3Type() : updatedState.getTextField3Type());
updatedState.setTextField4Type(errorState.getTextField4Type().equals(updatedState.getTextField4Type()) ? currentScreenData.getTextField4Type() : updatedState.getTextField4Type());

updatedState.setTemplateConfiguration(errorState.getTemplateConfiguration().equals(updatedState.getTemplateConfiguration()) ? currentScreenData.getTemplateConfiguration() : updatedState.getTemplateConfiguration());
}

void updateGraphicsAndShow(Show show) {
if (!shouldUpdatePrimaryImage() && !shouldUpdateSecondaryImage()) {
DebugTool.logInfo(TAG, "No images to send, sending text");
Expand Down Expand Up @@ -129,7 +157,6 @@ public void onComplete(boolean success) {
finishOperation(success);
}
});

}
});
}
Expand All @@ -144,7 +171,7 @@ public void onResponse(int correlationId, RPCResponse response) {
updateCurrentScreenDataFromShow(show);
} else {
DebugTool.logInfo(TAG, "Text and Graphic Show failed");
currentScreenDataUpdateListener.onError();
currentScreenDataUpdateListener.onError(updatedState);
}
listener.onComplete(response.getSuccess());

Expand All @@ -154,11 +181,10 @@ public void onResponse(int correlationId, RPCResponse response) {
internalInterface.get().sendRPC(show);
} else {
DebugTool.logInfo(TAG, "ISdl is null Text and Graphic update failed");
currentScreenDataUpdateListener.onError();
currentScreenDataUpdateListener.onError(updatedState);
finishOperation(false);
return;
}

}

@SuppressWarnings("deprecation")
Expand All @@ -171,7 +197,7 @@ public void onResponse(int correlationId, RPCResponse response) {
updateCurrentScreenDataFromSetDisplayLayout(setLayout);
} else {
DebugTool.logInfo(TAG, "Text and Graphic SetDisplayLayout failed");
currentScreenDataUpdateListener.onError();
currentScreenDataUpdateListener.onError(updatedState);
}
listener.onComplete(response.getSuccess());
}
Expand All @@ -180,7 +206,7 @@ public void onResponse(int correlationId, RPCResponse response) {
internalInterface.get().sendRPC(setLayout);
} else {
DebugTool.logInfo(TAG, "ISdl is null Text and Graphic update failed");
currentScreenDataUpdateListener.onError();
currentScreenDataUpdateListener.onError(updatedState);
finishOperation(false);
return;
}
Expand Down