blob: 400e994884054f549bc72e2652e576fb91376e52 [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.widget.Button;
24import android.view.transition.Fade;
25import android.view.transition.TransitionManager;
Chet Haasefaebd8f2012-05-18 14:17:57 -070026
27
28public class FadingTest extends Activity {
29
30 Button mRemovingButton, mInvisibleButton, mGoneButton;
31 Scene mScene1, mScene2;
32 ViewGroup mSceneRoot;
33 static Fade sFade = new Fade();
34
35 static {
36 sFade.setTargetIds(R.id.removingButton, R.id.invisibleButton, R.id.goneButton);
37 }
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
48 mRemovingButton = (Button) findViewById(R.id.removingButton);
49 mInvisibleButton = (Button) findViewById(R.id.invisibleButton);
50 mGoneButton = (Button) findViewById(R.id.goneButton);
51
52 mGoneButton.setOnClickListener(new View.OnClickListener() {
53 @Override
54 public void onClick(View v) {
55 mGoneButton.setAlpha(mGoneButton.getAlpha() < 1 ? 1 : .6f);
56 }
57 });
58
59 mScene1 = new Scene(mSceneRoot, R.layout.fading_test, this);
60 mScene2 = new Scene(mSceneRoot, R.layout.fading_test_scene_2, this);
61
62 mSceneRoot.setCurrentScene(mScene1);
63 }
64
65 public void sendMessage(View view) {
66 if (mSceneRoot.getCurrentScene() == mScene1) {
67 TransitionManager.go(mScene2);
68 } else {
69 TransitionManager.go(mScene1);
70 }
71 }
72
73}