Memory leaks fixed
This commit is contained in:
parent
e4fd89aed8
commit
127f27810e
@ -24,19 +24,21 @@ package org.solovyev.android.calculator;
|
|||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
import android.content.Context;
|
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import jscl.NumeralBase;
|
|
||||||
import jscl.math.Generic;
|
|
||||||
import org.solovyev.android.calculator.history.CalculatorHistoryState;
|
import org.solovyev.android.calculator.history.CalculatorHistoryState;
|
||||||
import org.solovyev.android.calculator.jscl.JsclOperation;
|
import org.solovyev.android.calculator.jscl.JsclOperation;
|
||||||
import org.solovyev.common.history.HistoryAction;
|
import org.solovyev.common.history.HistoryAction;
|
||||||
import org.solovyev.common.msg.Message;
|
import org.solovyev.common.msg.Message;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.List;
|
|
||||||
|
import jscl.NumeralBase;
|
||||||
|
import jscl.math.Generic;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User: serso
|
* User: serso
|
||||||
@ -58,31 +60,26 @@ public class AndroidCalculator implements Calculator, CalculatorEventListener, S
|
|||||||
PreferenceManager.getDefaultSharedPreferences(application).registerOnSharedPreferenceChangeListener(this);
|
PreferenceManager.getDefaultSharedPreferences(application).registerOnSharedPreferenceChangeListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init(@Nonnull final Activity activity) {
|
|
||||||
setEditor(activity);
|
|
||||||
setDisplay(activity);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDisplay(@Nonnull Activity activity) {
|
public void setDisplay(@Nonnull Activity activity) {
|
||||||
final AndroidCalculatorDisplayView displayView = (AndroidCalculatorDisplayView) activity.findViewById(R.id.calculator_display);
|
final AndroidCalculatorDisplayView displayView = (AndroidCalculatorDisplayView) activity.findViewById(R.id.calculator_display);
|
||||||
setDisplay(activity, displayView);
|
displayView.init(activity);
|
||||||
|
Locator.getInstance().getDisplay().setView(displayView);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDisplay(@Nonnull Context context, @Nonnull AndroidCalculatorDisplayView displayView) {
|
public void clearDisplay() {
|
||||||
displayView.init(context);
|
Locator.getInstance().getDisplay().setView(null);
|
||||||
Locator.getInstance().getDisplay().setView(displayView);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEditor(@Nonnull Activity activity) {
|
public void setEditor(@Nonnull Activity activity) {
|
||||||
final AndroidCalculatorEditorView editorView = (AndroidCalculatorEditorView) activity.findViewById(R.id.calculator_editor);
|
final AndroidCalculatorEditorView editorView = (AndroidCalculatorEditorView) activity.findViewById(R.id.calculator_editor);
|
||||||
setEditor(activity, editorView);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEditor(@Nonnull Context context, @Nonnull AndroidCalculatorEditorView editorView) {
|
|
||||||
editorView.init();
|
editorView.init();
|
||||||
Locator.getInstance().getEditor().setView(editorView);
|
Locator.getInstance().getEditor().setView(editorView);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void clearEditor() {
|
||||||
|
Locator.getInstance().getEditor().setView(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
|
@ -91,6 +91,12 @@ public class CalculatorDisplayFragment extends Fragment {
|
|||||||
super.onPause();
|
super.onPause();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroyView() {
|
||||||
|
((AndroidCalculator) Locator.getInstance().getCalculator()).clearDisplay();
|
||||||
|
super.onDestroyView();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
fragmentHelper.onDestroy(this);
|
fragmentHelper.onDestroy(this);
|
||||||
|
@ -99,6 +99,7 @@ public class CalculatorEditorFragment extends Fragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroyView() {
|
public void onDestroyView() {
|
||||||
|
((AndroidCalculator) Locator.getInstance().getCalculator()).clearEditor();
|
||||||
super.onDestroyView();
|
super.onDestroyView();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user