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.view.View; 21 import android.view.ViewGroup; 22 import android.transition.Scene; 23 import android.transition.Transition; 24 import android.transition.TransitionSet; 25 import android.widget.Button; 26 import android.transition.Fade; 27 import android.transition.ChangeBounds; 28 import android.transition.TransitionManager; 29 30 31 public class SequenceTest extends Activity { 32 33 Button mRemovingButton, mInvisibleButton, mGoneButton; 34 Scene mScene1, mScene2; 35 ViewGroup mSceneRoot; 36 TransitionSet sequencedFade, reverseSequencedFade; 37 Scene mCurrentScene; 38 39 @Override 40 public void onCreate(Bundle savedInstanceState) { 41 super.onCreate(savedInstanceState); 42 setContentView(R.layout.fading_test); 43 44 View container = (View) findViewById(R.id.container); 45 mSceneRoot = (ViewGroup) container.getParent(); 46 47 mRemovingButton = (Button) findViewById(R.id.removingButton); 48 mInvisibleButton = (Button) findViewById(R.id.invisibleButton); 49 mGoneButton = (Button) findViewById(R.id.goneButton); 50 51 mScene1 = Scene.getSceneForLayout(mSceneRoot, R.layout.fading_test, this); 52 mScene2 = Scene.getSceneForLayout(mSceneRoot, R.layout.fading_test_scene_2, this); 53 54 Transition fade1 = new Fade().addTarget(R.id.removingButton); 55 Transition fade2 = new Fade().addTarget(R.id.invisibleButton); 56 Transition fade3 = new Fade().addTarget(R.id.goneButton); 57 TransitionSet fader = new TransitionSet(). 58 setOrdering(TransitionSet.ORDERING_SEQUENTIAL); 59 fader.addTransition(fade1).addTransition(fade2).addTransition(fade3). 60 addTransition(new ChangeBounds()); 61 sequencedFade = fader; 62 63 reverseSequencedFade = new TransitionSet(). 64 setOrdering(TransitionSet.ORDERING_SEQUENTIAL); 65 reverseSequencedFade.addTransition(new ChangeBounds()).addTransition(fade3).addTransition(fade2). 66 addTransition(fade1); 67 68 mCurrentScene = mScene1; 69 } 70 71 public void sendMessage(View view) { 72 if (mCurrentScene == mScene1) { 73 TransitionManager.go(mScene2, sequencedFade); 74 mCurrentScene = mScene2; 75 } else { 76 TransitionManager.go(mScene1, reverseSequencedFade); 77 mCurrentScene = mScene1; 78 } 79 } 80 } 81