FileDocCategorySizeDatePackage
LoginActivityFromResources.javaAPI DocAndroid 5.1 API3639Thu Mar 12 22:22:44 GMT 2015com.android.transitiontests

LoginActivityFromResources

public class LoginActivityFromResources extends android.app.Activity

Fields Summary
android.view.ViewGroup
mSceneRoot
android.transition.Scene
mCurrentScene
android.transition.TransitionManager
mTransitionManager
android.transition.Scene
mLoginScene
android.transition.Scene
mPasswordScene
android.transition.Scene
mIncorrectPasswordScene
android.transition.Scene
mSuccessScene
android.transition.Scene
mUsernameTakenScene
android.transition.Scene
mNewUserScene
Constructors Summary
Methods Summary
public voidapplyScene(android.transition.Scene scene)

        mTransitionManager.transitionTo(scene);
        mCurrentScene = scene;
    
public voidonCreate(android.os.Bundle savedInstanceState)


    
        
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);
        View container = findViewById(R.id.container);
        mSceneRoot = (ViewGroup) container.getParent();

    
public voidsendMessage(android.view.View view)

        if (mTransitionManager == null) {
            TransitionInflater inflater = TransitionInflater.from(this);

            mLoginScene = Scene.getSceneForLayout(mSceneRoot, R.layout.activity_login, this);
            mPasswordScene = Scene.getSceneForLayout(mSceneRoot, R.layout.login_password, this);
            mIncorrectPasswordScene = Scene.getSceneForLayout(mSceneRoot, R.layout
                    .incorrect_password, this);
            mUsernameTakenScene = Scene.getSceneForLayout(mSceneRoot, R.layout.username_taken, this);
            mSuccessScene = Scene.getSceneForLayout(mSceneRoot, R.layout.success, this);
            mNewUserScene = Scene.getSceneForLayout(mSceneRoot, R.layout.new_user, this);

            mTransitionManager =
                    inflater.inflateTransitionManager(R.transition.login_transition_mgr,
                            mSceneRoot);

            mCurrentScene = mLoginScene;
        }
        TextView textView = (TextView) view;
        CharSequence text = textView.getText();
        if (text.equals("Cancel")) {
            applyScene(mLoginScene);
        } else if (text.equals("Submit")) {
            if (mCurrentScene == mLoginScene) {
                applyScene(mPasswordScene);
            } else if (mCurrentScene == mPasswordScene) {
                applyScene(Math.random() < .5 ? mSuccessScene : mIncorrectPasswordScene);
            } else if (mCurrentScene == mNewUserScene) {
                applyScene(Math.random() < .5 ? mSuccessScene : mUsernameTakenScene);
            }
        } else if (text.equals("New User?")) {
            applyScene(mNewUserScene);
        } else if (text.equals("Okay")) {
            if (mCurrentScene == mIncorrectPasswordScene) {
                applyScene(mPasswordScene);
            } else { // username taken scene
                applyScene(mNewUserScene);
            }
        } else if (text.equals("Reset")) {
            applyScene(mLoginScene);
        }