external listeners removed

This commit is contained in:
Sergey Solovyev 2013-06-28 00:53:12 +04:00
parent 8d15db4c3f
commit 6ab63bfbbc
13 changed files with 23 additions and 450 deletions

View File

@ -1,150 +0,0 @@
/*
* Copyright 2013 serso aka se.solovyev
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Contact details
*
* Email: se.solovyev@gmail.com
* Site: http://se.solovyev.org
*/
package org.solovyev.android.calculator.external;
import android.content.Context;
import android.content.Intent;
import android.os.Parcelable;
import org.solovyev.android.App;
import org.solovyev.android.calculator.*;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.HashSet;
import java.util.Set;
/**
* User: serso
* Date: 10/19/12
* Time: 11:11 PM
*/
public class AndroidExternalListenersContainer implements CalculatorExternalListenersContainer, CalculatorEventListener {
/*
**********************************************************************
*
* CONSTANTS
*
**********************************************************************
*/
public static final String EVENT_ID_EXTRA = "eventId";
public static final String INIT_ACTION = "org.solovyev.android.calculator.INIT";
public static final String INIT_ACTION_CREATE_VIEW_EXTRA = "createView";
public static final String EDITOR_STATE_CHANGED_ACTION = "org.solovyev.android.calculator.EDITOR_STATE_CHANGED";
public static final String EDITOR_STATE_EXTRA = "editorState";
public static final String DISPLAY_STATE_CHANGED_ACTION = "org.solovyev.android.calculator.DISPLAY_STATE_CHANGED";
public static final String DISPLAY_STATE_EXTRA = "displayState";
private static final String TAG = "Calculator++ External Listener Helper";
@Nonnull
private final Set<Class<?>> externalListeners = new HashSet<Class<?>>();
@Nonnull
private final CalculatorEventHolder lastEvent = new CalculatorEventHolder(CalculatorUtils.createFirstEventDataId());
public AndroidExternalListenersContainer(@Nonnull Calculator calculator) {
calculator.addCalculatorEventListener(this);
}
public void onEditorStateChanged(@Nonnull Context context,
@Nonnull CalculatorEventData calculatorEventData,
@Nonnull CalculatorEditorViewState editorViewState) {
for (Class<?> externalListener : getExternalListenersSync()) {
final Intent intent = new Intent(EDITOR_STATE_CHANGED_ACTION);
intent.setClass(context, externalListener);
intent.putExtra(EVENT_ID_EXTRA, calculatorEventData.getEventId());
intent.putExtra(EDITOR_STATE_EXTRA, (Parcelable) new ParcelableCalculatorEditorViewState(editorViewState));
context.sendBroadcast(intent);
Locator.getInstance().getNotifier().showDebugMessage(TAG, "Editor state changed broadcast sent");
}
}
private void onDisplayStateChanged(@Nonnull Context context,
@Nonnull CalculatorEventData calculatorEventData,
@Nonnull CalculatorDisplayViewState displayViewState) {
for (Class<?> externalListener : getExternalListenersSync()) {
final Intent intent = new Intent(DISPLAY_STATE_CHANGED_ACTION);
intent.setClass(context, externalListener);
intent.putExtra(EVENT_ID_EXTRA, calculatorEventData.getEventId());
intent.putExtra(DISPLAY_STATE_EXTRA, (Parcelable) new ParcelableCalculatorDisplayViewState(displayViewState));
context.sendBroadcast(intent);
Locator.getInstance().getNotifier().showDebugMessage(TAG, "Display state changed broadcast sent");
}
}
@Nonnull
private Set<Class<?>> getExternalListenersSync() {
synchronized (externalListeners) {
return new HashSet<Class<?>>(externalListeners);
}
}
@Override
public void addExternalListener(@Nonnull Class<?> externalCalculatorClass) {
synchronized (externalListeners) {
externalListeners.add(externalCalculatorClass);
}
}
@Override
public boolean removeExternalListener(@Nonnull Class<?> externalCalculatorClass) {
synchronized (externalListeners) {
return externalListeners.remove(externalCalculatorClass);
}
}
@Override
public void onCalculatorEvent(@Nonnull CalculatorEventData calculatorEventData, @Nonnull CalculatorEventType calculatorEventType, @Nullable Object data) {
final CalculatorEventHolder.Result result = lastEvent.apply(calculatorEventData);
if (result.isNewAfter()) {
switch (calculatorEventType) {
case editor_state_changed_light:
case editor_state_changed:
final CalculatorEditorChangeEventData editorChangeData = (CalculatorEditorChangeEventData) data;
final CalculatorEditorViewState newEditorState = editorChangeData.getNewValue();
Locator.getInstance().getNotifier().showDebugMessage(TAG, "Editor state changed: " + newEditorState.getText());
onEditorStateChanged(App.getApplication(), calculatorEventData, newEditorState);
break;
case display_state_changed:
final CalculatorDisplayChangeEventData displayChangeData = (CalculatorDisplayChangeEventData) data;
final CalculatorDisplayViewState newDisplayState = displayChangeData.getNewValue();
Locator.getInstance().getNotifier().showDebugMessage(TAG, "Display state changed: " + newDisplayState.getText());
onDisplayStateChanged(App.getApplication(), calculatorEventData, newDisplayState);
break;
}
}
}
}

