public final class

TransitionHelper

extends java.lang.Object

 java.lang.Object

↳androidx.leanback.transition.TransitionHelper

Gradle dependencies

compile group: 'androidx.leanback', name: 'leanback', version: '1.2.0-alpha04'

  • groupId: androidx.leanback
  • artifactId: leanback
  • version: 1.2.0-alpha04

Artifact androidx.leanback:leanback:1.2.0-alpha04 it located at Google repository (https://maven.google.com/)

Androidx artifact mapping:

androidx.leanback:leanback com.android.support:leanback-v17

Androidx class mapping:

androidx.leanback.transition.TransitionHelper android.support.v17.leanback.transition.TransitionHelper

Overview

Helper for view transitions.

Summary

Fields
public static final intFADE_IN

public static final intFADE_OUT

Methods
public static voidaddSharedElement(FragmentTransaction ft, View view, java.lang.String transitionName)

public static voidaddTarget(java.lang.Object transition, View view)

public static voidaddTransition(java.lang.Object transitionSet, java.lang.Object transition)

public static voidaddTransitionListener(java.lang.Object transition, TransitionListener listener)

public static voidbeginDelayedTransition(ViewGroup sceneRoot, java.lang.Object transitionObject)

public static java.lang.ObjectcreateAutoTransition()

public static java.lang.ObjectcreateChangeBounds(boolean reparent)

public static java.lang.ObjectcreateChangeTransform()

public static java.lang.ObjectcreateDefaultInterpolator(Context context)

public static java.lang.ObjectcreateFadeAndShortSlide(int edge)

public static java.lang.ObjectcreateFadeAndShortSlide(int edge, float distance)

public static java.lang.ObjectcreateFadeTransition(int fadeMode)

public static java.lang.ObjectcreateScale()

public static java.lang.ObjectcreateScene(ViewGroup sceneRoot, java.lang.Runnable r)

public static java.lang.ObjectcreateSlide(int slideEdge)

public static java.lang.ObjectcreateTransitionSet(boolean sequential)

public static voidexclude(java.lang.Object transition, int targetId, boolean exclude)

public static voidexclude(java.lang.Object transition, View targetView, boolean exclude)

public static voidexcludeChildren(java.lang.Object transition, int targetId, boolean exclude)

public static voidexcludeChildren(java.lang.Object transition, View targetView, boolean exclude)

public static java.lang.ObjectgetEnterTransition(Window window)

public static java.lang.ObjectgetExitTransition(Window window)

public static java.lang.ObjectgetReenterTransition(Window window)

public static java.lang.ObjectgetReturnTransition(Window window)

public static java.lang.ObjectgetSharedElementEnterTransition(Window window)

public static java.lang.ObjectgetSharedElementExitTransition(Window window)

public static java.lang.ObjectgetSharedElementReenterTransition(Window window)

public static java.lang.ObjectgetSharedElementReturnTransition(Window window)

public static voidinclude(java.lang.Object transition, int targetId)

public static voidinclude(java.lang.Object transition, View targetView)

public static java.lang.ObjectloadTransition(Context context, int resId)

public static voidremoveTransitionListener(java.lang.Object transition, TransitionListener listener)

public static voidrunTransition(java.lang.Object scene, java.lang.Object transition)

public static voidsetChangeBoundsDefaultStartDelay(java.lang.Object changeBounds, int startDelay)

public static voidsetChangeBoundsStartDelay(java.lang.Object changeBounds, View view, int startDelay)

public static voidsetDuration(java.lang.Object transition, long duration)

public static voidsetEnterTransition(Fragment fragment, java.lang.Object transition)

public static voidsetEnterTransition(Window window, java.lang.Object transition)

public static voidsetEpicenterCallback(java.lang.Object transition, TransitionEpicenterCallback callback)

public static voidsetExitTransition(Fragment fragment, java.lang.Object transition)

public static voidsetInterpolator(java.lang.Object transition, java.lang.Object timeInterpolator)

public static voidsetReturnTransition(Window window, java.lang.Object transition)

public static voidsetSharedElementEnterTransition(Fragment fragment, java.lang.Object transition)

public static voidsetSharedElementEnterTransition(Window window, java.lang.Object transition)

public static voidsetSharedElementReturnTransition(Window window, java.lang.Object transition)

public static voidsetStartDelay(java.lang.Object transition, long startDelay)

public static voidsetTransitionGroup(ViewGroup viewGroup, boolean transitionGroup)

public static booleansystemSupportsEntranceTransitions()

Returns true if system supports entrance Transition animations.

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Fields

public static final int FADE_IN

public static final int FADE_OUT

Methods

public static boolean systemSupportsEntranceTransitions()

Returns true if system supports entrance Transition animations.

public static java.lang.Object getSharedElementEnterTransition(Window window)

public static void setSharedElementEnterTransition(Window window, java.lang.Object transition)

public static java.lang.Object getSharedElementReturnTransition(Window window)

public static void setSharedElementReturnTransition(Window window, java.lang.Object transition)

public static java.lang.Object getSharedElementExitTransition(Window window)

public static java.lang.Object getSharedElementReenterTransition(Window window)

public static java.lang.Object getEnterTransition(Window window)

public static void setEnterTransition(Window window, java.lang.Object transition)

public static java.lang.Object getReturnTransition(Window window)

public static void setReturnTransition(Window window, java.lang.Object transition)

public static java.lang.Object getExitTransition(Window window)

public static java.lang.Object getReenterTransition(Window window)

public static java.lang.Object createScene(ViewGroup sceneRoot, java.lang.Runnable r)

public static java.lang.Object createChangeBounds(boolean reparent)

public static java.lang.Object createChangeTransform()

public static void setChangeBoundsStartDelay(java.lang.Object changeBounds, View view, int startDelay)

public static void setChangeBoundsDefaultStartDelay(java.lang.Object changeBounds, int startDelay)

public static java.lang.Object createTransitionSet(boolean sequential)

public static java.lang.Object createSlide(int slideEdge)

public static java.lang.Object createScale()

public static void addTransition(java.lang.Object transitionSet, java.lang.Object transition)

public static void exclude(java.lang.Object transition, int targetId, boolean exclude)

public static void exclude(java.lang.Object transition, View targetView, boolean exclude)

public static void excludeChildren(java.lang.Object transition, int targetId, boolean exclude)

public static void excludeChildren(java.lang.Object transition, View targetView, boolean exclude)

public static void include(java.lang.Object transition, int targetId)

public static void include(java.lang.Object transition, View targetView)

public static void setStartDelay(java.lang.Object transition, long startDelay)

public static void setDuration(java.lang.Object transition, long duration)

public static java.lang.Object createAutoTransition()

public static java.lang.Object createFadeTransition(int fadeMode)

public static void addTransitionListener(java.lang.Object transition, TransitionListener listener)

public static void removeTransitionListener(java.lang.Object transition, TransitionListener listener)

public static void runTransition(java.lang.Object scene, java.lang.Object transition)

public static void setInterpolator(java.lang.Object transition, java.lang.Object timeInterpolator)

public static void addTarget(java.lang.Object transition, View view)

public static java.lang.Object createDefaultInterpolator(Context context)

public static java.lang.Object loadTransition(Context context, int resId)

public static void setEnterTransition(Fragment fragment, java.lang.Object transition)

public static void setExitTransition(Fragment fragment, java.lang.Object transition)

public static void setSharedElementEnterTransition(Fragment fragment, java.lang.Object transition)

public static void addSharedElement(FragmentTransaction ft, View view, java.lang.String transitionName)

public static java.lang.Object createFadeAndShortSlide(int edge)

public static java.lang.Object createFadeAndShortSlide(int edge, float distance)

public static void beginDelayedTransition(ViewGroup sceneRoot, java.lang.Object transitionObject)

public static void setTransitionGroup(ViewGroup viewGroup, boolean transitionGroup)

public static void setEpicenterCallback(java.lang.Object transition, TransitionEpicenterCallback callback)

Source

/*
 * Copyright (C) 2014 The Android Open Source Project
 *
 * 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 androidx.leanback.transition;

import static androidx.annotation.RestrictTo.Scope.LIBRARY;

import android.animation.TimeInterpolator;
import android.annotation.SuppressLint;
import android.app.Fragment;
import android.app.FragmentTransaction;
import android.content.Context;
import android.graphics.Rect;
import android.os.Build;
import android.transition.AutoTransition;
import android.transition.ChangeTransform;
import android.transition.Fade;
import android.transition.Scene;
import android.transition.Transition;
import android.transition.TransitionInflater;
import android.transition.TransitionManager;
import android.transition.TransitionSet;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.animation.AnimationUtils;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;

import java.util.ArrayList;

/**
 * Helper for view transitions.
 */
@RestrictTo(LIBRARY)
public final class TransitionHelper {

    public static final int FADE_IN = 0x1;
    public static final int FADE_OUT = 0x2;

    /**
     * Returns true if system supports entrance Transition animations.
     */
    @SuppressWarnings("BooleanMethodIsAlwaysInverted")
    public static boolean systemSupportsEntranceTransitions() {
        return Build.VERSION.SDK_INT >= 21;
    }

    private static class TransitionStub {
        ArrayList<TransitionListener> mTransitionListeners;

        TransitionStub() {
        }
    }

    @SuppressLint("ClassVerificationFailure")
    @Nullable
    public static Object getSharedElementEnterTransition(@NonNull Window window) {
        if (Build.VERSION.SDK_INT >= 21) {
            return window.getSharedElementEnterTransition();
        }
        return null;
    }

    @SuppressLint("ClassVerificationFailure")
    public static void setSharedElementEnterTransition(
            @NonNull Window window,
            @Nullable Object transition
    ) {
        if (Build.VERSION.SDK_INT >= 21) {
            window.setSharedElementEnterTransition((Transition) transition);
        }
    }

    @SuppressLint("ClassVerificationFailure")
    @Nullable
    public static Object getSharedElementReturnTransition(@NonNull Window window) {
        if (Build.VERSION.SDK_INT >= 21) {
            return window.getSharedElementReturnTransition();
        }
        return null;
    }

    @SuppressLint("ClassVerificationFailure")
    public static void setSharedElementReturnTransition(
            @NonNull Window window,
            @Nullable Object transition
    ) {
        if (Build.VERSION.SDK_INT >= 21) {
            window.setSharedElementReturnTransition((Transition) transition);
        }
    }

    @SuppressLint("ClassVerificationFailure")
    @Nullable
    public static Object getSharedElementExitTransition(@NonNull Window window) {
        if (Build.VERSION.SDK_INT >= 21) {
            return window.getSharedElementExitTransition();
        }
        return null;
    }

    @SuppressLint("ClassVerificationFailure")
    @Nullable
    public static Object getSharedElementReenterTransition(@NonNull Window window) {
        if (Build.VERSION.SDK_INT >= 21) {
            return window.getSharedElementReenterTransition();
        }
        return null;
    }

    @SuppressLint("ClassVerificationFailure")
    @Nullable
    public static Object getEnterTransition(@NonNull Window window) {
        if (Build.VERSION.SDK_INT >= 21) {
            return window.getEnterTransition();
        }
        return null;
    }

    @SuppressLint("ClassVerificationFailure")
    public static void setEnterTransition(@NonNull Window window, @Nullable Object transition) {
        if (Build.VERSION.SDK_INT >= 21) {
            window.setEnterTransition((Transition) transition);
        }
    }

    @SuppressLint("ClassVerificationFailure")
    @Nullable
    public static Object getReturnTransition(@NonNull Window window) {
        if (Build.VERSION.SDK_INT >= 21) {
            return window.getReturnTransition();
        }
        return null;
    }

    @SuppressLint("ClassVerificationFailure")
    public static void setReturnTransition(@NonNull Window window, @Nullable Object transition) {
        if (Build.VERSION.SDK_INT >= 21) {
            window.setReturnTransition((Transition) transition);
        }
    }

    @SuppressLint("ClassVerificationFailure")
    @Nullable
    public static Object getExitTransition(@NonNull Window window) {
        if (Build.VERSION.SDK_INT >= 21) {
            return window.getExitTransition();
        }
        return null;
    }

    @SuppressLint("ClassVerificationFailure")
    @Nullable
    public static Object getReenterTransition(@NonNull Window window) {
        if (Build.VERSION.SDK_INT >= 21) {
            return window.getReenterTransition();
        }
        return null;
    }

    @SuppressLint("ClassVerificationFailure")
    @Nullable
    public static Object createScene(@NonNull ViewGroup sceneRoot, @Nullable Runnable r) {
        if (Build.VERSION.SDK_INT >= 19) {
            Scene scene = new Scene(sceneRoot);
            scene.setEnterAction(r);
            return scene;
        }
        return r;
    }

    @SuppressLint("ClassVerificationFailure")
    @NonNull
    public static Object createChangeBounds(boolean reparent) {
        if (Build.VERSION.SDK_INT >= 19) {
            CustomChangeBounds changeBounds = new CustomChangeBounds();
            changeBounds.setReparent(reparent);
            return changeBounds;
        }
        return new TransitionStub();
    }

    @SuppressLint("ClassVerificationFailure")
    @NonNull
    public static Object createChangeTransform() {
        if (Build.VERSION.SDK_INT >= 21) {
            return new ChangeTransform();
        }
        return new TransitionStub();
    }

    @SuppressLint("ClassVerificationFailure")
    public static void setChangeBoundsStartDelay(
            @NonNull Object changeBounds,
            @NonNull View view,
            int startDelay
    ) {
        if (Build.VERSION.SDK_INT >= 19) {
            ((CustomChangeBounds) changeBounds).setStartDelay(view, startDelay);
        }
    }

    public static void setChangeBoundsStartDelay(
            @NonNull Object changeBounds,
            int viewId,
            int startDelay
    ) {
        if (Build.VERSION.SDK_INT >= 19) {
            ((CustomChangeBounds) changeBounds).setStartDelay(viewId, startDelay);
        }
    }

    public static void setChangeBoundsStartDelay(
            @NonNull Object changeBounds,
            @NonNull String className,
            int startDelay
    ) {
        if (Build.VERSION.SDK_INT >= 19) {
            ((CustomChangeBounds) changeBounds).setStartDelay(className, startDelay);
        }
    }

    public static void setChangeBoundsDefaultStartDelay(
            @NonNull Object changeBounds,
            int startDelay
    ) {
        if (Build.VERSION.SDK_INT >= 19) {
            ((CustomChangeBounds) changeBounds).setDefaultStartDelay(startDelay);
        }
    }

    @SuppressLint("ClassVerificationFailure")
    @NonNull
    public static Object createTransitionSet(boolean sequential) {
        if (Build.VERSION.SDK_INT >= 19) {
            TransitionSet set = new TransitionSet();
            set.setOrdering(sequential ? TransitionSet.ORDERING_SEQUENTIAL
                    : TransitionSet.ORDERING_TOGETHER);
            return set;
        }
        return new TransitionStub();
    }

    @NonNull
    public static Object createSlide(int slideEdge) {
        if (Build.VERSION.SDK_INT >= 19) {
            SlideKitkat slide = new SlideKitkat();
            slide.setSlideEdge(slideEdge);
            return slide;
        }
        return new TransitionStub();
    }

    @SuppressLint("ClassVerificationFailure")
    @NonNull
    public static Object createScale() {
        if (Build.VERSION.SDK_INT >= 21) {
            return new ChangeTransform();
        }
        if (Build.VERSION.SDK_INT >= 19) {
            return new Scale();
        }
        return new TransitionStub();
    }

    @SuppressLint("ClassVerificationFailure")
    public static void addTransition(@NonNull Object transitionSet, @NonNull Object transition) {
        if (Build.VERSION.SDK_INT >= 19) {
            ((TransitionSet) transitionSet).addTransition((Transition) transition);
        }
    }

    @SuppressLint("ClassVerificationFailure")
    public static void exclude(@NonNull Object transition, int targetId, boolean exclude) {
        if (Build.VERSION.SDK_INT >= 19) {
            ((Transition) transition).excludeTarget(targetId, exclude);
        }
    }

    @SuppressLint("ClassVerificationFailure")
    public static void exclude(
            @NonNull Object transition,
            @NonNull View targetView,
            boolean exclude
    ) {
        if (Build.VERSION.SDK_INT >= 19) {
            ((Transition) transition).excludeTarget(targetView, exclude);
        }
    }

    @SuppressLint("ClassVerificationFailure")
    public static void excludeChildren(@NonNull Object transition, int targetId, boolean exclude) {
        if (Build.VERSION.SDK_INT >= 19) {
            ((Transition) transition).excludeChildren(targetId, exclude);
        }
    }

    @SuppressLint("ClassVerificationFailure")
    public static void excludeChildren(
            @NonNull Object transition,
            @NonNull View targetView,
            boolean exclude
    ) {
        if (Build.VERSION.SDK_INT >= 19) {
            ((Transition) transition).excludeChildren(targetView, exclude);
        }
    }

    @SuppressLint("ClassVerificationFailure")
    public static void include(@NonNull Object transition, int targetId) {
        if (Build.VERSION.SDK_INT >= 19) {
            ((Transition) transition).addTarget(targetId);
        }
    }

    @SuppressLint("ClassVerificationFailure")
    public static void include(@NonNull Object transition, @NonNull View targetView) {
        if (Build.VERSION.SDK_INT >= 19) {
            ((Transition) transition).addTarget(targetView);
        }
    }

    @SuppressLint("ClassVerificationFailure")
    public static void setStartDelay(@NonNull Object transition, long startDelay) {
        if (Build.VERSION.SDK_INT >= 19) {
            ((Transition) transition).setStartDelay(startDelay);
        }
    }

    @SuppressLint("ClassVerificationFailure")
    public static void setDuration(@NonNull Object transition, long duration) {
        if (Build.VERSION.SDK_INT >= 19) {
            ((Transition) transition).setDuration(duration);
        }
    }

    @SuppressLint("ClassVerificationFailure")
    @NonNull
    public static Object createAutoTransition() {
        if (Build.VERSION.SDK_INT >= 19) {
            return new AutoTransition();
        }
        return new TransitionStub();
    }

    @SuppressLint("ClassVerificationFailure")
    @NonNull
    public static Object createFadeTransition(int fadeMode) {
        if (Build.VERSION.SDK_INT >= 19) {
            return new Fade(fadeMode);
        }
        return new TransitionStub();
    }

    @SuppressLint("ClassVerificationFailure")
    public static void addTransitionListener(
            @NonNull Object transition,
            final @Nullable TransitionListener listener
    ) {
        if (listener == null) {
            return;
        }
        if (Build.VERSION.SDK_INT >= 19) {
            Transition t = (Transition) transition;
            listener.mImpl = new Transition.TransitionListener() {
                @Override
                public void onTransitionStart(Transition transition11) {
                    listener.onTransitionStart(transition11);
                }

                @Override
                public void onTransitionResume(Transition transition11) {
                    listener.onTransitionResume(transition11);
                }

                @Override
                public void onTransitionPause(Transition transition11) {
                    listener.onTransitionPause(transition11);
                }

                @Override
                public void onTransitionEnd(Transition transition11) {
                    listener.onTransitionEnd(transition11);
                }

                @Override
                public void onTransitionCancel(Transition transition11) {
                    listener.onTransitionCancel(transition11);
                }
            };
            t.addListener((Transition.TransitionListener) listener.mImpl);
        } else {
            TransitionStub stub = (TransitionStub) transition;
            if (stub.mTransitionListeners == null) {
                stub.mTransitionListeners = new ArrayList<>();
            }
            stub.mTransitionListeners.add(listener);
        }
    }

    @SuppressLint("ClassVerificationFailure")
    public static void removeTransitionListener(
            @NonNull Object transition,
            @Nullable TransitionListener listener
    ) {
        if (Build.VERSION.SDK_INT >= 19) {
            if (listener == null || listener.mImpl == null) {
                return;
            }
            Transition t = (Transition) transition;
            t.removeListener((Transition.TransitionListener) listener.mImpl);
            listener.mImpl = null;
        } else {
            TransitionStub stub = (TransitionStub) transition;
            if (stub.mTransitionListeners != null) {
                stub.mTransitionListeners.remove(listener);
            }
        }
    }

    @SuppressLint("ClassVerificationFailure")
    public static void runTransition(@Nullable Object scene, @Nullable Object transition) {
        if (Build.VERSION.SDK_INT >= 19) {
            TransitionManager.go((Scene) scene, (Transition) transition);
        } else {
            TransitionStub transitionStub = (TransitionStub) transition;
            if (transitionStub != null && transitionStub.mTransitionListeners != null) {
                for (int i = 0, size = transitionStub.mTransitionListeners.size(); i < size; i++) {
                    transitionStub.mTransitionListeners.get(i).onTransitionStart(transition);
                }
            }
            Runnable r = ((Runnable) scene);
            if (r != null) {
                r.run();
            }
            if (transitionStub != null && transitionStub.mTransitionListeners != null) {
                for (int i = 0, size = transitionStub.mTransitionListeners.size(); i < size; i++) {
                    transitionStub.mTransitionListeners.get(i).onTransitionEnd(transition);
                }
            }
        }
    }

    @SuppressLint("ClassVerificationFailure")
    public static void setInterpolator(
            @NonNull Object transition,
            @Nullable Object timeInterpolator
    ) {
        if (Build.VERSION.SDK_INT >= 19) {
            ((Transition) transition).setInterpolator((TimeInterpolator) timeInterpolator);
        }
    }

    @SuppressLint("ClassVerificationFailure")
    public static void addTarget(@NonNull Object transition, @NonNull View view) {
        if (Build.VERSION.SDK_INT >= 19) {
            ((Transition) transition).addTarget(view);
        }
    }

    @SuppressLint("ClassVerificationFailure")
    @Nullable
    public static Object createDefaultInterpolator(@NonNull Context context) {
        if (Build.VERSION.SDK_INT >= 21) {
            return AnimationUtils.loadInterpolator(context,
                    android.R.interpolator.fast_out_linear_in);
        }
        return null;
    }

    @SuppressLint("ClassVerificationFailure")
    @NonNull
    public static Object loadTransition(@NonNull Context context, int resId) {
        if (Build.VERSION.SDK_INT >= 19) {
            return TransitionInflater.from(context).inflateTransition(resId);
        }
        return new TransitionStub();
    }

    @SuppressLint({"ReferencesDeprecated", "ClassVerificationFailure"})
    public static void setEnterTransition(
            @NonNull Fragment fragment,
            @Nullable Object transition
    ) {
        if (Build.VERSION.SDK_INT >= 21) {
            fragment.setEnterTransition((Transition) transition);
        }
    }

    @SuppressLint({"ReferencesDeprecated", "ClassVerificationFailure"})
    public static void setExitTransition(
            @NonNull Fragment fragment,
            @Nullable Object transition
    ) {
        if (Build.VERSION.SDK_INT >= 21) {
            fragment.setExitTransition((Transition) transition);
        }
    }

    @SuppressLint({"ReferencesDeprecated", "ClassVerificationFailure"})
    public static void setSharedElementEnterTransition(
            @NonNull Fragment fragment,
            @Nullable Object transition
    ) {
        if (Build.VERSION.SDK_INT >= 21) {
            fragment.setSharedElementEnterTransition((Transition) transition);
        }
    }

    @SuppressLint({"ReferencesDeprecated", "ClassVerificationFailure"})
    public static void addSharedElement(
            @NonNull FragmentTransaction ft,
            @NonNull View view,
            @NonNull String transitionName
    ) {
        if (Build.VERSION.SDK_INT >= 21) {
            ft.addSharedElement(view, transitionName);
        }
    }

    @SuppressLint("ClassVerificationFailure")
    @NonNull
    public static Object createFadeAndShortSlide(int edge) {
        if (Build.VERSION.SDK_INT >= 21) {
            return new FadeAndShortSlide(edge);
        }
        return new TransitionStub();
    }

    @SuppressLint("ClassVerificationFailure")
    @NonNull
    public static Object createFadeAndShortSlide(int edge, float distance) {
        if (Build.VERSION.SDK_INT >= 21) {
            FadeAndShortSlide slide = new FadeAndShortSlide(edge);
            slide.setDistance(distance);
            return slide;
        }
        return new TransitionStub();
    }

    @SuppressLint("ClassVerificationFailure")
    public static void beginDelayedTransition(
            @NonNull ViewGroup sceneRoot,
            @Nullable Object transitionObject
    ) {
        if (Build.VERSION.SDK_INT >= 21) {
            Transition transition = (Transition) transitionObject;
            TransitionManager.beginDelayedTransition(sceneRoot, transition);
        }
    }

    @SuppressLint("ClassVerificationFailure")
    public static void setTransitionGroup(@NonNull ViewGroup viewGroup, boolean transitionGroup) {
        if (Build.VERSION.SDK_INT >= 21) {
            viewGroup.setTransitionGroup(transitionGroup);
        }
    }

    @SuppressLint("ClassVerificationFailure")
    public static void setEpicenterCallback(
            @NonNull Object transition,
            @Nullable final TransitionEpicenterCallback callback
    ) {
        if (Build.VERSION.SDK_INT >= 21) {
            if (callback == null) {
                ((Transition) transition).setEpicenterCallback(null);
            } else {
                ((Transition) transition).setEpicenterCallback(new Transition.EpicenterCallback() {
                    @Override
                    public Rect onGetEpicenter(Transition transition11) {
                        return callback.onGetEpicenter(transition11);
                    }
                });
            }
        }
    }

    private TransitionHelper() {
    }
}