Home | History | Annotate | Download | only in transitiontests
      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.transition.TransitionSet;
     24 import android.transition.ChangeBounds;
     25 import android.transition.ChangeText;
     26 import android.transition.TransitionManager;
     27 
     28 public class ChangingText extends Activity {
     29 
     30     Scene mScene1, mScene2;
     31     ViewGroup mSceneRoot;
     32     TransitionSet mChanger;
     33     Scene mCurrentScene;
     34 
     35     @Override
     36     public void onCreate(Bundle savedInstanceState) {
     37         super.onCreate(savedInstanceState);
     38         setContentView(R.layout.changing_text_1);
     39 
     40         View container = findViewById(R.id.container);
     41         mSceneRoot = (ViewGroup) container.getParent();
     42 
     43         mScene1 = Scene.getSceneForLayout(mSceneRoot, R.layout.changing_text_1, this);
     44         mScene2 = Scene.getSceneForLayout(mSceneRoot, R.layout.changing_text_2, this);
     45 
     46         mChanger = new TransitionSet().setOrdering(TransitionSet.ORDERING_TOGETHER);
     47         mChanger.addTransition(new ChangeBounds()).addTransition(new ChangeText());
     48 
     49         mCurrentScene = mScene1;
     50     }
     51 
     52     public void sendMessage(View view) {
     53         if (mCurrentScene == mScene1) {
     54             TransitionManager.go(mScene2, mChanger);
     55             mCurrentScene = mScene2;
     56         } else {
     57             TransitionManager.go(mScene1, mChanger);
     58             mCurrentScene = mScene1;
     59         }
     60     }
     61 }
     62