public class

Transition

extends java.lang.Object

 java.lang.Object

↳androidx.constraintlayout.core.dsl.Transition

Gradle dependencies

compile group: 'androidx.constraintlayout', name: 'constraintlayout-core', version: '1.1.0-beta01'

  • groupId: androidx.constraintlayout
  • artifactId: constraintlayout-core
  • version: 1.1.0-beta01

Artifact androidx.constraintlayout:constraintlayout-core:1.1.0-beta01 it located at Google repository (https://maven.google.com/)

Overview

Create a Transition Object. Transition objects reference the start and end Constraints

Summary

Constructors
publicTransition(java.lang.String from, java.lang.String to)

publicTransition(java.lang.String id, java.lang.String from, java.lang.String to)

Methods
public java.lang.StringgetId()

public voidsetDuration(int duration)

public voidsetFrom(java.lang.String constraintSetStart)

public voidsetId(java.lang.String id)

public voidsetKeyFrames(Keys keyFrames)

public voidsetOnSwipe(OnSwipe onSwipe)

public voidsetStagger(float stagger)

public voidsetTo(java.lang.String constraintSetEnd)

public java.lang.StringtoString()

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

Constructors

public Transition(java.lang.String from, java.lang.String to)

public Transition(java.lang.String id, java.lang.String from, java.lang.String to)

Methods

public void setOnSwipe(OnSwipe onSwipe)

public void setKeyFrames(Keys keyFrames)

public void setId(java.lang.String id)

public void setTo(java.lang.String constraintSetEnd)

public void setFrom(java.lang.String constraintSetStart)

public void setDuration(int duration)

public void setStagger(float stagger)

public java.lang.String toString()

public java.lang.String getId()

Source

/*
 * Copyright (C) 2022 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.constraintlayout.core.dsl;

/**
 * Create a Transition Object.
 * Transition objects reference the start and end Constraints
 */
public class Transition {
    private OnSwipe mOnSwipe = null;
    final int UNSET = -1;
    private final int DEFAULT_DURATION = 400;
    private final float DEFAULT_STAGGER = 0;
    private String mId = null;
    private String mConstraintSetEnd = null;
    private String mConstraintSetStart = null;
    @SuppressWarnings("unused") private int mDefaultInterpolator = 0;
    @SuppressWarnings("unused") private String mDefaultInterpolatorString = null;
    @SuppressWarnings("unused") private int mDefaultInterpolatorID = -1;
    private int mDuration = DEFAULT_DURATION;
    private float mStagger = DEFAULT_STAGGER;

    private KeyFrames mKeyFrames = new KeyFrames();

    public void setOnSwipe(OnSwipe onSwipe) {
        mOnSwipe = onSwipe;
    }

    public void setKeyFrames(@SuppressWarnings("HiddenTypeParameter") Keys keyFrames) {
        mKeyFrames.add(keyFrames);
    }

    public Transition(String from, String to) {
        mId = "default";
        mConstraintSetStart = from;
        mConstraintSetEnd = to;
    }

    public Transition(String id, String from, String to) {
        mId = id;
        mConstraintSetStart = from;
        mConstraintSetEnd = to;
    }

    String toJson() {
        return toString();
    }

    public void setId(String id) {
        mId = id;
    }

    public void setTo(String constraintSetEnd) {
        mConstraintSetEnd = constraintSetEnd;
    }

    public void setFrom(String constraintSetStart) {
        mConstraintSetStart = constraintSetStart;
    }

    public void setDuration(int duration) {
        mDuration = duration;
    }

    public void setStagger(float stagger) {
        mStagger = stagger;
    }

    @Override
    public String toString() {
        String ret = mId + ":{\n"
                + "from:'" + mConstraintSetStart + "',\n"
                + "to:'" + mConstraintSetEnd + "',\n";
        if (mDuration != DEFAULT_DURATION) {
            ret += "duration:" + mDuration + ",\n";
        }
        if (mStagger != DEFAULT_STAGGER) {
            ret += "stagger:" + mStagger + ",\n";
        }
        if (mOnSwipe != null) {
            ret += mOnSwipe.toString();
        }

        ret += mKeyFrames.toString();


        ret += "},\n";

        return ret;
    }

    public String getId() {
        return mId;
    }
}