This repository has been archived by the owner on Aug 13, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement MotionObservable in android.
Reviewers: featherless, O2 Material Motion, O6 Material Motion Android platform reviewers Reviewed By: featherless, O2 Material Motion, O6 Material Motion Android platform reviewers Subscribers: featherless Tags: #material_motion Differential Revision: http://codereview.cc/D2150
- Loading branch information
Mark Wei
committed
Dec 7, 2016
1 parent
7cde681
commit c4c5e45
Showing
5 changed files
with
190 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 0 additions & 24 deletions
24
library/src/main/java/com/google/android/material/motion/streams/Library.java
This file was deleted.
Oops, something went wrong.
80 changes: 80 additions & 0 deletions
80
library/src/main/java/com/google/android/material/motion/streams/MotionObservable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* | ||
* Copyright 2016-present The Material Motion Authors. All Rights Reserved. | ||
* | ||
* 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.material.motion.streams; | ||
|
||
import android.support.annotation.IntDef; | ||
|
||
import com.google.android.material.motion.observable.IndefiniteObservable; | ||
import com.google.android.material.motion.observable.Observer; | ||
import com.google.android.material.motion.streams.MotionObservable.MotionObserver; | ||
|
||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
|
||
/** | ||
* A MotionObservable is a type of <a href="http://reactivex.io/documentation/observable.html">Observable</a> | ||
* that specializes in motion systems that can be either active or at rest. | ||
* <p> | ||
* Throughout this documentation we will treat the words "observable" and "stream" as synonyms. | ||
* | ||
* @see <a href="https://material-motion.github.io/material-motion/starmap/specifications/streams/MotionObservable">The | ||
* motion observable specification</a> | ||
*/ | ||
public class MotionObservable<T> extends IndefiniteObservable<MotionObserver<T>> { | ||
|
||
/** | ||
* The stream is at rest. | ||
*/ | ||
public static final int AT_REST = 0; | ||
|
||
/** | ||
* The stream is currently active. | ||
*/ | ||
public static final int ACTIVE = 1; | ||
|
||
public MotionObservable(Subscriber<MotionObserver<T>> subscriber) { | ||
super(subscriber); | ||
} | ||
|
||
/** | ||
* The possible states that a stream can be in. | ||
* <p> | ||
* What "active" means is stream-dependant. The stream is active if you can answer yes to any of | ||
* the following questions: <ul> <li>Is my animation currently animating?</li> <li>Is my | ||
* physical simulation still moving?</li> <li>Is my gesture recognizer in the .began or .changed | ||
* state?</li> </ul> Momentary events such as taps may emit {@link #ACTIVE} immediately followed | ||
* by {@link #AT_REST}. | ||
*/ | ||
@IntDef({AT_REST, ACTIVE}) | ||
@Retention(RetentionPolicy.SOURCE) | ||
public @interface MotionState { | ||
|
||
} | ||
|
||
/** | ||
* An observer with an additional {@link #state(int)} method. | ||
*/ | ||
public interface MotionObserver<T> extends Observer<T> { | ||
|
||
@Override | ||
void next(T value); | ||
|
||
/** | ||
* A method to handle new state values from upstream. | ||
*/ | ||
void state(@MotionState int state); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters