Java Code Examples for android.view.Window#hasFeature()

The following examples show how to use android.view.Window#hasFeature() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ActivityTransitionState.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
public void setEnterActivityOptions(Activity activity, ActivityOptions options) {
    final Window window = activity.getWindow();
    if (window == null) {
        return;
    }
    // ensure Decor View has been created so that the window features are activated
    window.getDecorView();
    if (window.hasFeature(Window.FEATURE_ACTIVITY_TRANSITIONS)
            && options != null && mEnterActivityOptions == null
            && mEnterTransitionCoordinator == null
            && options.getAnimationType() == ActivityOptions.ANIM_SCENE_TRANSITION) {
        mEnterActivityOptions = options;
        mIsEnterTriggered = false;
        if (mEnterActivityOptions.isReturning()) {
            restoreExitedViews();
            int result = mEnterActivityOptions.getResultCode();
            if (result != 0) {
                Intent intent = mEnterActivityOptions.getResultData();
                if (intent != null) {
                    intent.setExtrasClassLoader(activity.getClassLoader());
                }
                activity.onActivityReenter(result, intent);
            }
        }
    }
}
 
Example 2
Source File: ActivityOptions.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
static ExitTransitionCoordinator makeSceneTransitionAnimation(Activity activity, Window window,
        ActivityOptions opts, SharedElementCallback callback,
        Pair<View, String>[] sharedElements) {
    if (!window.hasFeature(Window.FEATURE_ACTIVITY_TRANSITIONS)) {
        opts.mAnimationType = ANIM_DEFAULT;
        return null;
    }
    opts.mAnimationType = ANIM_SCENE_TRANSITION;

    ArrayList<String> names = new ArrayList<String>();
    ArrayList<View> views = new ArrayList<View>();

    if (sharedElements != null) {
        for (int i = 0; i < sharedElements.length; i++) {
            Pair<View, String> sharedElement = sharedElements[i];
            String sharedElementName = sharedElement.second;
            if (sharedElementName == null) {
                throw new IllegalArgumentException("Shared element name must not be null");
            }
            names.add(sharedElementName);
            View view = sharedElement.first;
            if (view == null) {
                throw new IllegalArgumentException("Shared element must not be null");
            }
            views.add(sharedElement.first);
        }
    }

    ExitTransitionCoordinator exit = new ExitTransitionCoordinator(activity, window,
            callback, names, names, views, false);
    opts.mTransitionReceiver = exit;
    opts.mSharedElementNames = names;
    opts.mIsReturning = (activity == null);
    if (activity == null) {
        opts.mExitCoordinatorIndex = -1;
    } else {
        opts.mExitCoordinatorIndex =
                activity.mActivityTransitionState.addExitTransitionCoordinator(exit);
    }
    return exit;
}