Browse Source

ResetView on invalid eventLog

hbw_build
Wong Joon Hui 3 years ago
parent
commit
f1c0dc955a
  1. 14
      app/src/main/java/com/cst/im30/activity/MainActivity.java
  2. 57
      app/src/main/java/com/cst/im30/service/IDVerificationService.java

14
app/src/main/java/com/cst/im30/activity/MainActivity.java

@ -382,6 +382,11 @@ public class MainActivity extends AppCompatActivity implements CallableInterface
if (source.equalsIgnoreCase(IDVerificationService.SUCCESS_GET_EVENT_LOG)) { if (source.equalsIgnoreCase(IDVerificationService.SUCCESS_GET_EVENT_LOG)) {
EventLogDetailed incomingEventLogDetailed = (EventLogDetailed) object; EventLogDetailed incomingEventLogDetailed = (EventLogDetailed) object;
if (incomingEventLogDetailed == null) {
resetView();
return;
}
boolean cancelAction = incomingEventLogDetailed.getAction().equalsIgnoreCase(Constants.IC_FUNCTION_CANCEL); boolean cancelAction = incomingEventLogDetailed.getAction().equalsIgnoreCase(Constants.IC_FUNCTION_CANCEL);
if (cancelAction) { if (cancelAction) {
if (MainApplication.working && MainApplication.currentActivity instanceof ICCActivity) { if (MainApplication.working && MainApplication.currentActivity instanceof ICCActivity) {
@ -416,6 +421,11 @@ public class MainActivity extends AppCompatActivity implements CallableInterface
else if (source.equalsIgnoreCase(PaymentService.SUCCESS_GET_EVENT_LOG)) { else if (source.equalsIgnoreCase(PaymentService.SUCCESS_GET_EVENT_LOG)) {
EventLogDetailed incomingEventLogDetailed = (EventLogDetailed) object; EventLogDetailed incomingEventLogDetailed = (EventLogDetailed) object;
if (incomingEventLogDetailed == null) {
resetView();
return;
}
boolean cancelPayFunction = incomingEventLogDetailed.getPayFunction().equalsIgnoreCase(Constants.PAY_FUNCTION_CANCEL); boolean cancelPayFunction = incomingEventLogDetailed.getPayFunction().equalsIgnoreCase(Constants.PAY_FUNCTION_CANCEL);
if (cancelPayFunction) { if (cancelPayFunction) {
// Cancel whether working or not at the moment // Cancel whether working or not at the moment
@ -554,12 +564,12 @@ public class MainActivity extends AppCompatActivity implements CallableInterface
} }
private void initEchoClientIC() { private void initEchoClientIC() {
//Logger.logD("echoClient IC: " + BuildConfig.ECHO_SERVER_URL + ":" + BuildConfig.ECHO_SERVER_PORT); Logger.logD("echoClient IC: " + BuildConfig.ECHO_SERVER_URL + ":" + BuildConfig.ECHO_SERVER_PORT);
MainApplication.icClient = new EchoClient(BuildConfig.ECHO_SERVER_URL + ":" + BuildConfig.ECHO_SERVER_PORT); MainApplication.icClient = new EchoClient(BuildConfig.ECHO_SERVER_URL + ":" + BuildConfig.ECHO_SERVER_PORT);
} }
private void initEchoClientPayment() { private void initEchoClientPayment() {
//Logger.logD("echoClient Payment: " + BuildConfig.ECHO_SERVER_URL + ":" + BuildConfig.ECHO_SERVER_PORT); Logger.logD("echoClient Payment: " + BuildConfig.ECHO_SERVER_URL + ":" + BuildConfig.ECHO_SERVER_PORT);
MainApplication.paymentClient = new EchoClient(BuildConfig.ECHO_SERVER_URL + ":" + BuildConfig.ECHO_SERVER_PORT); MainApplication.paymentClient = new EchoClient(BuildConfig.ECHO_SERVER_URL + ":" + BuildConfig.ECHO_SERVER_PORT);
} }

57
app/src/main/java/com/cst/im30/service/IDVerificationService.java

@ -177,30 +177,39 @@ public class IDVerificationService {
} }
private EventLogDetailed parseGetEventLogResponse(JSONObject jsonObject) throws Exception { private EventLogDetailed parseGetEventLogResponse(JSONObject jsonObject) throws Exception {
String type = jsonObject.getJSONObject("data").getString("type"); if (jsonObject.has("data")) {
String status = jsonObject.getJSONObject("data").getString("status"); try {
String action = jsonObject.getJSONObject("data").getString("action"); String type = jsonObject.getJSONObject("data").getString("type");
String documentType = jsonObject.getJSONObject("data").getJSONObject("content").getString("document_type"); String status = jsonObject.getJSONObject("data").getString("status");
String documentNumber = jsonObject.getJSONObject("data").getJSONObject("content").getString("document_number"); String action = jsonObject.getJSONObject("data").getString("action");
String firstName = jsonObject.getJSONObject("data").getJSONObject("content").getString("first_name"); String documentType = jsonObject.getJSONObject("data").getJSONObject("content").getString("document_type");
String lastName = jsonObject.getJSONObject("data").getJSONObject("content").getString("last_name"); String documentNumber = jsonObject.getJSONObject("data").getJSONObject("content").getString("document_number");
String id = jsonObject.getJSONObject("data").getJSONObject("content").getString("id"); String firstName = jsonObject.getJSONObject("data").getJSONObject("content").getString("first_name");
String confirmationNumber = jsonObject.getJSONObject("data").getJSONObject("content").getString("confirmation_number"); String lastName = jsonObject.getJSONObject("data").getJSONObject("content").getString("last_name");
String profileOperaId = jsonObject.getJSONObject("data").getJSONObject("content").getString("profile_id_opera"); String id = jsonObject.getJSONObject("data").getJSONObject("content").getString("id");
String confirmationNumber = jsonObject.getJSONObject("data").getJSONObject("content").getString("confirmation_number");
EventLogDetailed eventLogDetailed = new EventLogDetailed(); String profileOperaId = jsonObject.getJSONObject("data").getJSONObject("content").getString("profile_id_opera");
eventLogDetailed.setAction(action);
eventLogDetailed.setType(type); EventLogDetailed eventLogDetailed = new EventLogDetailed();
eventLogDetailed.setStatus(status); eventLogDetailed.setAction(action);
eventLogDetailed.setDocumentType(documentType); eventLogDetailed.setType(type);
eventLogDetailed.setDocumentNumber(documentNumber); eventLogDetailed.setStatus(status);
eventLogDetailed.setFirstName(firstName); eventLogDetailed.setDocumentType(documentType);
eventLogDetailed.setLastName(lastName); eventLogDetailed.setDocumentNumber(documentNumber);
eventLogDetailed.setId(Integer.parseInt(id)); eventLogDetailed.setFirstName(firstName);
eventLogDetailed.setConfirmationNumber(confirmationNumber); eventLogDetailed.setLastName(lastName);
eventLogDetailed.setProfileIdOpera(profileOperaId); eventLogDetailed.setId(Integer.parseInt(id));
eventLogDetailed.setConfirmationNumber(confirmationNumber);
return eventLogDetailed; eventLogDetailed.setProfileIdOpera(profileOperaId);
return eventLogDetailed;
} catch (Exception e) {
Logger.logE(e.getMessage());
e.printStackTrace();
return null;
}
}
return null;
} }
} }

Loading…
Cancel
Save