Remove close method from prediction API
After the latest changes, the close method is no longer needed.
Bug: 232941452
Test: builds properly
Relnote: removed close method as it is no longer needed
Change-Id: I843491e06b583282a4a085737429c80bc6322d99
diff --git a/input/input-motionprediction/api/current.txt b/input/input-motionprediction/api/current.txt
index 6611119..b0eef8e 100644
--- a/input/input-motionprediction/api/current.txt
+++ b/input/input-motionprediction/api/current.txt
@@ -1,8 +1,7 @@
// Signature format: 4.0
package androidx.input.motionprediction {
- public interface MotionEventPredictor extends java.lang.AutoCloseable {
- method public void close();
+ public interface MotionEventPredictor {
method public static androidx.input.motionprediction.MotionEventPredictor newInstance(android.view.View);
method public android.view.MotionEvent? predict();
method public void record(android.view.MotionEvent);
diff --git a/input/input-motionprediction/api/public_plus_experimental_current.txt b/input/input-motionprediction/api/public_plus_experimental_current.txt
index 6611119..b0eef8e 100644
--- a/input/input-motionprediction/api/public_plus_experimental_current.txt
+++ b/input/input-motionprediction/api/public_plus_experimental_current.txt
@@ -1,8 +1,7 @@
// Signature format: 4.0
package androidx.input.motionprediction {
- public interface MotionEventPredictor extends java.lang.AutoCloseable {
- method public void close();
+ public interface MotionEventPredictor {
method public static androidx.input.motionprediction.MotionEventPredictor newInstance(android.view.View);
method public android.view.MotionEvent? predict();
method public void record(android.view.MotionEvent);
diff --git a/input/input-motionprediction/api/restricted_current.txt b/input/input-motionprediction/api/restricted_current.txt
index 6611119..b0eef8e 100644
--- a/input/input-motionprediction/api/restricted_current.txt
+++ b/input/input-motionprediction/api/restricted_current.txt
@@ -1,8 +1,7 @@
// Signature format: 4.0
package androidx.input.motionprediction {
- public interface MotionEventPredictor extends java.lang.AutoCloseable {
- method public void close();
+ public interface MotionEventPredictor {
method public static androidx.input.motionprediction.MotionEventPredictor newInstance(android.view.View);
method public android.view.MotionEvent? predict();
method public void record(android.view.MotionEvent);
diff --git a/input/input-motionprediction/src/main/java/androidx/input/motionprediction/MotionEventPredictor.java b/input/input-motionprediction/src/main/java/androidx/input/motionprediction/MotionEventPredictor.java
index 66da8cf..e976419 100644
--- a/input/input-motionprediction/src/main/java/androidx/input/motionprediction/MotionEventPredictor.java
+++ b/input/input-motionprediction/src/main/java/androidx/input/motionprediction/MotionEventPredictor.java
@@ -30,10 +30,9 @@
* {@link #newInstance(android.view.View)}; put the motion events you receive into it with
* {@link #record(android.view.MotionEvent)}, and call {@link #predict()} to retrieve the
* predicted {@link android.view.MotionEvent} that would occur at the moment the next frame is
- * rendered on the display. Once no more predictions are needed, call {@link #close()} to stop it
- * and clean up resources.
+ * rendered on the display.
*/
-public interface MotionEventPredictor extends AutoCloseable {
+public interface MotionEventPredictor {
/**
* Record a user's movement to the predictor. You should call this for every
* {@link android.view.MotionEvent} that is received by the associated
@@ -53,13 +52,6 @@
MotionEvent predict();
/**
- * Notify the predictor that no more predictions are needed. Any subsequent call to
- * {@link #predict()} will return null.
- */
- @Override
- void close();
-
- /**
* Create a new motion predictor associated to a specific {@link android.view.View}
* @param view the view to associated to this predictor
* @return the new predictor instance
diff --git a/input/input-motionprediction/src/main/java/androidx/input/motionprediction/kalman/KalmanMotionEventPredictor.java b/input/input-motionprediction/src/main/java/androidx/input/motionprediction/kalman/KalmanMotionEventPredictor.java
index 9a41bb5..1b7d73b 100644
--- a/input/input-motionprediction/src/main/java/androidx/input/motionprediction/kalman/KalmanMotionEventPredictor.java
+++ b/input/input-motionprediction/src/main/java/androidx/input/motionprediction/kalman/KalmanMotionEventPredictor.java
@@ -31,8 +31,8 @@
*/
@RestrictTo(LIBRARY)
public class KalmanMotionEventPredictor implements MotionEventPredictor {
- private MultiPointerPredictor mMultiPointerPredictor = new MultiPointerPredictor();
- private PredictionEstimator mPredictionEstimator;
+ private final MultiPointerPredictor mMultiPointerPredictor = new MultiPointerPredictor();
+ private final PredictionEstimator mPredictionEstimator;
public KalmanMotionEventPredictor(@NonNull Context context) {
mPredictionEstimator = new PredictionEstimator(context);
@@ -40,9 +40,6 @@
@Override
public void record(@NonNull MotionEvent event) {
- if (mMultiPointerPredictor == null) {
- return;
- }
mPredictionEstimator.record(event);
mMultiPointerPredictor.onTouchEvent(event);
}
@@ -50,15 +47,7 @@
@Nullable
@Override
public MotionEvent predict() {
- if (mMultiPointerPredictor == null) {
- return null;
- }
final int predictionTimeDelta = mPredictionEstimator.estimate();
return mMultiPointerPredictor.predict(predictionTimeDelta);
}
-
- @Override
- public void close() {
- mMultiPointerPredictor = null;
- }
}