()
| 1046 | /// prevent blocking of actual input and drawing operations. This also |
| 1047 | /// enables functionality such as "true" modal dialogs etc... |
| 1048 | void mainEDTLoop() { |
| 1049 | impl.initEDT(); |
| 1050 | UIManager.getInstance(); |
| 1051 | try { |
| 1052 | // when there is no current form the EDT is useful only |
| 1053 | // for features such as call serially |
| 1054 | while (impl.getCurrentForm() == null) { // PMD Fix: AvoidBranchingStatementAsLastInLoop |
| 1055 | synchronized (lock) { |
| 1056 | while (shouldEDTSleep() && pendingIdleSerialCalls.isEmpty()) { |
| 1057 | try { |
| 1058 | lock.wait(); |
| 1059 | } catch (InterruptedException ie) { |
| 1060 | Thread.currentThread().interrupt(); |
| 1061 | break; |
| 1062 | } |
| 1063 | } |
| 1064 | if (shouldEDTSleep() && !pendingIdleSerialCalls.isEmpty()) { |
| 1065 | Runnable r = pendingIdleSerialCalls.remove(0); |
| 1066 | callSerially(r); |
| 1067 | } |
| 1068 | |
| 1069 | // paint transition or intro animations and don't do anything else if such |
| 1070 | // animations are in progress... |
| 1071 | if (animationQueue != null && !animationQueue.isEmpty()) { |
| 1072 | paintTransitionAnimation(); |
| 1073 | continue; |
| 1074 | } |
| 1075 | } |
| 1076 | processSerialCalls(); |
| 1077 | } |
| 1078 | } catch (Throwable err) { |
| 1079 | Log.e(err); |
| 1080 | if (crashReporter != null) { |
| 1081 | crashReporter.exception(err); |
| 1082 | } |
| 1083 | if (!impl.handleEDTException(err)) { |
| 1084 | if (errorHandler != null) { |
| 1085 | errorHandler.fireActionEvent(new ActionEvent(err, ActionEvent.Type.Exception)); |
| 1086 | } else { |
| 1087 | Dialog.show("Error", "An internal application error occurred: " + err, "OK", null); |
| 1088 | } |
| 1089 | } |
| 1090 | } |
| 1091 | |
| 1092 | while (codenameOneRunning) { // PMD Fix: AvoidBranchingStatementAsLastInLoop |
| 1093 | try { |
| 1094 | // wait indefinetly Lock surrounds the should method to prevent serial calls from |
| 1095 | // getting "lost" |
| 1096 | synchronized (lock) { |
| 1097 | if (shouldEDTSleep()) { |
| 1098 | if (!pendingIdleSerialCalls.isEmpty()) { |
| 1099 | Runnable r = pendingIdleSerialCalls.remove(0); |
| 1100 | callSerially(r); |
| 1101 | } else { |
| 1102 | impl.edtIdle(true); |
| 1103 | while (shouldEDTSleep() && pendingIdleSerialCalls.isEmpty()) { |
| 1104 | try { |
| 1105 | lock.wait(); |
no test coverage detected