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 */
16package com.android.transitiontests;
17
18import android.app.Activity;
19import android.os.Bundle;
20import android.transition.ChangeBounds;
21import android.view.View;
22import android.view.ViewGroup;
23import android.transition.Scene;
24import android.widget.Button;
25import android.transition.Fade;
26import android.transition.ChangeText;
27import android.transition.TransitionSet;
28import android.transition.TransitionManager;
29
30public class ClippingText extends Activity {
31
32    Button mRemovingButton, mInvisibleButton, mGoneButton;
33    Scene mScene1, mScene2;
34    ViewGroup mSceneRoot;
35    //    static Fade sFade = new Fade(R.id.removingButton, R.id.invisibleButton, R.id.goneButton);
36    Fade fader;
37    TransitionSet mChanger;
38    Scene mCurrentScene;
39
40    @Override
41    public void onCreate(Bundle savedInstanceState) {
42        super.onCreate(savedInstanceState);
43        setContentView(R.layout.clipping_text_1);
44
45        View container = (View) findViewById(R.id.container);
46        mSceneRoot = (ViewGroup) container.getParent();
47
48        mScene1 = Scene.getSceneForLayout(mSceneRoot, R.layout.clipping_text_1, this);
49        mScene2 = Scene.getSceneForLayout(mSceneRoot, R.layout.clipping_text_2, this);
50
51        mChanger = new TransitionSet().setOrdering(TransitionSet.ORDERING_TOGETHER);
52        ChangeBounds changeBounds = new ChangeBounds();
53        changeBounds.setResizeClip(true);
54        mChanger.addTransition(changeBounds).addTransition(new ChangeText());
55
56        mCurrentScene = mScene1;
57    }
58
59    public void sendMessage(View view) {
60        if (mCurrentScene == mScene1) {
61            TransitionManager.go(mScene2, mChanger);
62            mCurrentScene = mScene2;
63        } else {
64            TransitionManager.go(mScene1, mChanger);
65            mCurrentScene = mScene1;
66        }
67    }
68}
69