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; |
Chet Haase | d82c8ac | 2013-08-26 14:20:16 -0700 | [diff] [blame] | 20 | import android.transition.ChangeBounds; |
Chet Haase | 867a866 | 2013-06-03 07:30:21 -0700 | [diff] [blame] | 21 | import android.view.View; |
| 22 | import android.view.ViewGroup; |
Chet Haase | d82c8ac | 2013-08-26 14:20:16 -0700 | [diff] [blame] | 23 | import android.transition.Scene; |
| 24 | import android.transition.TransitionSet; |
| 25 | import android.transition.TransitionManager; |
Chet Haase | 867a866 | 2013-06-03 07:30:21 -0700 | [diff] [blame] | 26 | import android.widget.RadioButton; |
| 27 | |
| 28 | public class InterruptionTest extends Activity { |
| 29 | |
| 30 | RadioButton mScene1RB, mScene2RB, mScene3RB, mScene4RB; |
| 31 | private Scene mScene1; |
| 32 | private Scene mScene2; |
| 33 | private Scene mScene3; |
| 34 | private Scene mScene4; |
Chet Haase | d82c8ac | 2013-08-26 14:20:16 -0700 | [diff] [blame] | 35 | TransitionSet mSequencedMove = new TransitionSet(). |
| 36 | setOrdering(TransitionSet.ORDERING_SEQUENTIAL); |
Chet Haase | 867a866 | 2013-06-03 07:30:21 -0700 | [diff] [blame] | 37 | |
| 38 | @Override |
| 39 | public void onCreate(Bundle savedInstanceState) { |
| 40 | super.onCreate(savedInstanceState); |
| 41 | setContentView(R.layout.interruption); |
| 42 | |
Alan Viverette | 51efddb | 2017-04-05 10:00:01 -0400 | [diff] [blame] | 43 | ViewGroup sceneRoot = findViewById(R.id.sceneRoot); |
Chet Haase | 867a866 | 2013-06-03 07:30:21 -0700 | [diff] [blame] | 44 | |
Chet Haase | d82c8ac | 2013-08-26 14:20:16 -0700 | [diff] [blame] | 45 | mScene1 = Scene.getSceneForLayout(sceneRoot, R.layout.interruption_inner_1, this); |
| 46 | mScene2 = Scene.getSceneForLayout(sceneRoot, R.layout.interruption_inner_2, this); |
| 47 | mScene3 = Scene.getSceneForLayout(sceneRoot, R.layout.interruption_inner_3, this); |
| 48 | mScene4 = Scene.getSceneForLayout(sceneRoot, R.layout.interruption_inner_4, this); |
Chet Haase | 867a866 | 2013-06-03 07:30:21 -0700 | [diff] [blame] | 49 | |
Alan Viverette | 51efddb | 2017-04-05 10:00:01 -0400 | [diff] [blame] | 50 | mScene1RB = findViewById(R.id.scene1RB); |
| 51 | mScene2RB = findViewById(R.id.scene2RB); |
| 52 | mScene3RB = findViewById(R.id.scene3RB); |
| 53 | mScene4RB = findViewById(R.id.scene4RB); |
Chet Haase | 867a866 | 2013-06-03 07:30:21 -0700 | [diff] [blame] | 54 | |
Chet Haase | d82c8ac | 2013-08-26 14:20:16 -0700 | [diff] [blame] | 55 | ChangeBounds changeBounds1 = new ChangeBounds(); |
Chet Haase | ff58f92 | 2013-09-11 13:08:18 -0700 | [diff] [blame] | 56 | changeBounds1.addTarget(R.id.button); |
Chet Haase | d82c8ac | 2013-08-26 14:20:16 -0700 | [diff] [blame] | 57 | ChangeBounds changeBounds2 = new ChangeBounds(); |
Chet Haase | ff58f92 | 2013-09-11 13:08:18 -0700 | [diff] [blame] | 58 | changeBounds2.addTarget(R.id.button1); |
Chet Haase | 867a866 | 2013-06-03 07:30:21 -0700 | [diff] [blame] | 59 | |
Chet Haase | d82c8ac | 2013-08-26 14:20:16 -0700 | [diff] [blame] | 60 | mSequencedMove.addTransition(changeBounds1).addTransition(changeBounds2); |
Chet Haase | 25a738f | 2013-06-04 16:35:14 -0700 | [diff] [blame] | 61 | mSequencedMove.setDuration(1000); |
Chet Haase | 867a866 | 2013-06-03 07:30:21 -0700 | [diff] [blame] | 62 | } |
| 63 | |
| 64 | public void onRadioButtonClicked(View clickedButton) { |
| 65 | if (clickedButton == mScene1RB) { |
Chet Haase | 25a738f | 2013-06-04 16:35:14 -0700 | [diff] [blame] | 66 | TransitionManager.go(mScene1, mSequencedMove); |
Chet Haase | 867a866 | 2013-06-03 07:30:21 -0700 | [diff] [blame] | 67 | } else if (clickedButton == mScene2RB) { |
Chet Haase | 25a738f | 2013-06-04 16:35:14 -0700 | [diff] [blame] | 68 | TransitionManager.go(mScene2, mSequencedMove); |
Chet Haase | 867a866 | 2013-06-03 07:30:21 -0700 | [diff] [blame] | 69 | } else if (clickedButton == mScene3RB) { |
Chet Haase | 25a738f | 2013-06-04 16:35:14 -0700 | [diff] [blame] | 70 | TransitionManager.go(mScene3, mSequencedMove); |
Chet Haase | 867a866 | 2013-06-03 07:30:21 -0700 | [diff] [blame] | 71 | } else { |
Chet Haase | 25a738f | 2013-06-04 16:35:14 -0700 | [diff] [blame] | 72 | TransitionManager.go(mScene4, mSequencedMove); |
Chet Haase | 867a866 | 2013-06-03 07:30:21 -0700 | [diff] [blame] | 73 | } |
| 74 | } |
| 75 | } |