Directly implement CloseCallback/DragCallback.

Test: Verify that dragging history open/closed still works properly.
Fixes: 34079549

Change-Id: I9a53a6631cfc97e40bbfd0dccfe6e28e03792c09
diff --git a/src/com/android/calculator2/HistoryFragment.java b/src/com/android/calculator2/HistoryFragment.java
index 9c9c573..454c47a 100644
--- a/src/com/android/calculator2/HistoryFragment.java
+++ b/src/com/android/calculator2/HistoryFragment.java
@@ -34,41 +34,11 @@
 
 import static android.support.v7.widget.RecyclerView.SCROLL_STATE_DRAGGING;
 
-public class HistoryFragment extends Fragment {
+public class HistoryFragment extends Fragment implements DragLayout.DragCallback {
 
     public static final String TAG = "HistoryFragment";
     public static final String CLEAR_DIALOG_TAG = "clear";
 
-    private final DragLayout.DragCallback mDragCallback =
-            new DragLayout.DragCallback() {
-                @Override
-                public void onStartDraggingOpen() {
-                    // no-op
-                }
-
-                @Override
-                public void whileDragging(float yFraction) {
-                    mDragController.animateViews(yFraction, mRecyclerView);
-                }
-
-                @Override
-                public boolean shouldCaptureView(View view, int x, int y) {
-                    return view.getId() == R.id.history_frame
-                            && mDragLayout.isViewUnder(view, x, y)
-                            && !mRecyclerView.canScrollVertically(1 /* scrolling down */);
-                }
-
-                @Override
-                public int getDisplayHeight() {
-                    return 0;
-                }
-
-                @Override
-                public void onLayout(int translation) {
-                    // no-op
-                }
-            };
-
     private final DragController mDragController = new DragController();
 
     private RecyclerView mRecyclerView;
@@ -143,8 +113,8 @@
         final boolean isResultLayout = activity.isResultLayout();
 
         mDragLayout = (DragLayout) activity.findViewById(R.id.drag_layout);
-        mDragLayout.removeDragCallback(mDragCallback);
-        mDragLayout.addDragCallback(mDragCallback);
+        mDragLayout.removeDragCallback(this);
+        mDragLayout.addDragCallback(this);
 
         if (mEvaluator != null) {
             initializeController(isResultLayout);
@@ -209,7 +179,7 @@
     public void onDestroyView() {
         final DragLayout dragLayout = (DragLayout) getActivity().findViewById(R.id.drag_layout);
         if (dragLayout != null) {
-            dragLayout.removeDragCallback(mDragCallback);
+            dragLayout.removeDragCallback(this);
         }
 
         // Note that the view is destroyed when the fragment backstack is popped, so
@@ -248,4 +218,35 @@
         }
         return false;
     }
+
+    /* Begin override DragCallback methods. */
+
+    @Override
+    public void onStartDraggingOpen() {
+        // no-op
+    }
+
+    @Override
+    public void whileDragging(float yFraction) {
+        mDragController.animateViews(yFraction, mRecyclerView);
+    }
+
+    @Override
+    public boolean shouldCaptureView(View view, int x, int y) {
+        return view.getId() == R.id.history_frame
+                && mDragLayout.isViewUnder(view, x, y)
+                && !mRecyclerView.canScrollVertically(1 /* scrolling down */);
+    }
+
+    @Override
+    public int getDisplayHeight() {
+        return 0;
+    }
+
+    @Override
+    public void onLayout(int translation) {
+        // no-op
+    }
+
+    /* End override DragCallback methods. */
 }