blob: 6b3442032fe20e082dbe904c28ca25244dd3b9f8 [file] [log] [blame]
Chet Haasefaebd8f2012-05-18 14:17:57 -07001/*
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 */
16package com.android.transitiontests;
17
18import android.app.Activity;
19import android.os.Bundle;
20import android.view.View;
21import android.view.ViewGroup;
22import android.view.transition.Scene;
23import android.view.transition.Transition;
24import android.widget.Button;
25import android.view.transition.Fade;
26import android.view.transition.Move;
27import android.view.transition.TransitionGroup;
28import android.view.transition.TransitionManager;
Chet Haasefaebd8f2012-05-18 14:17:57 -070029
30
31public class SequenceTest extends Activity {
32
33 Button mRemovingButton, mInvisibleButton, mGoneButton;
34 Scene mScene1, mScene2;
35 ViewGroup mSceneRoot;
36 TransitionGroup sequencedFade, reverseSequencedFade;
37
38 @Override
39 public void onCreate(Bundle savedInstanceState) {
40 super.onCreate(savedInstanceState);
41 setContentView(R.layout.fading_test);
42
43 View container = (View) findViewById(R.id.container);
44 mSceneRoot = (ViewGroup) container.getParent();
45
46 mRemovingButton = (Button) findViewById(R.id.removingButton);
47 mInvisibleButton = (Button) findViewById(R.id.invisibleButton);
48 mGoneButton = (Button) findViewById(R.id.goneButton);
49
50 mScene1 = new Scene(mSceneRoot, R.layout.fading_test, this);
51 mScene2 = new Scene(mSceneRoot, R.layout.fading_test_scene_2, this);
52
53 Transition fade1 = new Fade().setTargetIds(R.id.removingButton);
54 Transition fade2 = new Fade().setTargetIds(R.id.invisibleButton);
55 Transition fade3 = new Fade().setTargetIds(R.id.goneButton);
56 TransitionGroup fader = new TransitionGroup(TransitionGroup.SEQUENTIALLY);
57 fader.addTransitions(fade1, fade2, fade3, new Move());
58 sequencedFade = fader;
59
60 reverseSequencedFade = new TransitionGroup(TransitionGroup.SEQUENTIALLY);
61 reverseSequencedFade.addTransitions(new Move(), fade3, fade2, fade1);
62
63 mSceneRoot.setCurrentScene(mScene1);
64 }
65
66 public void sendMessage(View view) {
67 if (mSceneRoot.getCurrentScene() == mScene1) {
68 TransitionManager.go(mScene2, sequencedFade);
69 } else {
70 TransitionManager.go(mScene1, reverseSequencedFade);
71 }
72 }
73}