Debian Codegraph @

tests/TransitionTests/src/com/android/transitiontests/InstanceTargets.java

raw symbols SCIP
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.ChangeBounds;
23 import android.transition.TransitionManager;
24 import android.widget.Button;
25
26 import static android.widget.RelativeLayout.ALIGN_PARENT_LEFT;
27 import static android.widget.RelativeLayout.ALIGN_PARENT_RIGHT;
28 import static android.widget.RelativeLayout.LayoutParams;
29
30 public class InstanceTargets extends Activity {
31
32 ViewGroup mSceneRoot;
33 static int mCurrentScene;
34
35 @Override
36 public void onCreate(Bundle savedInstanceState) {
37 super.onCreate(savedInstanceState);
38 setContentView(R.layout.instance_targets);
39
40 View container = findViewById(R.id.container);
41 mSceneRoot = (ViewGroup) container;
42 }
43
44 public void sendMessage(final View view) {
45 TransitionManager.beginDelayedTransition(mSceneRoot, new ChangeBounds().addTarget(view));
46 for (int i = 0; i < mSceneRoot.getChildCount(); ++i) {
47 Button button = (Button) mSceneRoot.getChildAt(i);
48 LayoutParams params = (LayoutParams) button.getLayoutParams();
49 int rules[] = params.getRules();
50 if (rules[ALIGN_PARENT_RIGHT] != 0) {
51 params.removeRule(ALIGN_PARENT_RIGHT);
52 params.addRule(ALIGN_PARENT_LEFT);
53 } else {
54 params.removeRule(ALIGN_PARENT_LEFT);
55 params.addRule(ALIGN_PARENT_RIGHT);
56 }
57 button.setLayoutParams(params);
58 }
59 }
60 }