blob: 9985357d4577a319bf7186c609581b58d55bb114 [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;
Chet Haased82c8ac2013-08-26 14:20:16 -070020import android.transition.ChangeBounds;
Chet Haasefaebd8f2012-05-18 14:17:57 -070021import android.view.View;
22import android.view.ViewGroup;
Chet Haased82c8ac2013-08-26 14:20:16 -070023import android.transition.Scene;
Chet Haasefaebd8f2012-05-18 14:17:57 -070024import android.widget.Button;
Chet Haased82c8ac2013-08-26 14:20:16 -070025import android.transition.Fade;
Chet Haaseb7a7fc92013-09-20 16:33:08 -070026import android.transition.ChangeText;
Chet Haased82c8ac2013-08-26 14:20:16 -070027import android.transition.TransitionSet;
28import android.transition.TransitionManager;
Chet Haasefaebd8f2012-05-18 14:17:57 -070029
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;
Chet Haased82c8ac2013-08-26 14:20:16 -070037 TransitionSet mChanger;
38 Scene mCurrentScene;
Chet Haasefaebd8f2012-05-18 14:17:57 -070039
40 @Override
41 public void onCreate(Bundle savedInstanceState) {
42 super.onCreate(savedInstanceState);
43 setContentView(R.layout.clipping_text_1);
44
Alan Viverette51efddb2017-04-05 10:00:01 -040045 View container = findViewById(R.id.container);
Chet Haasefaebd8f2012-05-18 14:17:57 -070046 mSceneRoot = (ViewGroup) container.getParent();
47
Chet Haased82c8ac2013-08-26 14:20:16 -070048 mScene1 = Scene.getSceneForLayout(mSceneRoot, R.layout.clipping_text_1, this);
49 mScene2 = Scene.getSceneForLayout(mSceneRoot, R.layout.clipping_text_2, this);
Chet Haasefaebd8f2012-05-18 14:17:57 -070050
Chet Haased82c8ac2013-08-26 14:20:16 -070051 mChanger = new TransitionSet().setOrdering(TransitionSet.ORDERING_TOGETHER);
52 ChangeBounds changeBounds = new ChangeBounds();
53 changeBounds.setResizeClip(true);
Chet Haaseb7a7fc92013-09-20 16:33:08 -070054 mChanger.addTransition(changeBounds).addTransition(new ChangeText());
Chet Haasefaebd8f2012-05-18 14:17:57 -070055
Chet Haased82c8ac2013-08-26 14:20:16 -070056 mCurrentScene = mScene1;
Chet Haasefaebd8f2012-05-18 14:17:57 -070057 }
58
59 public void sendMessage(View view) {
Chet Haased82c8ac2013-08-26 14:20:16 -070060 if (mCurrentScene == mScene1) {
Chet Haasefaebd8f2012-05-18 14:17:57 -070061 TransitionManager.go(mScene2, mChanger);
Chet Haased82c8ac2013-08-26 14:20:16 -070062 mCurrentScene = mScene2;
Chet Haasefaebd8f2012-05-18 14:17:57 -070063 } else {
64 TransitionManager.go(mScene1, mChanger);
Chet Haased82c8ac2013-08-26 14:20:16 -070065 mCurrentScene = mScene1;
Chet Haasefaebd8f2012-05-18 14:17:57 -070066 }
67 }
68}