blob: cf4ea9ad66a576e7c35604deb57d134116dcff27 [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.content.Context;
20import android.os.Bundle;
21import android.view.LayoutInflater;
22import android.view.View;
23import android.view.ViewGroup;
24import android.view.transition.Move;
25import android.view.transition.Scene;
26import android.view.transition.TransitionManager;
27import android.widget.Button;
28import android.widget.RelativeLayout;
Chet Haasefaebd8f2012-05-18 14:17:57 -070029
30import static android.widget.RelativeLayout.ALIGN_PARENT_LEFT;
31import static android.widget.RelativeLayout.ALIGN_PARENT_RIGHT;
32import static android.widget.RelativeLayout.LayoutParams;
33
34public class InstanceTargets extends Activity {
35
36 ViewGroup mSceneRoot;
37 static int mCurrentScene;
38
39 @Override
40 public void onCreate(Bundle savedInstanceState) {
41 super.onCreate(savedInstanceState);
42 setContentView(R.layout.instance_targets);
43
44 View container = (View) findViewById(R.id.container);
45 mSceneRoot = (ViewGroup) container;
46 }
47
48 public void sendMessage(final View view) {
49 TransitionManager.go(mSceneRoot, new Runnable() {
50 @Override
51 public void run() {
52 for (int i = 0; i < mSceneRoot.getChildCount(); ++i) {
53 Button button = (Button) mSceneRoot.getChildAt(i);
54 LayoutParams params = (LayoutParams) button.getLayoutParams();
55 int rules[] = params.getRules();
56 if (rules[ALIGN_PARENT_RIGHT] != 0) {
57 params.removeRule(ALIGN_PARENT_RIGHT);
58 params.addRule(ALIGN_PARENT_LEFT);
59 } else {
60 params.removeRule(ALIGN_PARENT_LEFT);
61 params.addRule(ALIGN_PARENT_RIGHT);
62 }
63 button.setLayoutParams(params);
64 }
65 }
66 }, new Move().setTargets(view));
67 }
68}