Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit efa259a7 authored by Annie Chin's avatar Annie Chin
Browse files

Initialize the RecyclerView as INVISIBLE.

Fixes: 33106612
Fixes: 33106867

Also, reinitialize the DragController in onResume() instead of
only on creation.

Change-Id: I6d2be61f07d1839472fddbbd5f88b00da90e3180
parent 450de8a9
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -86,6 +86,9 @@ public final class DragController {
    public void animateViews(float yFraction, RecyclerView recyclerView, int itemCount) {
        final HistoryAdapter.ViewHolder vh = (HistoryAdapter.ViewHolder)
                recyclerView.findViewHolderForAdapterPosition(0);
        if (yFraction > 0) {
            recyclerView.setVisibility(View.VISIBLE);
        }
        if (vh != null && !EvaluatorStateUtils.isDisplayEmpty(mEvaluator)) {
            final CalculatorFormula formula = vh.getFormula();
            final CalculatorResult result = vh.getResult();
@@ -154,10 +157,10 @@ public final class DragController {
    }

    /**
     * Reset all initialized values whenever the History fragment is closed because the
     * DisplayState may change.
     * Reset all initialized values and set recyclerview to INVISIBLE to avoid flickering.
     */
    public void resetAnimationInitialized() {
    public void initializeAnimation(RecyclerView recyclerView) {
        recyclerView.setVisibility(View.INVISIBLE);
        mAnimationInitialized = false;
    }

+7 −5
Original line number Diff line number Diff line
@@ -51,8 +51,6 @@ public class HistoryFragment extends Fragment {
                public void onClosed() {
                    // TODO: only cancel historical evaluations
                    mEvaluator.cancelAll(true);

                    mDragController.resetAnimationInitialized();
                }

                @Override
@@ -168,10 +166,14 @@ public class HistoryFragment extends Fragment {
        }

        mAdapter.notifyDataSetChanged();
    }

    @Override
    public void onStart() {
        super.onStart();

        // Initialize the current expression element to dimensions that match the display to
        // avoid flickering and scrolling when elements expand on drag start.
        mDragController.animateViews(1.0f, mRecyclerView, mAdapter.getItemCount());
        // The orientation may have changed.
        mDragController.initializeAnimation(mRecyclerView);
    }

    @Override