Browse Source

ResetView on invalid eventLog

hbw_build
Wong Joon Hui 2 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)) {
EventLogDetailed incomingEventLogDetailed = (EventLogDetailed) object;
if (incomingEventLogDetailed == null) {
resetView();
return;
}
boolean cancelAction = incomingEventLogDetailed.getAction().equalsIgnoreCase(Constants.IC_FUNCTION_CANCEL);
if (cancelAction) {
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)) {
EventLogDetailed incomingEventLogDetailed = (EventLogDetailed) object;
if (incomingEventLogDetailed == null) {
resetView();
return;
}
boolean cancelPayFunction = incomingEventLogDetailed.getPayFunction().equalsIgnoreCase(Constants.PAY_FUNCTION_CANCEL);
if (cancelPayFunction) {
// Cancel whether working or not at the moment
@ -554,12 +564,12 @@ public class MainActivity extends AppCompatActivity implements CallableInterface
}
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);
}
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);
}

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 {
String type = jsonObject.getJSONObject("data").getString("type");
String status = jsonObject.getJSONObject("data").getString("status");
String action = jsonObject.getJSONObject("data").getString("action");
String documentType = jsonObject.getJSONObject("data").getJSONObject("content").getString("document_type");
String documentNumber = jsonObject.getJSONObject("data").getJSONObject("content").getString("document_number");
String firstName = jsonObject.getJSONObject("data").getJSONObject("content").getString("first_name");
String lastName = jsonObject.getJSONObject("data").getJSONObject("content").getString("last_name");
String id = jsonObject.getJSONObject("data").getJSONObject("content").getString("id");
String confirmationNumber = jsonObject.getJSONObject("data").getJSONObject("content").getString("confirmation_number");
String profileOperaId = jsonObject.getJSONObject("data").getJSONObject("content").getString("profile_id_opera");
EventLogDetailed eventLogDetailed = new EventLogDetailed();
eventLogDetailed.setAction(action);
eventLogDetailed.setType(type);
eventLogDetailed.setStatus(status);
eventLogDetailed.setDocumentType(documentType);
eventLogDetailed.setDocumentNumber(documentNumber);
eventLogDetailed.setFirstName(firstName);
eventLogDetailed.setLastName(lastName);
eventLogDetailed.setId(Integer.parseInt(id));
eventLogDetailed.setConfirmationNumber(confirmationNumber);
eventLogDetailed.setProfileIdOpera(profileOperaId);
return eventLogDetailed;
if (jsonObject.has("data")) {
try {
String type = jsonObject.getJSONObject("data").getString("type");
String status = jsonObject.getJSONObject("data").getString("status");
String action = jsonObject.getJSONObject("data").getString("action");
String documentType = jsonObject.getJSONObject("data").getJSONObject("content").getString("document_type");
String documentNumber = jsonObject.getJSONObject("data").getJSONObject("content").getString("document_number");
String firstName = jsonObject.getJSONObject("data").getJSONObject("content").getString("first_name");
String lastName = jsonObject.getJSONObject("data").getJSONObject("content").getString("last_name");
String id = jsonObject.getJSONObject("data").getJSONObject("content").getString("id");
String confirmationNumber = jsonObject.getJSONObject("data").getJSONObject("content").getString("confirmation_number");
String profileOperaId = jsonObject.getJSONObject("data").getJSONObject("content").getString("profile_id_opera");
EventLogDetailed eventLogDetailed = new EventLogDetailed();
eventLogDetailed.setAction(action);
eventLogDetailed.setType(type);
eventLogDetailed.setStatus(status);
eventLogDetailed.setDocumentType(documentType);
eventLogDetailed.setDocumentNumber(documentNumber);
eventLogDetailed.setFirstName(firstName);
eventLogDetailed.setLastName(lastName);
eventLogDetailed.setId(Integer.parseInt(id));
eventLogDetailed.setConfirmationNumber(confirmationNumber);
eventLogDetailed.setProfileIdOpera(profileOperaId);
return eventLogDetailed;
} catch (Exception e) {
Logger.logE(e.getMessage());
e.printStackTrace();
return null;
}
}
return null;
}
}

Loading…
Cancel
Save