1 /* 2 * Copyright (C) 2013 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package com.android.transitiontests; 17 18 import android.app.Activity; 19 import android.os.Bundle; 20 import android.transition.ChangeBounds; 21 import android.view.View; 22 import android.view.ViewGroup; 23 import android.transition.Scene; 24 import android.transition.TransitionSet; 25 import android.widget.Button; 26 import android.transition.Fade; 27 import android.transition.Transition; 28 import android.transition.TransitionManager; 29 30 31 public class SequenceTestSimple extends Activity { 32 33 Button mRemovingButton, mInvisibleButton, mGoneButton; 34 Scene mScene1, mScene2; 35 ViewGroup mSceneRoot; 36 Transition sequencedFade; 37 TransitionSet sequencedFadeReverse; 38 Scene mCurrentScene; 39 40 @Override onCreate(Bundle savedInstanceState)41 public void onCreate(Bundle savedInstanceState) { 42 super.onCreate(savedInstanceState); 43 setContentView(R.layout.fading_test_simple); 44 45 View container = findViewById(R.id.container); 46 mSceneRoot = (ViewGroup) container.getParent(); 47 48 mRemovingButton = findViewById(R.id.removingButton); 49 50 mScene1 = Scene.getSceneForLayout(mSceneRoot, R.layout.fading_test_simple, this); 51 mScene2 = Scene.getSceneForLayout(mSceneRoot, R.layout.fading_test_simple2, this); 52 53 TransitionSet fader = new TransitionSet(). 54 setOrdering(TransitionSet.ORDERING_SEQUENTIAL); 55 fader.addTransition(new Fade().addTarget(R.id.removingButton)); 56 fader.addTransition(new ChangeBounds().addTarget(R.id.sceneSwitchButton)); 57 sequencedFade = fader; 58 59 sequencedFadeReverse = new TransitionSet(). 60 setOrdering(TransitionSet.ORDERING_SEQUENTIAL); 61 sequencedFadeReverse.addTransition(new ChangeBounds().addTarget(R.id.sceneSwitchButton)); 62 sequencedFadeReverse.addTransition(new Fade().addTarget(R.id.removingButton)); 63 64 mCurrentScene = mScene1; 65 } 66 sendMessage(View view)67 public void sendMessage(View view) { 68 if (mCurrentScene == mScene1) { 69 TransitionManager.go(mScene2, sequencedFade); 70 mCurrentScene = mScene2; 71 } else { 72 TransitionManager.go(mScene1, sequencedFadeReverse); 73 mCurrentScene = mScene1; 74 } 75 }} 76