diff --git a/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorFragment.java b/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorFragment.java
index 0bc6cf00..a3a53bd1 100644
--- a/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorFragment.java
+++ b/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorFragment.java
@@ -1,83 +1,87 @@
-package org.solovyev.android.calculator;
-
-import android.app.Activity;
-import android.os.Bundle;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import com.actionbarsherlock.app.SherlockFragment;
-import org.jetbrains.annotations.NotNull;
-import org.solovyev.android.calculator.about.CalculatorFragmentType;
-
-/**
- * User: Solovyev_S
- * Date: 03.10.12
- * Time: 14:18
- */
-public abstract class CalculatorFragment extends SherlockFragment {
-
- @NotNull
- private final CalculatorFragmentHelper fragmentHelper;
-
- protected CalculatorFragment(int layoutResId, int titleResId) {
- fragmentHelper = CalculatorApplication.getInstance().createFragmentHelper(layoutResId, titleResId);
- }
-
- protected CalculatorFragment(@NotNull CalculatorFragmentType fragmentType) {
- fragmentHelper = CalculatorApplication.getInstance().createFragmentHelper(fragmentType.getDefaultLayoutId(), fragmentType.getDefaultTitleResId());
- }
-
- @Override
- public void onAttach(Activity activity) {
- super.onAttach(activity);
- }
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- fragmentHelper.onCreate(this);
- }
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- return fragmentHelper.onCreateView(this, inflater, container);
- }
-
- @Override
- public void onViewCreated(View view, Bundle savedInstanceState) {
- super.onViewCreated(view, savedInstanceState);
-
- fragmentHelper.onViewCreated(this, view);
- }
-
- @Override
- public void onResume() {
- super.onResume();
-
- this.fragmentHelper.onResume(this);
- }
-
- @Override
- public void onPause() {
- this.fragmentHelper.onPause(this);
-
- super.onPause();
- }
-
- @Override
- public void onDestroyView() {
- super.onDestroyView();
- }
-
- @Override
- public void onDestroy() {
- fragmentHelper.onDestroy(this);
- super.onDestroy();
- }
-
- @Override
- public void onDetach() {
- super.onDetach();
- }
-}
+package org.solovyev.android.calculator;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import com.actionbarsherlock.app.SherlockFragment;
+import org.jetbrains.annotations.NotNull;
+import org.solovyev.android.calculator.about.CalculatorFragmentType;
+
+/**
+ * User: Solovyev_S
+ * Date: 03.10.12
+ * Time: 14:18
+ */
+public abstract class CalculatorFragment extends SherlockFragment {
+
+ @NotNull
+ private final CalculatorFragmentHelper fragmentHelper;
+
+ protected CalculatorFragment(int layoutResId, int titleResId) {
+ fragmentHelper = CalculatorApplication.getInstance().createFragmentHelper(layoutResId, titleResId);
+ }
+
+ protected CalculatorFragment(@NotNull CalculatorFragmentType fragmentType) {
+ fragmentHelper = CalculatorApplication.getInstance().createFragmentHelper(fragmentType.getDefaultLayoutId(), fragmentType.getDefaultTitleResId());
+ }
+
+ protected CalculatorFragment(@NotNull CalculatorFragmentHelper fragmentHelper) {
+ this.fragmentHelper = fragmentHelper;
+ }
+
+ @Override
+ public void onAttach(Activity activity) {
+ super.onAttach(activity);
+ }
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ fragmentHelper.onCreate(this);
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+ return fragmentHelper.onCreateView(this, inflater, container);
+ }
+
+ @Override
+ public void onViewCreated(View view, Bundle savedInstanceState) {
+ super.onViewCreated(view, savedInstanceState);
+
+ fragmentHelper.onViewCreated(this, view);
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+
+ this.fragmentHelper.onResume(this);
+ }
+
+ @Override
+ public void onPause() {
+ this.fragmentHelper.onPause(this);
+
+ super.onPause();
+ }
+
+ @Override
+ public void onDestroyView() {
+ super.onDestroyView();
+ }
+
+ @Override
+ public void onDestroy() {
+ fragmentHelper.onDestroy(this);
+ super.onDestroy();
+ }
+
+ @Override
+ public void onDetach() {
+ super.onDetach();
+ }
+}
diff --git a/calculatorpp/src/main/java/org/solovyev/android/calculator/plot/CalculatorPlotFragment.java b/calculatorpp/src/main/java/org/solovyev/android/calculator/plot/CalculatorPlotFragment.java
index 0c1f675d..c3cfa9e4 100644
--- a/calculatorpp/src/main/java/org/solovyev/android/calculator/plot/CalculatorPlotFragment.java
+++ b/calculatorpp/src/main/java/org/solovyev/android/calculator/plot/CalculatorPlotFragment.java
@@ -12,12 +12,11 @@ import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;
import android.preference.PreferenceManager;
+import android.support.v4.app.FragmentActivity;
import android.util.Log;
-import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;
-import com.actionbarsherlock.app.SherlockFragment;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuInflater;
import com.actionbarsherlock.view.MenuItem;
@@ -51,7 +50,7 @@ import java.util.concurrent.Executors;
* Date: 12/1/11
* Time: 12:40 AM
*/
-public class CalculatorPlotFragment extends SherlockFragment implements CalculatorEventListener, SharedPreferences.OnSharedPreferenceChangeListener {
+public class CalculatorPlotFragment extends CalculatorFragment implements CalculatorEventListener {
private static final String TAG = CalculatorPlotFragment.class.getSimpleName();
@@ -64,32 +63,25 @@ public class CalculatorPlotFragment extends SherlockFragment implements Calculat
public static final long EVAL_DELAY_MILLIS = 200;
+ @Nullable
private XYChart chart;
/**
* The encapsulated graphical view.
*/
+ @Nullable
private GraphicalView graphicalView;
- @NotNull
- private Generic expression;
-
- @NotNull
- private Constant variable;
-
- @NotNull
- private final CalculatorFragmentHelper fragmentHelper = CalculatorApplication.getInstance().createFragmentHelper(R.layout.plot_fragment, R.string.c_graph, false);
-
+ // thread which calculated data for graph view
@NotNull
private final Executor plotExecutor = Executors.newSingleThreadExecutor();
+ // thread for applying UI changes
@NotNull
private final Handler uiHandler = new Handler();
- @Nullable
- private Input input = null;
-
- private boolean inputFromArgs = true;
+ @NotNull
+ private PreparedInput preparedInput;
@NotNull
private CalculatorEventData lastCalculatorEventData = CalculatorUtils.createFirstEventDataId();
@@ -102,91 +94,89 @@ public class CalculatorPlotFragment extends SherlockFragment implements Calculat
@NotNull
private ActivityMenu