user exceptions fixed
This commit is contained in:
parent
6e09225366
commit
6991b3c7ae
@ -38,6 +38,7 @@ public class AndroidExternalListenersContainer implements CalculatorExternalList
|
|||||||
|
|
||||||
private static final String TAG = "Calculator++ External Listener Helper";
|
private static final String TAG = "Calculator++ External Listener Helper";
|
||||||
|
|
||||||
|
@NotNull
|
||||||
private final Set<Class<?>> externalListeners = new HashSet<Class<?>>();
|
private final Set<Class<?>> externalListeners = new HashSet<Class<?>>();
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@ -51,7 +52,7 @@ public class AndroidExternalListenersContainer implements CalculatorExternalList
|
|||||||
@NotNull CalculatorEventData calculatorEventData,
|
@NotNull CalculatorEventData calculatorEventData,
|
||||||
@NotNull CalculatorEditorViewState editorViewState) {
|
@NotNull CalculatorEditorViewState editorViewState) {
|
||||||
|
|
||||||
for (Class<?> externalListener : externalListeners) {
|
for (Class<?> externalListener : getExternalListenersSync()) {
|
||||||
final Intent intent = new Intent(EDITOR_STATE_CHANGED_ACTION);
|
final Intent intent = new Intent(EDITOR_STATE_CHANGED_ACTION);
|
||||||
intent.setClass(context, externalListener);
|
intent.setClass(context, externalListener);
|
||||||
intent.putExtra(EVENT_ID_EXTRA, calculatorEventData.getEventId());
|
intent.putExtra(EVENT_ID_EXTRA, calculatorEventData.getEventId());
|
||||||
@ -64,7 +65,7 @@ public class AndroidExternalListenersContainer implements CalculatorExternalList
|
|||||||
private void onDisplayStateChanged(@NotNull Context context,
|
private void onDisplayStateChanged(@NotNull Context context,
|
||||||
@NotNull CalculatorEventData calculatorEventData,
|
@NotNull CalculatorEventData calculatorEventData,
|
||||||
@NotNull CalculatorDisplayViewState displayViewState) {
|
@NotNull CalculatorDisplayViewState displayViewState) {
|
||||||
for (Class<?> externalListener : externalListeners) {
|
for (Class<?> externalListener : getExternalListenersSync()) {
|
||||||
final Intent intent = new Intent(DISPLAY_STATE_CHANGED_ACTION);
|
final Intent intent = new Intent(DISPLAY_STATE_CHANGED_ACTION);
|
||||||
intent.setClass(context, externalListener);
|
intent.setClass(context, externalListener);
|
||||||
intent.putExtra(EVENT_ID_EXTRA, calculatorEventData.getEventId());
|
intent.putExtra(EVENT_ID_EXTRA, calculatorEventData.getEventId());
|
||||||
@ -74,15 +75,26 @@ public class AndroidExternalListenersContainer implements CalculatorExternalList
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private Set<Class<?>> getExternalListenersSync() {
|
||||||
|
synchronized (externalListeners) {
|
||||||
|
return new HashSet<Class<?>>(externalListeners);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addExternalListener(@NotNull Class<?> externalCalculatorClass) {
|
public void addExternalListener(@NotNull Class<?> externalCalculatorClass) {
|
||||||
|
synchronized (externalListeners) {
|
||||||
externalListeners.add(externalCalculatorClass);
|
externalListeners.add(externalCalculatorClass);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean removeExternalListener(@NotNull Class<?> externalCalculatorClass) {
|
public boolean removeExternalListener(@NotNull Class<?> externalCalculatorClass) {
|
||||||
|
synchronized (externalListeners) {
|
||||||
return externalListeners.remove(externalCalculatorClass);
|
return externalListeners.remove(externalCalculatorClass);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCalculatorEvent(@NotNull CalculatorEventData calculatorEventData, @NotNull CalculatorEventType calculatorEventType, @Nullable Object data) {
|
public void onCalculatorEvent(@NotNull CalculatorEventData calculatorEventData, @NotNull CalculatorEventType calculatorEventType, @Nullable Object data) {
|
||||||
|
Loading…
Reference in New Issue
Block a user