mViewTransformerList = new ArrayList<>();
15 |
16 | public CustomTransitionController() {
17 | super(null);
18 | updateProgressWidth();
19 | }
20 |
21 | public void addViewTransformer(ViewTransformer mViewTransformer) {
22 | mViewTransformerList.add(mViewTransformer);
23 | }
24 |
25 | @Override
26 | public void updateProgress(float progress) {
27 | for (int i = 0, count = mViewTransformerList.size(); i < count; ++i) {
28 | mViewTransformerList.get(i).updateView(this, getTarget(), progress);
29 | }
30 | }
31 |
32 | @CheckResult
33 | @Override
34 | public CustomTransitionController clone() {
35 | CustomTransitionController newCopy = (CustomTransitionController) super.clone();
36 | newCopy.mViewTransformerList = new ArrayList<>(mViewTransformerList.size());
37 | newCopy.mViewTransformerList.addAll(mViewTransformerList);
38 | return newCopy;
39 | }
40 |
41 | protected CustomTransitionController self() {
42 | return this;
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/app/src/main/java/com/kaichunlin/transition/app/SlidingUpPanelRotateActivity.java:
--------------------------------------------------------------------------------
1 | package com.kaichunlin.transition.app;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.support.v7.widget.Toolbar;
6 | import android.view.View;
7 |
8 | import com.kaichunlin.transition.ViewTransitionBuilder;
9 | import com.kaichunlin.transition.adapter.SlidingUpPanelLayoutAdapter;
10 | import com.sothree.slidinguppanel.SlidingUpPanelLayout;
11 |
12 | import kaichunlin.transition.app.R;
13 |
14 |
15 | public class SlidingUpPanelRotateActivity extends AppCompatActivity {
16 |
17 | private SlidingUpPanelLayoutAdapter mSlidingUpPanelLayoutAdapter;
18 |
19 | @Override
20 | protected void onCreate(Bundle savedInstanceState) {
21 | super.onCreate(savedInstanceState);
22 |
23 | setContentView(R.layout.activity_slideup_actionbar_transparent);
24 | findViewById(R.id.content_bg).setVisibility(View.VISIBLE);
25 | findViewById(R.id.content_bg2).setVisibility(View.VISIBLE);
26 |
27 | final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
28 | setSupportActionBar(toolbar);
29 |
30 | final SlidingUpPanelLayout supl=((SlidingUpPanelLayout)findViewById(R.id.sliding_layout));
31 |
32 | //code to transit view
33 | mSlidingUpPanelLayoutAdapter = new SlidingUpPanelLayoutAdapter();
34 | ViewTransitionBuilder.transit(findViewById(R.id.content_bg)).rotationY(90).endRange(0.25f).id("BG").buildFor(mSlidingUpPanelLayoutAdapter);
35 | ViewTransitionBuilder.transit(findViewById(R.id.content_bg2)).rotationY(270, 360).range(0.25f, 0.5f).id("BG_2").buildFor(mSlidingUpPanelLayoutAdapter);
36 | ViewTransitionBuilder.transit(findViewById(R.id.toolbar)).alpha(0f).buildFor(mSlidingUpPanelLayoutAdapter);
37 | supl.addPanelSlideListener(mSlidingUpPanelLayoutAdapter);
38 |
39 | mSlidingUpPanelLayoutAdapter.setPanelSlideListener(new DialogPanelSlideListener(this));
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/core/src/main/java/com/kaichunlin/transition/transformer/ColorTransformer.java:
--------------------------------------------------------------------------------
1 | package com.kaichunlin.transition.transformer;
2 |
3 | import android.view.View;
4 |
5 | import com.kaichunlin.transition.internal.TransitionController;
6 |
7 | /**
8 | * Helper to transform from one color to another, how this color is used depends on the subclass.
9 | */
10 | public abstract class ColorTransformer extends ScaledTransformer {
11 | final int startColor;
12 | final int endColor;
13 |
14 | public ColorTransformer(int startColor, int endColor) {
15 | this.startColor = startColor;
16 | this.endColor = endColor;
17 | }
18 |
19 | @Override
20 | protected void updateViewScaled(TransitionController controller, View target, float scaledProgress) {
21 | updateViewWithColor(controller, target, evaluate(scaledProgress, startColor, endColor));
22 | }
23 |
24 | /**
25 | * Similar to {@link #updateView(TransitionController, View, float)}, with the addition of the current color.
26 | *
27 | * @param controller
28 | * @param target
29 | * @param color The current color calculated using the starting color, the end color, and the current progress.
30 | */
31 | protected abstract void updateViewWithColor(TransitionController controller, View target, int color);
32 |
33 | private int evaluate(float fraction, int startValue, int endValue) {
34 | int startA = (startValue >>> 24);
35 | int startR = (startValue >> 16) & 0xff;
36 | int startG = (startValue >> 8) & 0xff;
37 | int startB = startValue & 0xff;
38 |
39 | int endA = (endValue >>> 24);
40 | int endR = (endValue >> 16) & 0xff;
41 | int endG = (endValue >> 8) & 0xff;
42 | int endB = endValue & 0xff;
43 |
44 | return ((startA + (int) (fraction * (endA - startA))) << 24) |
45 | ((startR + (int) (fraction * (endR - startR))) << 16) |
46 | ((startG + (int) (fraction * (endG - startG))) << 8) |
47 | ((startB + (int) (fraction * (endB - startB))));
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/slidinguppanel/src/main/java/com/kaichunlin/transition/adapter/SlidingUpPanelLayoutAdapter.java:
--------------------------------------------------------------------------------
1 | package com.kaichunlin.transition.adapter;
2 |
3 | import android.support.annotation.Nullable;
4 | import android.view.View;
5 |
6 | import com.sothree.slidinguppanel.SlidingUpPanelLayout;
7 |
8 | /**
9 | * Adapter for SlidingUpPanelLayout, the transition range goes from 0.0f to 1.0f, where 0.0f is the collapsed state and 1.0f is the expanded state.
10 | *
11 | * Created by Kai-Chun Lin on 2015/4/14.
12 | */
13 | public class SlidingUpPanelLayoutAdapter extends MenuBaseAdapter implements SlidingUpPanelLayout.PanelSlideListener {
14 | private SlidingUpPanelLayout.PanelSlideListener mListener;
15 |
16 | /**
17 | * Sets a listener that can provide further customization, the respective calls to the listener is performed after the adapter has completed its own processing.
18 | *
19 | * @param listener
20 | */
21 | public void setPanelSlideListener(@Nullable SlidingUpPanelLayout.PanelSlideListener listener) {
22 | mListener = listener;
23 | }
24 |
25 | @Override
26 | public void onPanelSlide(View panel, float slideOffset) {
27 | startTransition();
28 | getTransitionManager().updateProgress(slideOffset);
29 |
30 | if (mListener != null) {
31 | mListener.onPanelSlide(panel, slideOffset);
32 | }
33 | }
34 |
35 | @Override
36 | public void onPanelStateChanged(View panel, SlidingUpPanelLayout.PanelState previousState, SlidingUpPanelLayout.PanelState newState) {
37 | if (newState == SlidingUpPanelLayout.PanelState.COLLAPSED) {
38 | getAdapterState().setState(AdapterState.CLOSE);
39 | } else if (newState == SlidingUpPanelLayout.PanelState.EXPANDED) {
40 | getAdapterState().setState(AdapterState.OPEN);
41 | }
42 | stopTransition();
43 | mListener.onPanelStateChanged(panel, previousState, newState);
44 | }
45 |
46 | @Override
47 | protected MenuOptionHandler createMenuHandler() {
48 | return new DefaultMenuOptionHandler(this, getAdapterState());
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
16 |
17 |
22 |
23 |
26 |
27 |
30 |
31 |
35 |
36 |
44 |
45 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
12 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
25 |
28 |
31 |
34 |
37 |
41 |
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/core/src/main/java/com/kaichunlin/transition/transformer/ScaledTransformer.java:
--------------------------------------------------------------------------------
1 | package com.kaichunlin.transition.transformer;
2 |
3 | import android.view.View;
4 |
5 | import com.kaichunlin.transition.internal.TransitionController;
6 |
7 | /**
8 | * The progress valued passed to @link {@link #updateView(TransitionController, View, float)} has taken the start and end range
9 | * into consideration. The method will only be called when the progress is within range, and the value passed has been scaled to be
10 | * always between 0f to 1f.
11 | */
12 | public abstract class ScaledTransformer implements ViewTransformer {
13 | private final boolean updateOnceOutsideRange;
14 | private boolean updateMinProgress = true;
15 | private boolean updateMaxProgress = true;
16 |
17 | public ScaledTransformer() {
18 | this(false);
19 | }
20 |
21 | public ScaledTransformer(boolean updateOnceOutsideRange) {
22 | this.updateOnceOutsideRange = updateOnceOutsideRange;
23 | }
24 |
25 | @Override
26 | public final void updateView(TransitionController controller, View target, float progress) {
27 | final float start = controller.getStart();
28 | final float end = controller.getEnd();
29 | if (progress < start) {
30 | if (updateOnceOutsideRange && updateMinProgress) {
31 | updateViewScaled(controller, target, 0);
32 | }
33 | updateMinProgress = false;
34 | return;
35 | }
36 | updateMinProgress = true;
37 | if (progress > end) {
38 | if (updateOnceOutsideRange && updateMaxProgress) {
39 | updateViewScaled(controller, target, 1);
40 | }
41 | updateMaxProgress = false;
42 | return;
43 | }
44 | updateMaxProgress = true;
45 | updateViewScaled(controller, target, (progress - start) / (end - start));
46 | }
47 |
48 | /**
49 | * @param controller
50 | * @param target
51 | * @param scaledProgress
52 | */
53 | protected abstract void updateViewScaled(TransitionController controller, View target, float scaledProgress);
54 | }
55 |
--------------------------------------------------------------------------------
/core/src/main/java/com/kaichunlin/transition/internal/debug/TraceAnimationListener.java:
--------------------------------------------------------------------------------
1 | package com.kaichunlin.transition.internal.debug;
2 |
3 | import com.kaichunlin.transition.animation.Animation;
4 | import com.kaichunlin.transition.animation.AnimationListener;
5 | import com.kaichunlin.transition.TransitionConfig;
6 |
7 | /**
8 | * Use Log.i to output the start and end of an animation
9 | */
10 | public class TraceAnimationListener implements AnimationListener {
11 | private long mStart;
12 |
13 | @Override
14 | public void onAnimationStart(Animation animationManager) {
15 | mStart = System.currentTimeMillis();
16 | if (TransitionConfig.isDebug()) {
17 | try {
18 | throw new IllegalStateException("Tracer: onAnimationStart: " + animationManager);
19 | } catch (IllegalStateException e) {
20 | e.printStackTrace();
21 | }
22 | }
23 | }
24 |
25 | @Override
26 | public void onAnimationEnd(Animation animationManager) {
27 | if (TransitionConfig.isDebug()) {
28 | try {
29 | throw new IllegalStateException("Tracer: onAnimationEnd, duration=" + (System.currentTimeMillis() - mStart) + ": " + animationManager);
30 | } catch (IllegalStateException e) {
31 | e.printStackTrace();
32 | }
33 | }
34 | }
35 |
36 | @Override
37 | public void onAnimationCancel(Animation animationManager) {
38 | if (TransitionConfig.isDebug()) {
39 | try {
40 | throw new IllegalStateException("Tracer: onAnimationCancel, duration=" + (System.currentTimeMillis() - mStart) + ": " + animationManager);
41 | } catch (IllegalStateException e) {
42 | e.printStackTrace();
43 | }
44 | }
45 | }
46 |
47 | @Override
48 | public void onAnimationReset(Animation animationManager) {
49 | if (TransitionConfig.isDebug()) {
50 | try {
51 | throw new IllegalStateException("Tracer: onAnimationReset, duration=" + (System.currentTimeMillis() - mStart) + ": " + animationManager);
52 | } catch (IllegalStateException e) {
53 | e.printStackTrace();
54 | }
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_slideup_actionbar_transparent.xml:
--------------------------------------------------------------------------------
1 |
2 |
15 |
16 |
20 |
21 |
28 |
29 |
36 |
37 |
47 |
48 |
49 |
56 |
--------------------------------------------------------------------------------
/core/src/main/java/com/kaichunlin/transition/adapter/MenuOptionHandler.java:
--------------------------------------------------------------------------------
1 | package com.kaichunlin.transition.adapter;
2 |
3 | import android.app.Activity;
4 | import android.support.annotation.NonNull;
5 | import android.support.annotation.Nullable;
6 | import android.view.Menu;
7 |
8 | /**
9 | */
10 | public interface MenuOptionHandler {
11 | AdapterState getAdapterState();
12 |
13 | /**
14 | * Syncs current state of Menu with transitions
15 | *
16 | * @param activity
17 | * @param menu
18 | */
19 | void onCreateOptionsMenu(@NonNull Activity activity, @NonNull Menu menu);
20 |
21 | /**
22 | * Syncs current state of Menu with transitions
23 | *
24 | * @param activity
25 | * @param menu
26 | * @param adapterState a different {@link AdapterState} than the one retrieved by calling getAdapterState()
27 | */
28 | void onCreateOptionsMenu(@NonNull Activity activity, @NonNull Menu menu, @NonNull AdapterState adapterState);
29 |
30 | /**
31 | * Sets transitions to {@link android.view.MenuItem} in both the opened state and closed state with only
32 | * the opened state's transition specified, which is used to build menu transition in the closed state
33 | *
34 | * @param activity
35 | * @param openConfig
36 | */
37 | void setupOption(@NonNull Activity activity, @Nullable MenuOptionConfiguration openConfig);
38 |
39 | /**
40 | * Sets transitions to {@link android.view.MenuItem} in the opened state
41 | *
42 | * @param activity
43 | * @param openConfig
44 | */
45 | void setupOpenOption(@NonNull Activity activity, @Nullable MenuOptionConfiguration openConfig);
46 |
47 | /**
48 | * Sets transitions to {@link android.view.MenuItem} in the closed state
49 | *
50 | * @param activity
51 | * @param closeConfig
52 | */
53 | void setupCloseOption(@NonNull Activity activity, @Nullable MenuOptionConfiguration closeConfig);
54 |
55 | /**
56 | * Sets transitions to {@link android.view.MenuItem} in both the opened state and closed state
57 | *
58 | * @param activity
59 | * @param openConfig
60 | * @param closeConfig
61 | */
62 | void setupOptions(@NonNull Activity activity, @Nullable MenuOptionConfiguration openConfig, @Nullable MenuOptionConfiguration closeConfig);
63 |
64 | /**
65 | * Clears menu transition
66 | */
67 | void clearOptions();
68 |
69 | MenuOptionConfiguration getOpenConfig();
70 |
71 | MenuOptionConfiguration getCloseConfig();
72 | }
73 |
--------------------------------------------------------------------------------
/core/src/main/java/com/kaichunlin/transition/Transition.java:
--------------------------------------------------------------------------------
1 | package com.kaichunlin.transition;
2 |
3 | import android.support.annotation.UiThread;
4 | import android.view.View;
5 | import android.view.animation.Interpolator;
6 |
7 | /**
8 | * Represent the operations that should be performed with the given progress, usually on a View.
9 | */
10 | public interface Transition extends TransitionOperation, Cloneable {
11 |
12 | /**
13 | * Sets an ID the transition, used internally for debugging purpose.
14 | *
15 | * @param id
16 | * @return
17 | */
18 | AbstractTransition setId(String id);
19 |
20 | /**
21 | *
22 | * @return ID assigned for the transition, used internally for debugging purpose.
23 | */
24 | String getId();
25 |
26 | /**
27 | * Sets the transition progress, many times in the range of 0.0f ~ 1.0f, but not necessarily so.
28 | *
29 | * @param progress
30 | */
31 | @UiThread
32 | void setProgress(float progress);
33 |
34 | /**
35 | * Reverses the transition.
36 | *
37 | * @return itself
38 | */
39 | Transition reverse();
40 |
41 | /**
42 | * A {@link AbstractTransition.Setup} is an object that configures how a Transition for a specific effect.
43 | *
44 | * For examples see MenuItemTransitionBuilder.setupAnimation(MenuItem, TransitionControllerManager, int, int)
45 | * and ViewTransitionBuilder#setupAnimation(TransitionControllerManager).
46 | *
47 | * @param setup
48 | * @return itself
49 | */
50 | Transition setSetup(T setup);
51 |
52 | /**
53 | *
54 | * @return A carbon clone of this object that can be used independently from the object it's cloned from.
55 | */
56 | Transition clone();
57 |
58 | /**
59 | *
60 | * @param interpolator The Interpolator that should be used.
61 | * @return itself
62 | */
63 | Transition setInterpolator(Interpolator interpolator);
64 |
65 | /**
66 | *
67 | * @param target The View this transition would modify.
68 | */
69 | void setTarget(View target);
70 |
71 | /**
72 | *
73 | * @return The View this transition would modify.
74 | */
75 | View getTarget();
76 |
77 | /**
78 | *
79 | * @param updateStateAfterUpdateProgress Whether or not to update a controller's enable state after
80 | * each {@link #updateProgress(float)} call.
81 | * @return itself
82 | */
83 | Transition setUpdateStateAfterUpdateProgress(boolean updateStateAfterUpdateProgress);
84 | }
85 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_drawer_menuitem.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
18 |
19 |
20 |
25 |
26 |
31 |
35 |
39 |
43 |
44 |
45 |
46 |
47 |
57 |
58 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Transition
3 |
4 | View Pager (In Progress)
5 | Sliding Up Panel
6 | Rotate Image
7 | Drawer View Transition
8 | MenuItem Transition
9 | Shifting Gradient Drawer
10 |
11 | Flip and Fade
12 | Shrink and Fade
13 | Rotate
14 |
15 | Slowly slides your finger from the left edge of the screen towards right to see the transition.
16 | Press on "The Awesome Sliding Up Panel" and slowly slides your finger up to see the transition.
17 | OK
18 |
19 | The Awesome Sliding Up Panel
20 | Rotate and Slide
21 | Rotating ActionBar
22 | Sliding ActionBar and Subviews
23 | Fading ActionBar
24 | Change ActionBar Color
25 | Change ActionBar Color HSV
26 | Background to Grayscale
27 | Cascade Fading
28 | Cascade Rolling
29 | Rotate and Shrink View
30 | Sliding Subviews
31 | Sliding Background
32 | Animate
33 | Pause
34 | Resume
35 | Interpolator
36 | Default
37 | Linear
38 | Accelerate
39 | Decelerate
40 | Fast Out Linear In
41 | Anticipate
42 |
43 | Open navigation drawer
44 | Close navigation drawer
45 |
46 |
--------------------------------------------------------------------------------
/core/src/main/java/com/kaichunlin/transition/adapter/MenuBaseAdapter.java:
--------------------------------------------------------------------------------
1 | package com.kaichunlin.transition.adapter;
2 |
3 | import android.app.Activity;
4 | import android.support.annotation.NonNull;
5 | import android.support.annotation.Nullable;
6 | import android.view.Menu;
7 |
8 | /**
9 | * Adds support for {@link android.view.MenuItem} transition.
10 | */
11 | public abstract class MenuBaseAdapter extends AbstractAdapter implements MenuOptionHandler {
12 | MenuOptionHandler mMenuHandler;
13 |
14 | protected abstract MenuOptionHandler createMenuHandler();
15 |
16 | @Override
17 | public void removeAllTransitions() {
18 | super.removeAllTransitions();
19 | createMenuHandlerIfNecessary();
20 | mMenuHandler.clearOptions();
21 | }
22 |
23 | protected MenuOptionHandler getMenuOptionHandler() {
24 | return mMenuHandler;
25 | }
26 |
27 | private void createMenuHandlerIfNecessary() {
28 | if (mMenuHandler == null) {
29 | mMenuHandler = createMenuHandler();
30 | }
31 | }
32 |
33 | public void onCreateOptionsMenu(@NonNull Activity activity, @NonNull Menu menu) {
34 | createMenuHandlerIfNecessary();
35 | mMenuHandler.onCreateOptionsMenu(activity, menu);
36 | }
37 |
38 | public void onCreateOptionsMenu(@NonNull Activity activity, @NonNull Menu menu, AdapterState adapterState) {
39 | createMenuHandlerIfNecessary();
40 | mMenuHandler.onCreateOptionsMenu(activity, menu, adapterState);
41 | }
42 |
43 | @Override
44 | public void setupOption(@NonNull Activity activity, MenuOptionConfiguration openConfig) {
45 | createMenuHandlerIfNecessary();
46 | mMenuHandler.setupOption(activity, openConfig);
47 | }
48 |
49 | @Override
50 | public void setupOpenOption(@NonNull Activity activity, MenuOptionConfiguration openConfig) {
51 | createMenuHandlerIfNecessary();
52 | mMenuHandler.setupOpenOption(activity, openConfig);
53 | }
54 |
55 | @Override
56 | public void setupCloseOption(@NonNull Activity activity, MenuOptionConfiguration closeConfig) {
57 | createMenuHandlerIfNecessary();
58 | mMenuHandler.setupCloseOption(activity, closeConfig);
59 | }
60 |
61 | @Override
62 | public void setupOptions(@NonNull Activity activity, MenuOptionConfiguration openConfig, MenuOptionConfiguration closeConfig) {
63 | createMenuHandlerIfNecessary();
64 | mMenuHandler.setupOptions(activity, openConfig, closeConfig);
65 | }
66 |
67 | @Override
68 | public void clearOptions() {
69 | mMenuHandler.clearOptions();
70 | }
71 |
72 | @Nullable
73 | @Override
74 | public MenuOptionConfiguration getOpenConfig() {
75 | return mMenuHandler.getOpenConfig();
76 | }
77 |
78 | @Nullable
79 | @Override
80 | public MenuOptionConfiguration getCloseConfig() {
81 | return mMenuHandler.getCloseConfig();
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
21 |
22 |
25 |
26 |
32 |
33 |
37 |
38 |
42 |
43 |
47 |
48 |
52 |
53 |
57 |
58 |
62 |
63 |
67 |
68 |
69 |
--------------------------------------------------------------------------------
/core/src/main/java/com/kaichunlin/transition/animation/Animation.java:
--------------------------------------------------------------------------------
1 | package com.kaichunlin.transition.animation;
2 |
3 | import android.support.annotation.IntRange;
4 | import android.support.annotation.UiThread;
5 |
6 | /**
7 | * Interface for an Animation.
8 | */
9 | @UiThread
10 | public interface Animation {
11 |
12 | /**
13 | * @param listener
14 | */
15 | void addAnimationListener(AnimationListener listener);
16 |
17 | /**
18 | * @param listener
19 | */
20 | void removeAnimationListener(AnimationListener listener);
21 |
22 | /**
23 | *
24 | * @param duration Length of the animation.
25 | */
26 | void setDuration(@IntRange(from = 0) int duration);
27 |
28 | int getDuration();
29 |
30 | /**
31 | *
32 | * @param reverse If true, the animation will be played backward.
33 | */
34 | void setReverseAnimation(boolean reverse);
35 |
36 | /**
37 | * @return true if {@link #setReverseAnimation(boolean)} has been set to true.
38 | */
39 | boolean isReverseAnimation();
40 |
41 | /**
42 | * Starts the animation with the default duration (300 ms).
43 | */
44 | void startAnimation();
45 |
46 | /**
47 | * Starts the animation with the specified duration.
48 | *
49 | * @param duration
50 | */
51 | void startAnimation(@IntRange(from = 0) int duration);
52 |
53 | /**
54 | * Same as {@link #startAnimation()}, but with an added delay before the animation is started.
55 |
56 | * @param delay
57 | */
58 | void startAnimationDelayed(@IntRange(from = 0) int delay);
59 |
60 | /**
61 | * Same as {@link #startAnimation(int)}, but with an added delay before the animation is started.
62 | *
63 | * @param duration
64 | * @param delay
65 | */
66 | void startAnimationDelayed(@IntRange(from = 0) int duration, @IntRange(from = 0) int delay);
67 |
68 | /**
69 | *
70 | * @return Is the Animation in the started state.
71 | */
72 | boolean isAnimating();
73 |
74 | /**
75 | * Cancels the animation, i.e. the affected Views will retain their current states but will no longer
76 | * advance the animation. A canceled animation cannot be resumed.
77 | */
78 | void cancelAnimation();
79 |
80 | /**
81 | * Pauses the animation, i.e. the affected Views will retain their current states but will no longer
82 | * advance the animation. {@link #resumeAnimation()} can be called afterwards.
83 | */
84 | void pauseAnimation();
85 |
86 | /**
87 | * Resumes the animation, i.e. the affected Views will continue the animations from the paused states.
88 | */
89 | void resumeAnimation();
90 |
91 | /**
92 | * Ends the animation, i.e. the affected Views will be assigned their final states.
93 | */
94 | void endAnimation();
95 |
96 | /**
97 | * Forces the animation's end state to be applied immediately even if the animation has not started.
98 | * If the animation has started, it will end immediately, the effect would be the same as calling
99 | * {@link #endAnimation()}.
100 | */
101 | void forceEndState();
102 |
103 | /**
104 | * Stops the animation, i.e. the affected Views will be reverted to their original states at the
105 | * beginning of the animation.
106 | */
107 | void resetAnimation();
108 | }
109 |
--------------------------------------------------------------------------------
/core/src/main/java/com/kaichunlin/transition/adapter/MenuAnimationAdapter.java:
--------------------------------------------------------------------------------
1 | package com.kaichunlin.transition.adapter;
2 |
3 | import android.app.Activity;
4 | import android.support.annotation.IntRange;
5 | import android.support.annotation.NonNull;
6 | import android.support.annotation.Nullable;
7 | import android.view.Menu;
8 |
9 | /**
10 | * Similar to {@link AnimationAdapter} with the addition of MenuItem animation support.
11 | */
12 | public class MenuAnimationAdapter extends AnimationAdapter implements MenuOptionHandler {
13 | private MenuOptionHandler mMenuOptionHandler = new DefaultMenuOptionHandler(this, getAdapterState());
14 |
15 | public MenuAnimationAdapter() {
16 | super();
17 | }
18 |
19 | /**
20 | * Wraps an existing {@link MenuBaseAdapter} to reuse its onCreateOptionsMenu(...) logic and its transition effects
21 | *
22 | * @param adapter
23 | */
24 | public MenuAnimationAdapter(@Nullable TransitionAdapter adapter) {
25 | super(adapter);
26 | }
27 |
28 | @Override
29 | public void startAnimation(@IntRange(from = 0) int duration) {
30 | AdapterState adapterState = getAdapterState();
31 | adapterState.setState(adapterState.getState() == AdapterState.OPEN ? AdapterState.CLOSE : AdapterState.OPEN);
32 |
33 | setReverseAnimation(adapterState.isOpen());
34 | super.startAnimation(duration);
35 | }
36 |
37 | public void setMenuOptionHandler(@NonNull MenuOptionHandler menuOptionHandler) {
38 | mMenuOptionHandler = menuOptionHandler;
39 | }
40 |
41 | private MenuOptionHandler getHandler() {
42 | return getAdapter() == null ? mMenuOptionHandler : (MenuOptionHandler) getAdapter();
43 | }
44 |
45 | public void onCreateOptionsMenu(@NonNull Activity activity, @NonNull Menu menu) {
46 | if (getAdapter() == null) {
47 | mMenuOptionHandler.onCreateOptionsMenu(activity, menu);
48 | } else {
49 | ((MenuBaseAdapter) getAdapter()).onCreateOptionsMenu(activity, menu, mMenuOptionHandler.getAdapterState());
50 | }
51 | }
52 |
53 | @Override
54 | public void onCreateOptionsMenu(@NonNull Activity activity, @NonNull Menu menu, @NonNull AdapterState adapterState) {
55 | getHandler().onCreateOptionsMenu(activity, menu, adapterState);
56 | }
57 |
58 | public void setupOption(@NonNull Activity activity, @Nullable MenuOptionConfiguration openConfig) {
59 | getHandler().setupOption(activity, openConfig);
60 | }
61 |
62 | public void setupOpenOption(@NonNull Activity activity, @Nullable MenuOptionConfiguration openConfig) {
63 | getHandler().setupOpenOption(activity, openConfig);
64 | }
65 |
66 | public void setupCloseOption(@NonNull Activity activity, @Nullable MenuOptionConfiguration closeConfig) {
67 | getHandler().setupCloseOption(activity, closeConfig);
68 | }
69 |
70 | public void setupOptions(@NonNull Activity activity, @Nullable MenuOptionConfiguration openConfig, @Nullable MenuOptionConfiguration closeConfig) {
71 | getHandler().setupOptions(activity, openConfig, closeConfig);
72 | }
73 |
74 | @Override
75 | public void clearOptions() {
76 | getHandler().clearOptions();
77 | }
78 |
79 | @Override
80 | public MenuOptionConfiguration getOpenConfig() {
81 | return getHandler().getOpenConfig();
82 | }
83 |
84 | @Override
85 | public MenuOptionConfiguration getCloseConfig() {
86 | return getHandler().getCloseConfig();
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/upload.gradle:
--------------------------------------------------------------------------------
1 |
2 |
3 | /**
4 | * JCenter publishing logic courtesy of https://www.virag.si/2015/01/publishing-gradle-android-library-to-jcenter/
5 | */
6 | def siteUrl = 'https://github.com/kaichunlin/android-transition' // Homepage URL of the library
7 | def gitUrl = 'https://github.com/kaichunlin/android-transition.git' // Git repository URL
8 | group = "com.github.kaichunlin.transition" // Maven Group ID for the artifact
9 |
10 | Properties moduleProperties = new Properties()
11 | moduleProperties.load(project.file('module.properties').newDataInputStream())
12 |
13 | ext.artifactId = moduleProperties.getProperty("module.name")
14 |
15 | install {
16 | repositories.mavenInstaller {
17 | // This generates POM.xml with proper parameters
18 | pom {
19 | project {
20 | packaging 'aar'
21 |
22 | // Add your description here
23 | name moduleProperties.getProperty("module.pom_name")
24 | // http://stackoverflow.com/questions/30475780/how-to-change-the-default-artifactid-of-maven-metadata-xml-when-uploading-to-bin/30476385#30476385
25 | // artifactId = moduleProperties.getProperty("module.artifactId")
26 | description moduleProperties.getProperty("module.desc")
27 | url siteUrl
28 |
29 | // Set your license
30 | licenses {
31 | license {
32 | name 'The Apache Software License, Version 2.0'
33 | url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
34 | }
35 | }
36 | developers {
37 | developer {
38 | id 'kaichunlin'
39 | name 'Kai-Chun Lin'
40 | email 'kaichun.lin@gmail.com'
41 | }
42 | }
43 | scm {
44 | connection gitUrl
45 | developerConnection gitUrl
46 | url siteUrl
47 | }
48 | }
49 | }
50 | }
51 | }
52 |
53 | task sourcesJar(type: Jar) {
54 | from android.sourceSets.main.java.srcDirs
55 | classifier = 'sources'
56 | }
57 |
58 | task javadoc(type: Javadoc) {
59 | source = android.sourceSets.main.java.srcDirs
60 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
61 | }
62 |
63 | task javadocJar(type: Jar, dependsOn: javadoc) {
64 | classifier = 'javadoc'
65 | from javadoc.destinationDir
66 | }
67 |
68 | artifacts {
69 | archives javadocJar
70 | archives sourcesJar
71 | }
72 |
73 | Properties properties = new Properties()
74 | properties.load(project.rootProject.file('local.properties').newDataInputStream())
75 |
76 | def test = false
77 |
78 | bintray {
79 | user = properties.getProperty("bintray.user")
80 | key = properties.getProperty("bintray.apikey")
81 |
82 | configurations = ['archives']
83 | dryRun = test //Whether to run this as dry-run, without deploying
84 | publish = !test //If version should be auto published after an upload
85 | pkg {
86 | repo = "maven"
87 | name = moduleProperties.getProperty("module.bintray")
88 | websiteUrl = siteUrl
89 | vcsUrl = gitUrl
90 | licenses = ["Apache-2.0"]
91 | publish = !test
92 | version {
93 | gpg {
94 | sign = true //Determines whether to GPG sign the files. The default is false
95 | // passphrase = properties.getProperty("bintray.gpg.password") //Optional. The passphrase for GPG signing'
96 | }
97 | }
98 | }
99 | }
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_drawer_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
20 |
21 |
22 |
27 |
28 |
32 |
33 |
38 |
39 |
45 |
46 |
51 |
52 |
57 |
58 |
63 |
64 |
69 |
70 |
71 |
72 |
73 |
74 |
84 |
85 |
--------------------------------------------------------------------------------
/core/src/main/java/com/kaichunlin/transition/adapter/AbstractAdapter.java:
--------------------------------------------------------------------------------
1 | package com.kaichunlin.transition.adapter;
2 |
3 | import android.support.annotation.NonNull;
4 |
5 | import com.kaichunlin.transition.AbstractTransitionBuilder;
6 | import com.kaichunlin.transition.DefaultTransitionManager;
7 | import com.kaichunlin.transition.Transition;
8 | import com.kaichunlin.transition.TransitionManagerListener;
9 | import com.kaichunlin.transition.TransitionManager;
10 |
11 | import java.util.List;
12 |
13 | /**
14 | * Provides implementation shared by most adapters.
15 | */
16 | public abstract class AbstractAdapter implements TransitionAdapter {
17 | private TransitionManager mTransitionManager = new DefaultTransitionManager();
18 | private AdapterState mAdapterState;
19 |
20 | public AbstractAdapter() {
21 | mAdapterState = new AdapterState();
22 | }
23 |
24 | public AbstractAdapter(@NonNull AdapterState adapterState) {
25 | mAdapterState = adapterState;
26 | }
27 |
28 | public void setTransitionManager(TransitionManager manager) {
29 | mTransitionManager = manager;
30 | }
31 |
32 | public TransitionManager getTransitionManager() {
33 | return mTransitionManager;
34 | }
35 |
36 | @Override
37 | public AdapterState getAdapterState() {
38 | return mAdapterState;
39 | }
40 |
41 | @Override
42 | public void addTransition(@NonNull AbstractTransitionBuilder builder) {
43 | mTransitionManager.addTransition(builder);
44 | }
45 |
46 | @Override
47 | public void addTransition(@NonNull Transition transition) {
48 | mTransitionManager.addTransition(transition);
49 | }
50 |
51 | @Override
52 | public void addAllTransitions(@NonNull List transitionsList) {
53 | mTransitionManager.addAllTransitions(transitionsList);
54 | }
55 |
56 | @Override
57 | public boolean removeTransition(@NonNull Transition transition) {
58 | return mTransitionManager.removeTransition(transition);
59 | }
60 |
61 | @Override
62 | public void removeAllTransitions() {
63 | stopTransition();
64 | mTransitionManager.removeAllTransitions();
65 | }
66 |
67 | @Override
68 | public List getTransitions() {
69 | return mTransitionManager.getTransitions();
70 | }
71 |
72 | @Override
73 | public boolean startTransition() {
74 | return startTransition(getAdapterState().isOpen()?1:0);
75 | }
76 |
77 | @Override
78 | public boolean startTransition(float progress) {
79 | if (mAdapterState.isTransiting()) {
80 | return false;
81 | }
82 |
83 | mTransitionManager.startTransition(progress);
84 | mAdapterState.setTransiting(true);
85 | return true;
86 | }
87 |
88 | @Override
89 | public void updateProgress(float value) {
90 | mTransitionManager.updateProgress(value);
91 | }
92 |
93 | @Override
94 | public void stopTransition() {
95 | if (!mAdapterState.isTransiting()) {
96 | return;
97 | }
98 |
99 | mTransitionManager.stopTransition();
100 | mAdapterState.setTransiting(false);
101 | }
102 |
103 | @Override
104 | public void addTransitionListener(TransitionManagerListener listener) {
105 | mTransitionManager.addTransitionListener(listener);
106 | }
107 |
108 | @Override
109 | public void removeTransitionListener(TransitionManagerListener listener) {
110 | mTransitionManager.removeTransitionListener(listener);
111 | }
112 |
113 | @Override
114 | public void notifyTransitionStart() {
115 | mTransitionManager.notifyTransitionStart();
116 | }
117 |
118 | @Override
119 | public void notifyTransitionEnd() {
120 | mTransitionManager.notifyTransitionEnd();
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/core/src/main/java/com/kaichunlin/transition/adapter/DrawerListenerAdapter.java:
--------------------------------------------------------------------------------
1 | package com.kaichunlin.transition.adapter;
2 |
3 | import android.app.Activity;
4 | import android.support.annotation.IdRes;
5 | import android.support.annotation.NonNull;
6 | import android.support.annotation.Nullable;
7 | import android.support.v4.widget.DrawerLayout;
8 | import android.support.v7.app.ActionBarDrawerToggle;
9 | import android.view.View;
10 |
11 | /**
12 | * Adapter for DrawerListener, the transition range goes from 0.0f to 1.0f, where 0.0f is the closed state and 1.0f is the opened state.
13 | */
14 | public class DrawerListenerAdapter extends MenuBaseAdapter implements DrawerLayout.DrawerListener {
15 | private final ActionBarDrawerToggle mDrawerToggle;
16 | private DrawerLayout.DrawerListener mDrawerListener;
17 | private int mDrawerId;
18 | private DrawerLayout mDrawerLayout;
19 |
20 | public DrawerListenerAdapter(@NonNull ActionBarDrawerToggle mDrawerToggle) {
21 | this(mDrawerToggle, 0);
22 | }
23 |
24 | public DrawerListenerAdapter(@NonNull ActionBarDrawerToggle mDrawerToggle, @IdRes int mDrawerId) {
25 | this.mDrawerToggle = mDrawerToggle;
26 | this.mDrawerId = mDrawerId;
27 | }
28 |
29 | /**
30 | * @param activity
31 | * @return is the drawer in the opened state
32 | */
33 | public boolean isOpened(@NonNull Activity activity) {
34 | return mDrawerLayout.isDrawerOpen(activity.findViewById(mDrawerId));
35 | }
36 |
37 | @Override
38 | public void onDrawerOpened(@NonNull View view) {
39 | mDrawerToggle.onDrawerOpened(view);
40 | getAdapterState().setState(AdapterState.OPEN);
41 | stopTransition();
42 |
43 | if (mDrawerListener != null) {
44 | mDrawerListener.onDrawerOpened(view);
45 | }
46 | }
47 |
48 | @Override
49 | public void onDrawerClosed(@NonNull View view) {
50 | mDrawerToggle.onDrawerClosed(view);
51 | getAdapterState().setState(AdapterState.CLOSE);
52 | stopTransition();
53 |
54 | if (mDrawerListener != null) {
55 | mDrawerListener.onDrawerClosed(view);
56 | }
57 | }
58 |
59 | @Override
60 | public void onDrawerStateChanged(int state) {
61 | mDrawerToggle.onDrawerStateChanged(state);
62 | switch (state) {
63 | case DrawerLayout.STATE_DRAGGING:
64 | case DrawerLayout.STATE_SETTLING:
65 | startTransition();
66 | break;
67 | case DrawerLayout.STATE_IDLE:
68 | stopTransition();
69 | break;
70 | }
71 |
72 | if (mDrawerListener != null) {
73 | mDrawerListener.onDrawerStateChanged(state);
74 | }
75 | }
76 |
77 | @Override
78 | public void onDrawerSlide(View view, float slideOffset) {
79 | getTransitionManager().updateProgress(slideOffset);
80 |
81 | if (view == null) {
82 | return;
83 | }
84 | mDrawerToggle.onDrawerSlide(view, slideOffset);
85 |
86 | if (mDrawerListener != null) {
87 | mDrawerListener.onDrawerSlide(view, slideOffset);
88 | }
89 | }
90 |
91 | /**
92 | * @param mDrawerListener
93 | */
94 | public void setDrawerListener(@Nullable DrawerLayout.DrawerListener mDrawerListener) {
95 | this.mDrawerListener = mDrawerListener;
96 | }
97 |
98 | /**
99 | * @param drawerLayout
100 | */
101 | public void setDrawerLayout(@NonNull DrawerLayout drawerLayout) {
102 | this.mDrawerLayout = drawerLayout;
103 | drawerLayout.setDrawerListener(this);
104 | }
105 |
106 | /**
107 | * @param drawerId Drawer view ID
108 | */
109 | public void setDrawerId(@IdRes int drawerId) {
110 | mDrawerId = drawerId;
111 | }
112 |
113 | @Override
114 | protected MenuOptionHandler createMenuHandler() {
115 | return new DefaultMenuOptionHandler(this, getAdapterState());
116 | }
117 | }
118 |
--------------------------------------------------------------------------------
/core/src/main/java/com/kaichunlin/transition/ViewTransition.java:
--------------------------------------------------------------------------------
1 | package com.kaichunlin.transition;
2 |
3 | import android.support.annotation.CheckResult;
4 | import android.support.annotation.Nullable;
5 | import android.support.annotation.UiThread;
6 |
7 | import com.kaichunlin.transition.internal.TransitionController;
8 | import com.kaichunlin.transition.internal.TransitionControllerManager;
9 | import com.kaichunlin.transition.util.TransitionStateLogger;
10 |
11 | /**
12 | * Provides transitions effects to all views other than one controlled by {@link android.view.MenuItem}.
13 | */
14 | @UiThread
15 | public class ViewTransition extends AbstractTransition {
16 | private TransitionControllerManager transitionControllerManager;
17 |
18 | public ViewTransition() {
19 | this(null, null);
20 | }
21 |
22 | public ViewTransition(@Nullable Setup setup) {
23 | this(null, setup);
24 | }
25 |
26 | /**
27 | * @param id Unique ID that can identify the transition.
28 | * @param setup Creates the {@link TransitionController}'s when {@link #startTransition()} is called.
29 | */
30 | public ViewTransition(@Nullable String id, @Nullable Setup setup) {
31 | super(id);
32 | setSetup(setup);
33 | }
34 |
35 | @Override
36 | public ViewTransition reverse() {
37 | super.reverse();
38 | if (transitionControllerManager != null) {
39 | transitionControllerManager.reverse();
40 | }
41 | return self();
42 | }
43 |
44 | @Override
45 | public boolean startTransition() {
46 | //caches result
47 | if (transitionControllerManager == null) {
48 | transitionControllerManager = new TransitionControllerManager(getId());
49 | if (mInterpolator != null) {
50 | transitionControllerManager.setInterpolator(mInterpolator);
51 | }
52 | if (TransitionConfig.isDebug()) {
53 | mTarget.setTag(R.id.debug_id, new TransitionStateLogger(getId()));
54 | }
55 | transitionControllerManager.setTarget(mTarget);
56 | transitionControllerManager.setUpdateStateAfterUpdateProgress(mUpdateStateAfterUpdateProgress);
57 |
58 | final int size = mSetupList.size();
59 | for (int i = 0; i < size; i++) {
60 | mSetupList.get(i).setupAnimation(transitionControllerManager);
61 | }
62 | if (mReverse) {
63 | transitionControllerManager.reverse();
64 | }
65 | }
66 | transitionControllerManager.start();
67 | return true;
68 | }
69 |
70 | @Override
71 | public void updateProgress(float progress) {
72 | transitionControllerManager.updateProgress(progress);
73 | }
74 |
75 | @Override
76 | public void stopTransition() {
77 | if (transitionControllerManager != null) {
78 | transitionControllerManager.end();
79 | }
80 | }
81 |
82 | @CheckResult
83 | @Override
84 | public ViewTransition clone() {
85 | ViewTransition newCopy = (ViewTransition) super.clone();
86 | //set to null for now, equivalent to calling invalidate()
87 | newCopy.transitionControllerManager = null;
88 | return newCopy;
89 | }
90 |
91 | @Override
92 | protected void invalidate() {
93 | stopTransition();
94 | transitionControllerManager = null;
95 | }
96 |
97 | @Override
98 | protected ViewTransition self() {
99 | return this;
100 | }
101 |
102 | /**
103 | * Creates the {@link TransitionController}'s when {@link #startTransition()} is called.
104 | */
105 | public interface Setup extends AbstractTransition.Setup {
106 | /**
107 | * @param manager The {@link TransitionControllerManager} that the created {@link TransitionController} should be added to
108 | */
109 | void setupAnimation(TransitionControllerManager manager);
110 | }
111 | }
112 |
--------------------------------------------------------------------------------
/core/src/main/java/com/kaichunlin/transition/util/TransitionUtil.java:
--------------------------------------------------------------------------------
1 | package com.kaichunlin.transition.util;
2 |
3 | import android.app.Activity;
4 | import android.os.Build;
5 | import android.support.annotation.IdRes;
6 | import android.support.annotation.NonNull;
7 | import android.support.v7.view.menu.ActionMenuItemView;
8 | import android.support.v7.widget.ActionMenuView;
9 | import android.support.v7.widget.Toolbar;
10 | import android.view.MenuItem;
11 | import android.view.View;
12 | import android.view.ViewTreeObserver;
13 |
14 | import java.util.ArrayList;
15 | import java.util.List;
16 |
17 | /**
18 | * Support utility methods.
19 | */
20 | public class TransitionUtil {
21 |
22 | /**
23 | * Get the list of visible MenuItems
24 | *
25 | * @param toolbar
26 | * @return the list of visible MenuItems
27 | */
28 | public static List