Chet Haase | 867a866 | 2013-06-03 07:30:21 -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.AutoTransition; |
| 23 | import android.view.transition.Move; |
| 24 | import android.view.transition.Scene; |
| 25 | import android.view.transition.TextChange; |
| 26 | import android.view.transition.Transition; |
| 27 | import android.view.transition.TransitionGroup; |
| 28 | import android.view.transition.TransitionManager; |
| 29 | import android.widget.RadioButton; |
| 30 | |
| 31 | public class InterruptionTest extends Activity { |
| 32 | |
| 33 | RadioButton mScene1RB, mScene2RB, mScene3RB, mScene4RB; |
| 34 | private Scene mScene1; |
| 35 | private Scene mScene2; |
| 36 | private Scene mScene3; |
| 37 | private Scene mScene4; |
Chet Haase | 25a738f | 2013-06-04 16:35:14 -0700 | [diff] [blame] | 38 | TransitionGroup mSequencedMove = new TransitionGroup(TransitionGroup.SEQUENTIALLY); |
Chet Haase | 867a866 | 2013-06-03 07:30:21 -0700 | [diff] [blame] | 39 | |
| 40 | @Override |
| 41 | public void onCreate(Bundle savedInstanceState) { |
| 42 | super.onCreate(savedInstanceState); |
| 43 | setContentView(R.layout.interruption); |
| 44 | |
Chet Haase | 867a866 | 2013-06-03 07:30:21 -0700 | [diff] [blame] | 45 | ViewGroup sceneRoot = (ViewGroup) findViewById(R.id.sceneRoot); |
| 46 | |
| 47 | mScene1 = new Scene(sceneRoot, R.layout.interruption_inner_1, this); |
| 48 | mScene2 = new Scene(sceneRoot, R.layout.interruption_inner_2, this); |
| 49 | mScene3 = new Scene(sceneRoot, R.layout.interruption_inner_3, this); |
| 50 | mScene4 = new Scene(sceneRoot, R.layout.interruption_inner_4, this); |
| 51 | |
| 52 | mScene1RB = (RadioButton) findViewById(R.id.scene1RB); |
| 53 | mScene2RB = (RadioButton) findViewById(R.id.scene2RB); |
| 54 | mScene3RB = (RadioButton) findViewById(R.id.scene3RB); |
| 55 | mScene4RB = (RadioButton) findViewById(R.id.scene4RB); |
| 56 | |
| 57 | sceneRoot.setCurrentScene(mScene1); |
| 58 | |
Chet Haase | 25a738f | 2013-06-04 16:35:14 -0700 | [diff] [blame] | 59 | Move move1 = new Move(); |
| 60 | move1.setTargetIds(R.id.button); |
| 61 | Move move2 = new Move(); |
| 62 | move2.setTargetIds(R.id.button1); |
| 63 | |
| 64 | mSequencedMove.addTransitions(move1, move2); |
| 65 | mSequencedMove.setDuration(1000); |
Chet Haase | 867a866 | 2013-06-03 07:30:21 -0700 | [diff] [blame] | 66 | } |
| 67 | |
| 68 | public void onRadioButtonClicked(View clickedButton) { |
| 69 | if (clickedButton == mScene1RB) { |
Chet Haase | 25a738f | 2013-06-04 16:35:14 -0700 | [diff] [blame] | 70 | TransitionManager.go(mScene1, mSequencedMove); |
Chet Haase | 867a866 | 2013-06-03 07:30:21 -0700 | [diff] [blame] | 71 | } else if (clickedButton == mScene2RB) { |
Chet Haase | 25a738f | 2013-06-04 16:35:14 -0700 | [diff] [blame] | 72 | TransitionManager.go(mScene2, mSequencedMove); |
Chet Haase | 867a866 | 2013-06-03 07:30:21 -0700 | [diff] [blame] | 73 | } else if (clickedButton == mScene3RB) { |
Chet Haase | 25a738f | 2013-06-04 16:35:14 -0700 | [diff] [blame] | 74 | TransitionManager.go(mScene3, mSequencedMove); |
Chet Haase | 867a866 | 2013-06-03 07:30:21 -0700 | [diff] [blame] | 75 | } else { |
Chet Haase | 25a738f | 2013-06-04 16:35:14 -0700 | [diff] [blame] | 76 | TransitionManager.go(mScene4, mSequencedMove); |
Chet Haase | 867a866 | 2013-06-03 07:30:21 -0700 | [diff] [blame] | 77 | } |
| 78 | } |
| 79 | } |