View File

@ -1,116 +0,0 @@
/*
* Copyright 2013 serso aka se.solovyev
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Contact details
*
* Email: se.solovyev@gmail.com
* Site: http://se.solovyev.org
*/
package org.solovyev.android.calculator.external;
import android.content.Context;
import android.content.Intent;
import android.os.Parcelable;
import javax.annotation.Nonnull;
import org.solovyev.android.calculator.CalculatorDisplayViewState;
import org.solovyev.android.calculator.CalculatorEditorViewState;
import org.solovyev.android.calculator.Locator;
import org.solovyev.common.MutableObject;
/**
* User: serso
* Date: 11/20/12
* Time: 10:34 PM
*/
public class DefaultExternalCalculatorIntentHandler implements ExternalCalculatorIntentHandler {
private static final String TAG = ExternalCalculatorIntentHandler.class.getSimpleName();
@Nonnull
private final MutableObject<Long> lastDisplayEventId = new MutableObject<Long>(0L);
@Nonnull
private final MutableObject<Long> lastEditorEventId = new MutableObject<Long>(0L);
@Nonnull
private final ExternalCalculatorStateUpdater stateUpdater;
public DefaultExternalCalculatorIntentHandler(@Nonnull ExternalCalculatorStateUpdater stateUpdater) {
this.stateUpdater = stateUpdater;
}
@Override
public void onIntent(@Nonnull Context context, @Nonnull Intent intent) {
if (AndroidExternalListenersContainer.EDITOR_STATE_CHANGED_ACTION.equals(intent.getAction())) {
Locator.getInstance().getNotifier().showDebugMessage(TAG, "Editor state changed broadcast received!");
final Long eventId = intent.getLongExtra(AndroidExternalListenersContainer.EVENT_ID_EXTRA, 0L);
boolean updateEditor = false;
synchronized (lastEditorEventId) {
if (eventId > lastEditorEventId.getObject()) {
lastEditorEventId.setObject(eventId);
updateEditor = true;
}
}
if (updateEditor) {
final Parcelable object = intent.getParcelableExtra(AndroidExternalListenersContainer.EDITOR_STATE_EXTRA);
if (object instanceof CalculatorEditorViewState) {
onEditorStateChanged(context, (CalculatorEditorViewState) object);
}
}
} else if (AndroidExternalListenersContainer.DISPLAY_STATE_CHANGED_ACTION.equals(intent.getAction())) {
Locator.getInstance().getNotifier().showDebugMessage(TAG, "Display state changed broadcast received!");
final Long eventId = intent.getLongExtra(AndroidExternalListenersContainer.EVENT_ID_EXTRA, 0L);
boolean updateDisplay = false;
synchronized (lastDisplayEventId) {
if (eventId > lastDisplayEventId.getObject()) {
lastDisplayEventId.setObject(eventId);
updateDisplay = true;
}
}
if (updateDisplay) {
final Parcelable object = intent.getParcelableExtra(AndroidExternalListenersContainer.DISPLAY_STATE_EXTRA);
if (object instanceof CalculatorDisplayViewState) {
onDisplayStateChanged(context, (CalculatorDisplayViewState) object);
}
}
} else if (AndroidExternalListenersContainer.INIT_ACTION.equals(intent.getAction())) {
updateState(context, Locator.getInstance().getEditor().getViewState(), Locator.getInstance().getDisplay().getViewState());
}
}
protected void updateState(@Nonnull Context context,
@Nonnull CalculatorEditorViewState editorViewState,
@Nonnull CalculatorDisplayViewState displayViewState) {
stateUpdater.updateState(context, editorViewState, displayViewState);
}
protected void onDisplayStateChanged(@Nonnull Context context, @Nonnull CalculatorDisplayViewState displayViewState) {
updateState(context, Locator.getInstance().getEditor().getViewState(), displayViewState);
}
protected void onEditorStateChanged(@Nonnull Context context, @Nonnull CalculatorEditorViewState editorViewState) {
updateState(context, editorViewState, Locator.getInstance().getDisplay().getViewState());
}
}

