summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAnnie Chin <afchin@google.com>2016-11-18 14:43:56 -0800
committerAnnie Chin <afchin@google.com>2016-11-22 12:42:38 -0800
commit70ac8eafeb18711e427d512dcbb3089977521df8 (patch)
tree79cdbe5dadfb6260c2ccdf48d66616221dbaec39 /src
parent9179623c3d2530f9ccfd1b542c0416317422ca0c (diff)
downloadandroid_packages_apps_ExactCalculator-70ac8eafeb18711e427d512dcbb3089977521df8.tar.gz
android_packages_apps_ExactCalculator-70ac8eafeb18711e427d512dcbb3089977521df8.tar.bz2
android_packages_apps_ExactCalculator-70ac8eafeb18711e427d512dcbb3089977521df8.zip
Fix animation for RESULT state.
Fixes: 32948596 Introduce isResultState() and pass its value to HistoryAdapter. We actually can't accurately determine RESULT state from the Evaluator. Change-Id: Ie50c5743fac8af680073c60a3e9cc9b58ccff167
Diffstat (limited to 'src')
-rw-r--r--src/com/android/calculator2/Calculator.java4
-rw-r--r--src/com/android/calculator2/HistoryAdapter.java6
-rw-r--r--src/com/android/calculator2/HistoryFragment.java15
3 files changed, 21 insertions, 4 deletions
diff --git a/src/com/android/calculator2/Calculator.java b/src/com/android/calculator2/Calculator.java
index 02047af..e22e628 100644
--- a/src/com/android/calculator2/Calculator.java
+++ b/src/com/android/calculator2/Calculator.java
@@ -462,6 +462,10 @@ public class Calculator extends Activity
}
}
+ public boolean isResultState() {
+ return mCurrentState == CalculatorState.RESULT;
+ }
+
@Override
protected void onDestroy() {
mDragLayout.removeDragCallback(mDragCallback);
diff --git a/src/com/android/calculator2/HistoryAdapter.java b/src/com/android/calculator2/HistoryAdapter.java
index ca5509c..dba887f 100644
--- a/src/com/android/calculator2/HistoryAdapter.java
+++ b/src/com/android/calculator2/HistoryAdapter.java
@@ -39,6 +39,8 @@ public class HistoryAdapter extends RecyclerView.Adapter<HistoryAdapter.ViewHold
private List<HistoryItem> mDataSet;
+ private boolean mIsResultState;
+
public HistoryAdapter(Calculator calculator, ArrayList<HistoryItem> dataSet,
String currentExpressionDescription) {
mEvaluator = Evaluator.getInstance(calculator);
@@ -131,6 +133,10 @@ public class HistoryAdapter extends RecyclerView.Adapter<HistoryAdapter.ViewHold
}
}
+ public void setIsResultState(boolean isResult) {
+ mIsResultState = isResult;
+ }
+
public static class ViewHolder extends RecyclerView.ViewHolder {
private TextView mDate;
diff --git a/src/com/android/calculator2/HistoryFragment.java b/src/com/android/calculator2/HistoryFragment.java
index dcc7b25..afc8803 100644
--- a/src/com/android/calculator2/HistoryFragment.java
+++ b/src/com/android/calculator2/HistoryFragment.java
@@ -135,7 +135,10 @@ public class HistoryFragment extends Fragment {
dragLayout.removeDragCallback(mDragCallback);
dragLayout.addDragCallback(mDragCallback);
- mEvaluator = Evaluator.getInstance((Calculator) getActivity());
+ final Calculator activity = (Calculator) getActivity();
+ final boolean isResultState = activity.isResultState();
+
+ mEvaluator = Evaluator.getInstance(activity);
if (mEvaluator != null) {
initializeController();
@@ -144,9 +147,12 @@ public class HistoryFragment extends Fragment {
final ArrayList<HistoryItem> newDataSet = new ArrayList<>();
- if (!EvaluatorStateUtils.isDisplayEmpty(mEvaluator)) {
- // Add the current expression as the first element in the list (the layout is reversed
- // and we want the current expression to be the last one in the recyclerview).
+ if (!EvaluatorStateUtils.isDisplayEmpty(mEvaluator) && !isResultState) {
+ // Add the current expression as the first element in the list (the layout is
+ // reversed and we want the current expression to be the last one in the
+ // recyclerview).
+ // If we are in the result state, the result will animate to the last history
+ // element in the list and there will be no "Current Expression."
newDataSet.add(new HistoryItem(Evaluator.MAIN_INDEX, System.currentTimeMillis(),
mEvaluator.getExprAsSpannable(0)));
}
@@ -158,6 +164,7 @@ public class HistoryFragment extends Fragment {
}
mDataSet = newDataSet;
mAdapter.setDataSet(mDataSet);
+ mAdapter.setIsResultState(isResultState);
}
mAdapter.notifyDataSetChanged();