blob: 01d46b2f86699f51288edb8ac8105562775878c8 [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;
Chet Haased82c8ac2013-08-26 14:20:16 -070022import android.transition.Scene;
23import android.transition.TransitionSet;
24import android.transition.ChangeBounds;
Chet Haaseb7a7fc92013-09-20 16:33:08 -070025import android.transition.ChangeText;
Chet Haased82c8ac2013-08-26 14:20:16 -070026import android.transition.TransitionManager;
Chet Haasefaebd8f2012-05-18 14:17:57 -070027
28public class ChangingText extends Activity {
29
Chet Haasefaebd8f2012-05-18 14:17:57 -070030 Scene mScene1, mScene2;
31 ViewGroup mSceneRoot;
Chet Haased82c8ac2013-08-26 14:20:16 -070032 TransitionSet mChanger;
33 Scene mCurrentScene;
Chet Haasefaebd8f2012-05-18 14:17:57 -070034
35 @Override
36 public void onCreate(Bundle savedInstanceState) {
37 super.onCreate(savedInstanceState);
38 setContentView(R.layout.changing_text_1);
39
Chet Haased82c8ac2013-08-26 14:20:16 -070040 View container = findViewById(R.id.container);
Chet Haasefaebd8f2012-05-18 14:17:57 -070041 mSceneRoot = (ViewGroup) container.getParent();
42
Chet Haased82c8ac2013-08-26 14:20:16 -070043 mScene1 = Scene.getSceneForLayout(mSceneRoot, R.layout.changing_text_1, this);
44 mScene2 = Scene.getSceneForLayout(mSceneRoot, R.layout.changing_text_2, this);
Chet Haasefaebd8f2012-05-18 14:17:57 -070045
Chet Haased82c8ac2013-08-26 14:20:16 -070046 mChanger = new TransitionSet().setOrdering(TransitionSet.ORDERING_TOGETHER);
Chet Haaseb7a7fc92013-09-20 16:33:08 -070047 mChanger.addTransition(new ChangeBounds()).addTransition(new ChangeText());
Chet Haasefaebd8f2012-05-18 14:17:57 -070048
Chet Haased82c8ac2013-08-26 14:20:16 -070049 mCurrentScene = mScene1;
Chet Haasefaebd8f2012-05-18 14:17:57 -070050 }
51
52 public void sendMessage(View view) {
Chet Haased82c8ac2013-08-26 14:20:16 -070053 if (mCurrentScene == mScene1) {
Chet Haasefaebd8f2012-05-18 14:17:57 -070054 TransitionManager.go(mScene2, mChanger);
Chet Haased82c8ac2013-08-26 14:20:16 -070055 mCurrentScene = mScene2;
Chet Haasefaebd8f2012-05-18 14:17:57 -070056 } else {
57 TransitionManager.go(mScene1, mChanger);
Chet Haased82c8ac2013-08-26 14:20:16 -070058 mCurrentScene = mScene1;
Chet Haasefaebd8f2012-05-18 14:17:57 -070059 }
60 }
61}