View File

@ -1,42 +0,0 @@
/*
* Copyright 2013 serso aka se.solovyev
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Contact details
*
* Email: se.solovyev@gmail.com
* Site: http://se.solovyev.org
*/
package org.solovyev.android.calculator.external;
import android.content.Context;
import javax.annotation.Nonnull;
import org.solovyev.android.calculator.CalculatorDisplayViewState;
import org.solovyev.android.calculator.CalculatorEditorViewState;
/**
* User: serso
* Date: 11/20/12
* Time: 10:42 PM
*/
public interface ExternalCalculatorStateUpdater {
void updateState(@Nonnull Context context,
@Nonnull CalculatorEditorViewState editorState,
@Nonnull CalculatorDisplayViewState displayState);
}

View File

@ -33,13 +33,10 @@ import android.util.DisplayMetrics;
import android.view.WindowManager;
import org.solovyev.android.Views;
import org.solovyev.android.calculator.*;
import org.solovyev.android.calculator.external.AndroidExternalListenersContainer;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import static org.solovyev.android.calculator.external.AndroidExternalListenersContainer.INIT_ACTION;
/**
* User: serso
* Date: 11/20/12
@ -47,6 +44,9 @@ import static org.solovyev.android.calculator.external.AndroidExternalListenersC
*/
public class CalculatorOnscreenService extends Service implements OnscreenViewListener, CalculatorEventListener {
private static final String INIT_ACTION = "org.solovyev.android.calculator.INIT";
private static final String INIT_ACTION_CREATE_VIEW_EXTRA = "createView";
private static final int NOTIFICATION_ID = 9031988; // my birthday =)
public static final Class<CalculatorOnscreenBroadcastReceiver> INTENT_LISTENER_CLASS = CalculatorOnscreenBroadcastReceiver.class;
@ -91,6 +91,8 @@ public class CalculatorOnscreenService extends Service implements OnscreenViewLi
view.show();
startCalculatorListening();
view.updateEditorState(Locator.getInstance().getEditor().getViewState());
view.updateDisplayState(Locator.getInstance().getDisplay().getViewState());
viewCreated = true;
}
@ -151,7 +153,7 @@ public class CalculatorOnscreenService extends Service implements OnscreenViewLi
if (isInitIntent(intent)) {
boolean createView = intent.getBooleanExtra(AndroidExternalListenersContainer.INIT_ACTION_CREATE_VIEW_EXTRA, false);
boolean createView = intent.getBooleanExtra(INIT_ACTION_CREATE_VIEW_EXTRA, false);
if (createView) {
hideNotification();
createView();
@ -211,7 +213,7 @@ public class CalculatorOnscreenService extends Service implements OnscreenViewLi
private static Intent createShowOnscreenViewIntent(@Nonnull Context context) {
final Intent intent = new Intent(INIT_ACTION);
intent.setClass(context, getIntentListenerClass());
intent.putExtra(AndroidExternalListenersContainer.INIT_ACTION_CREATE_VIEW_EXTRA, true);
intent.putExtra(INIT_ACTION_CREATE_VIEW_EXTRA, true);
return intent;
}

View File

@ -30,21 +30,19 @@ import android.content.Context;
import android.content.Intent;
import android.text.Html;
import android.widget.RemoteViews;
import org.solovyev.android.calculator.*;
import org.solovyev.android.calculator.external.CalculatorExternalListenersContainer;
import org.solovyev.android.calculator.external.ExternalCalculatorIntentHandler;
import org.solovyev.android.calculator.external.ExternalCalculatorStateUpdater;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import static android.content.Intent.ACTION_CONFIGURATION_CHANGED;
/**
* User: Solovyev_S
* Date: 19.10.12
* Time: 16:18
*/
abstract class AbstractCalculatorWidgetProvider extends AppWidgetProvider implements ExternalCalculatorStateUpdater {
abstract class AbstractCalculatorWidgetProvider extends AppWidgetProvider{
static final String BUTTON_ID_EXTRA = "buttonId";
static final String BUTTON_PRESSED_ACTION = "org.solovyev.android.calculator.widget.BUTTON_PRESSED";
@ -62,9 +60,6 @@ abstract class AbstractCalculatorWidgetProvider extends AppWidgetProvider implem
@Nullable
private String cursorColor;
@Nonnull
private ExternalCalculatorIntentHandler intentHandler = new CalculatorWidgetIntentHandler(this);
/*
**********************************************************************
*
@ -74,13 +69,6 @@ abstract class AbstractCalculatorWidgetProvider extends AppWidgetProvider implem
*/
protected AbstractCalculatorWidgetProvider() {
final Class<? extends AppWidgetProvider> componentClass = this.getComponentClass();
final CalculatorExternalListenersContainer externalListenersContainer = Locator.getInstance().getExternalListenersContainer();
// NOTE: null might be in tests, now robolectric creates widget provider before application
if (externalListenersContainer != null) {
externalListenersContainer.addExternalListener(componentClass);
}
}
/*
@ -114,7 +102,6 @@ abstract class AbstractCalculatorWidgetProvider extends AppWidgetProvider implem
updateWidget(context, appWidgetManager, appWidgetIds, Locator.getInstance().getEditor().getViewState(), Locator.getInstance().getDisplay().getViewState());
}
@Override
public void updateState(@Nonnull Context context,
@Nonnull CalculatorEditorViewState editorState,
@Nonnull CalculatorDisplayViewState displayState) {
@ -160,7 +147,16 @@ abstract class AbstractCalculatorWidgetProvider extends AppWidgetProvider implem
public void onReceive(Context context, Intent intent) {
super.onReceive(context, intent);
this.intentHandler.onIntent(context, intent);
if (BUTTON_PRESSED_ACTION.equals(intent.getAction())) {
final int buttonId = intent.getIntExtra(AbstractCalculatorWidgetProvider.BUTTON_ID_EXTRA, 0);
final CalculatorButton button = CalculatorButton.getById(buttonId);
if (button != null) {
button.onClick(context);
}
} else if (ACTION_CONFIGURATION_CHANGED.equals(intent.getAction())) {
updateState(context, Locator.getInstance().getEditor().getViewState(), Locator.getInstance().getDisplay().getViewState());
}
}
private void updateDisplayState(@Nonnull Context context, @Nonnull RemoteViews views, @Nonnull CalculatorDisplayViewState displayState) {

View File

@ -1,62 +0,0 @@
/*
* Copyright 2013 serso aka se.solovyev
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Contact details
*
* Email: se.solovyev@gmail.com
* Site: http://se.solovyev.org
*/
package org.solovyev.android.calculator.widget;
import android.content.Context;
import android.content.Intent;
import javax.annotation.Nonnull;
import org.solovyev.android.calculator.CalculatorButton;
import org.solovyev.android.calculator.Locator;
import org.solovyev.android.calculator.external.DefaultExternalCalculatorIntentHandler;
import org.solovyev.android.calculator.external.ExternalCalculatorStateUpdater;
/**
* User: serso
* Date: 11/20/12
* Time: 10:39 PM
*/
public class CalculatorWidgetIntentHandler extends DefaultExternalCalculatorIntentHandler {
public CalculatorWidgetIntentHandler(@Nonnull ExternalCalculatorStateUpdater stateUpdater) {
super(stateUpdater);
}
@Override
public void onIntent(@Nonnull Context context, @Nonnull Intent intent) {
super.onIntent(context, intent);
if (AbstractCalculatorWidgetProvider.BUTTON_PRESSED_ACTION.equals(intent.getAction())) {
final int buttonId = intent.getIntExtra(AbstractCalculatorWidgetProvider.BUTTON_ID_EXTRA, 0);
final CalculatorButton button = CalculatorButton.getById(buttonId);
if (button != null) {
button.onClick(context);
}
} else if (Intent.ACTION_CONFIGURATION_CHANGED.equals(intent.getAction())) {
updateState(context, Locator.getInstance().getEditor().getViewState(), Locator.getInstance().getDisplay().getViewState());
}
}
}

View File

@ -38,7 +38,6 @@ import org.solovyev.android.Android;
import org.solovyev.android.App;
import org.solovyev.android.ServiceLocator;
import org.solovyev.android.ads.AdsController;
import org.solovyev.android.calculator.external.AndroidExternalListenersContainer;
import org.solovyev.android.calculator.history.AndroidCalculatorHistory;
import org.solovyev.android.calculator.model.AndroidCalculatorEngine;
import org.solovyev.android.calculator.onscreen.CalculatorOnscreenStartActivity;
@ -145,7 +144,6 @@ public class CalculatorApplication extends android.app.Application implements Sh
new AndroidCalculatorLogger(),
new AndroidCalculatorPreferenceService(this),
new AndroidCalculatorKeyboard(this, new CalculatorKeyboardImpl(calculator)),
new AndroidExternalListenersContainer(calculator),
new AndroidCalculatorPlotter(this, new CalculatorPlotterImpl(calculator)),
editorTextProcessor);

View File

@ -26,7 +26,6 @@ import android.content.Context;
import jscl.JsclMathEngine;
import org.mockito.Mockito;
import org.solovyev.android.calculator.external.CalculatorExternalListenersContainer;
import org.solovyev.android.calculator.history.CalculatorHistory;
import org.solovyev.android.calculator.plot.CalculatorPlotter;
@ -41,7 +40,7 @@ import javax.annotation.Nullable;
public class CalculatorTestUtils {
public static void staticSetUp(@Nullable Context context) throws Exception {
Locator.getInstance().init(new CalculatorImpl(), newCalculatorEngine(), Mockito.mock(CalculatorClipboard.class), Mockito.mock(CalculatorNotifier.class), Mockito.mock(CalculatorHistory.class), new SystemOutCalculatorLogger(), Mockito.mock(CalculatorPreferenceService.class), Mockito.mock(CalculatorKeyboard.class), Mockito.mock(CalculatorExternalListenersContainer.class), Mockito.mock(CalculatorPlotter.class), null);
Locator.getInstance().init(new CalculatorImpl(), newCalculatorEngine(), Mockito.mock(CalculatorClipboard.class), Mockito.mock(CalculatorNotifier.class), Mockito.mock(CalculatorHistory.class), new SystemOutCalculatorLogger(), Mockito.mock(CalculatorPreferenceService.class), Mockito.mock(CalculatorKeyboard.class), Mockito.mock(CalculatorPlotter.class), null);
Locator.getInstance().getEngine().init();
if (context != null) {

View File

@ -22,7 +22,6 @@
package org.solovyev.android.calculator;
import org.solovyev.android.calculator.external.CalculatorExternalListenersContainer;
import org.solovyev.android.calculator.history.CalculatorHistory;
import org.solovyev.android.calculator.plot.CalculatorPlotter;
import org.solovyev.android.calculator.text.TextProcessor;
@ -46,7 +45,6 @@ public interface CalculatorLocator {
@Nonnull CalculatorLogger logger,
@Nonnull CalculatorPreferenceService preferenceService,
@Nonnull CalculatorKeyboard keyboard,
@Nonnull CalculatorExternalListenersContainer externalListenersContainer,
@Nonnull CalculatorPlotter plotter,
@Nullable TextProcessor<TextProcessorEditorResult, String> editorTextProcessor);
@ -82,8 +80,4 @@ public interface CalculatorLocator {
@Nonnull
CalculatorPreferenceService getPreferenceService();
// for robolectric
/*@Nonnull*/
CalculatorExternalListenersContainer getExternalListenersContainer();
}

View File

@ -22,7 +22,6 @@
package org.solovyev.android.calculator;
import org.solovyev.android.calculator.external.CalculatorExternalListenersContainer;
import org.solovyev.android.calculator.history.CalculatorHistory;
import org.solovyev.android.calculator.plot.CalculatorPlotter;
import org.solovyev.android.calculator.text.TextProcessor;
@ -71,9 +70,6 @@ public class Locator implements CalculatorLocator {
@Nonnull
private CalculatorPreferenceService calculatorPreferenceService;
/*@Nonnull*/
private CalculatorExternalListenersContainer calculatorExternalListenersContainer;
@Nonnull
private CalculatorPlotter calculatorPlotter;
@ -89,7 +85,6 @@ public class Locator implements CalculatorLocator {
@Nonnull CalculatorLogger logger,
@Nonnull CalculatorPreferenceService preferenceService,
@Nonnull CalculatorKeyboard keyboard,
@Nonnull CalculatorExternalListenersContainer externalListenersContainer,
@Nonnull CalculatorPlotter plotter,
@Nullable TextProcessor<TextProcessorEditorResult, String> editorTextProcessor) {
@ -100,7 +95,6 @@ public class Locator implements CalculatorLocator {
this.calculatorHistory = history;
this.calculatorLogger = logger;
this.calculatorPreferenceService = preferenceService;
this.calculatorExternalListenersContainer = externalListenersContainer;
this.calculatorPlotter = plotter;
calculatorEditor = new CalculatorEditorImpl(this.calculator, editorTextProcessor);
@ -178,10 +172,4 @@ public class Locator implements CalculatorLocator {
public CalculatorPreferenceService getPreferenceService() {
return this.calculatorPreferenceService;
}
@Override
/*@Nonnull*/
public CalculatorExternalListenersContainer getExternalListenersContainer() {
return calculatorExternalListenersContainer;
}
}

View File

@ -1,32 +0,0 @@
/*
* Copyright 2013 serso aka se.solovyev
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Contact details
*
* Email: se.solovyev@gmail.com
* Site: http://se.solovyev.org
*/
package org.solovyev.android.calculator.external;
import javax.annotation.Nonnull;
public interface CalculatorExternalListenersContainer {
void addExternalListener(@Nonnull Class<?> externalCalculatorClass);
boolean removeExternalListener(@Nonnull Class<?> externalCalculatorClass);
}

View File

@ -23,7 +23,6 @@
package org.solovyev.android.calculator;
import org.mockito.Mockito;
import org.solovyev.android.calculator.external.CalculatorExternalListenersContainer;
import org.solovyev.android.calculator.history.CalculatorHistory;
import org.solovyev.android.calculator.plot.CalculatorPlotter;
@ -35,7 +34,7 @@ import org.solovyev.android.calculator.plot.CalculatorPlotter;
public class AbstractCalculatorTest {
protected void setUp() throws Exception {
Locator.getInstance().init(new CalculatorImpl(), CalculatorTestUtils.newCalculatorEngine(), Mockito.mock(CalculatorClipboard.class), Mockito.mock(CalculatorNotifier.class), Mockito.mock(CalculatorHistory.class), new SystemOutCalculatorLogger(), Mockito.mock(CalculatorPreferenceService.class), Mockito.mock(CalculatorKeyboard.class), Mockito.mock(CalculatorExternalListenersContainer.class), Mockito.mock(CalculatorPlotter.class), null);
Locator.getInstance().init(new CalculatorImpl(), CalculatorTestUtils.newCalculatorEngine(), Mockito.mock(CalculatorClipboard.class), Mockito.mock(CalculatorNotifier.class), Mockito.mock(CalculatorHistory.class), new SystemOutCalculatorLogger(), Mockito.mock(CalculatorPreferenceService.class), Mockito.mock(CalculatorKeyboard.class), Mockito.mock(CalculatorPlotter.class), null);
Locator.getInstance().getEngine().init();
}

View File

@ -26,7 +26,6 @@ import jscl.JsclMathEngine;
import org.junit.Assert;
import org.mockito.Mockito;
import org.solovyev.android.calculator.external.CalculatorExternalListenersContainer;
import org.solovyev.android.calculator.history.CalculatorHistory;
import org.solovyev.android.calculator.jscl.JsclOperation;
import org.solovyev.android.calculator.plot.CalculatorPlotter;
@ -49,7 +48,7 @@ public class CalculatorTestUtils {
public static final int TIMEOUT = 15;
public static void staticSetUp() throws Exception {
Locator.getInstance().init(new CalculatorImpl(), newCalculatorEngine(), Mockito.mock(CalculatorClipboard.class), Mockito.mock(CalculatorNotifier.class), Mockito.mock(CalculatorHistory.class), new SystemOutCalculatorLogger(), Mockito.mock(CalculatorPreferenceService.class), Mockito.mock(CalculatorKeyboard.class), Mockito.mock(CalculatorExternalListenersContainer.class), Mockito.mock(CalculatorPlotter.class), null);
Locator.getInstance().init(new CalculatorImpl(), newCalculatorEngine(), Mockito.mock(CalculatorClipboard.class), Mockito.mock(CalculatorNotifier.class), Mockito.mock(CalculatorHistory.class), new SystemOutCalculatorLogger(), Mockito.mock(CalculatorPreferenceService.class), Mockito.mock(CalculatorKeyboard.class), Mockito.mock(CalculatorPlotter.class), null);
Locator.getInstance().getEngine().init();
}