Display/Editor views should not be cleared by closing activity if new activity has already been started
This commit is contained in:
@@ -32,7 +32,8 @@ import javax.annotation.Nullable;
|
||||
*/
|
||||
public interface CalculatorDisplay extends CalculatorEventListener {
|
||||
|
||||
void setView(@Nullable CalculatorDisplayView view);
|
||||
void setView(@Nonnull CalculatorDisplayView view);
|
||||
void clearView(@Nonnull CalculatorDisplayView view);
|
||||
|
||||
@Nullable
|
||||
CalculatorDisplayView getView();
|
||||
|
@@ -25,7 +25,12 @@ package org.solovyev.android.calculator;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static org.solovyev.android.calculator.CalculatorEventType.*;
|
||||
import static org.solovyev.android.calculator.CalculatorEventType.calculation_cancelled;
|
||||
import static org.solovyev.android.calculator.CalculatorEventType.calculation_failed;
|
||||
import static org.solovyev.android.calculator.CalculatorEventType.calculation_result;
|
||||
import static org.solovyev.android.calculator.CalculatorEventType.conversion_failed;
|
||||
import static org.solovyev.android.calculator.CalculatorEventType.conversion_result;
|
||||
import static org.solovyev.android.calculator.CalculatorEventType.display_state_changed;
|
||||
|
||||
/**
|
||||
* User: serso
|
||||
@@ -56,12 +61,18 @@ public class CalculatorDisplayImpl implements CalculatorDisplay {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setView(@Nullable CalculatorDisplayView view) {
|
||||
public void setView(@Nonnull CalculatorDisplayView view) {
|
||||
synchronized (viewLock) {
|
||||
this.view = view;
|
||||
this.view.setState(viewState);
|
||||
}
|
||||
}
|
||||
|
||||
if (view != null) {
|
||||
this.view.setState(viewState);
|
||||
@Override
|
||||
public void clearView(@Nonnull CalculatorDisplayView view) {
|
||||
synchronized (viewLock) {
|
||||
if (this.view == view) {
|
||||
this.view = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -25,7 +25,6 @@ package org.solovyev.android.calculator;
|
||||
import org.solovyev.common.gui.CursorControl;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* User: Solovyev_S
|
||||
@@ -37,7 +36,8 @@ public interface CalculatorEditor extends CalculatorEventListener {
|
||||
@Nonnull
|
||||
String TAG = CalculatorEditor.class.getSimpleName();
|
||||
|
||||
void setView(@Nullable CalculatorEditorView view);
|
||||
void setView(@Nonnull CalculatorEditorView view);
|
||||
void clearView(@Nonnull CalculatorEditorView view);
|
||||
|
||||
@Nonnull
|
||||
CalculatorEditorViewState getViewState();
|
||||
|
@@ -73,12 +73,18 @@ public class CalculatorEditorImpl implements CalculatorEditor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setView(@Nullable CalculatorEditorView view) {
|
||||
public void setView(@Nonnull CalculatorEditorView view) {
|
||||
synchronized (viewLock) {
|
||||
this.view = view;
|
||||
this.view.setState(lastViewState);
|
||||
}
|
||||
}
|
||||
|
||||
if (view != null) {
|
||||
view.setState(lastViewState);
|
||||
@Override
|
||||
public void clearView(@Nonnull CalculatorEditorView view) {
|
||||
synchronized (viewLock) {
|
||||
if (this.view == view) {
|
||||
this.view = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user