Move ScrollObserver and ScrollObservable to sharedstream.

PiperOrigin-RevId: 244040945
Change-Id: I83e1c3e85155ba9fe515e036d8271c80838946c2
diff --git a/src/main/java/com/google/android/libraries/feed/sharedstream/publicapi/scroll/BUILD b/src/main/java/com/google/android/libraries/feed/sharedstream/publicapi/scroll/BUILD
new file mode 100644
index 0000000..8b1a85f
--- /dev/null
+++ b/src/main/java/com/google/android/libraries/feed/sharedstream/publicapi/scroll/BUILD
@@ -0,0 +1,10 @@
+package(default_visibility = ["//visibility:public"])
+
+licenses(["notice"])  # Apache 2
+
+android_library(
+    name = "scroll",
+    srcs = glob(["*.java"]),
+    deps = [
+    ],
+)
diff --git a/src/main/java/com/google/android/libraries/feed/sharedstream/publicapi/scroll/ScrollObservable.java b/src/main/java/com/google/android/libraries/feed/sharedstream/publicapi/scroll/ScrollObservable.java
new file mode 100644
index 0000000..984be05
--- /dev/null
+++ b/src/main/java/com/google/android/libraries/feed/sharedstream/publicapi/scroll/ScrollObservable.java
@@ -0,0 +1,28 @@
+// Copyright 2019 The Feed Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.google.android.libraries.feed.sharedstream.publicapi.scroll;
+
+/** Interface to register for scroll events. */
+public interface ScrollObservable {
+
+  /** Adds an observer for listening to future scroll events. */
+  void addScrollObserver(ScrollObserver observer);
+
+  /** Removes the specified observer from listening to scroll events. */
+  void removeScrollObserver(ScrollObserver observer);
+
+  /** Provides the current scroll state of the monitor. */
+  int getCurrentScrollState();
+}
diff --git a/src/main/java/com/google/android/libraries/feed/sharedstream/publicapi/scroll/ScrollObserver.java b/src/main/java/com/google/android/libraries/feed/sharedstream/publicapi/scroll/ScrollObserver.java
new file mode 100644
index 0000000..fabf2dd
--- /dev/null
+++ b/src/main/java/com/google/android/libraries/feed/sharedstream/publicapi/scroll/ScrollObserver.java
@@ -0,0 +1,41 @@
+// Copyright 2019 The Feed Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.google.android.libraries.feed.sharedstream.publicapi.scroll;
+
+import android.view.View;
+
+/** Observer which gets notified about scroll events. */
+public interface ScrollObserver {
+
+  /**
+   * Callback with the new state of the scrollable container.
+   *
+   * @param view the view being scrolled.
+   * @param featureId the id of the view where the scroll originated from; optional.
+   * @param newState one of the RecyclerView SCROLLING_STATE_fields.
+   * @param timestamp the time in ms when the scroll state change occurred.
+   */
+  default void onScrollStateChanged(View view, String featureId, int newState, long timestamp) {}
+
+  /**
+   * Callback with the change in x/y from the most recent scroll events.
+   *
+   * @param view the view being scrolled.
+   * @param featureId the id of the view where the scroll originated from; optional.
+   * @param dx the amount scrolled in the x direction.
+   * @param dy the amount scrolled in the y direction.
+   */
+  void onScroll(View view, String featureId, int dx, int dy);
+}