Chet Haase | faebd8f | 2012-05-18 14:17:57 -0700 | [diff] [blame] | 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.view.transition.Scene; |
| 23 | import android.widget.Button; |
| 24 | import android.view.transition.Fade; |
| 25 | import android.view.transition.TransitionManager; |
Chet Haase | faebd8f | 2012-05-18 14:17:57 -0700 | [diff] [blame] | 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 | |
| 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 | } |