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.widget.Button; 24 import android.transition.Fade; 25 import android.transition.TransitionManager; 26 27 28 public class FadingTest extends Activity { 29 30 Button mRemovingButton, mInvisibleButton, mGoneButton; 31 Scene mScene1, mScene2; 32 ViewGroup mSceneRoot; 33 static Fade sFade = new Fade(); 34 Scene mCurrentScene; 35 36 static { 37 sFade.addTarget(R.id.removingButton).addTarget(R.id.invisibleButton). 38 addTarget(R.id.goneButton); 39 } 40 41 @Override onCreate(Bundle savedInstanceState)42 public void onCreate(Bundle savedInstanceState) { 43 super.onCreate(savedInstanceState); 44 setContentView(R.layout.fading_test); 45 46 View container = findViewById(R.id.container); 47 mSceneRoot = (ViewGroup) container.getParent(); 48 49 50 mRemovingButton = findViewById(R.id.removingButton); 51 mInvisibleButton = findViewById(R.id.invisibleButton); 52 mGoneButton = findViewById(R.id.goneButton); 53 54 mGoneButton.setOnClickListener(new View.OnClickListener() { 55 @Override 56 public void onClick(View v) { 57 mGoneButton.setAlpha(mGoneButton.getAlpha() < 1 ? 1 : .6f); 58 } 59 }); 60 61 mScene1 = Scene.getSceneForLayout(mSceneRoot, R.layout.fading_test, this); 62 mScene2 = Scene.getSceneForLayout(mSceneRoot, R.layout.fading_test_scene_2, this); 63 64 mCurrentScene = mScene1; 65 } 66 sendMessage(View view)67 public void sendMessage(View view) { 68 if (mCurrentScene == mScene1) { 69 TransitionManager.go(mScene2); 70 mCurrentScene = mScene2; 71 } else { 72 TransitionManager.go(mScene1); 73 mCurrentScene = mScene1; 74 } 75 } 76 77 } 78