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.transition.ChangeBounds;
     21 import android.view.View;
     22 import android.view.ViewGroup;
     23 import android.transition.Scene;
     24 import android.transition.TransitionSet;
     25 import android.transition.TransitionManager;
     26 import android.widget.RadioButton;
     27 
     28 public class InterruptionTest extends Activity {
     29 
     30     RadioButton mScene1RB, mScene2RB, mScene3RB, mScene4RB;
     31     private Scene mScene1;
     32     private Scene mScene2;
     33     private Scene mScene3;
     34     private Scene mScene4;
     35     TransitionSet mSequencedMove = new TransitionSet().
     36             setOrdering(TransitionSet.ORDERING_SEQUENTIAL);
     37 
     38     @Override
     39     public void onCreate(Bundle savedInstanceState) {
     40         super.onCreate(savedInstanceState);
     41         setContentView(R.layout.interruption);
     42 
     43         ViewGroup sceneRoot = findViewById(R.id.sceneRoot);
     44 
     45         mScene1 = Scene.getSceneForLayout(sceneRoot, R.layout.interruption_inner_1, this);
     46         mScene2 = Scene.getSceneForLayout(sceneRoot, R.layout.interruption_inner_2, this);
     47         mScene3 = Scene.getSceneForLayout(sceneRoot, R.layout.interruption_inner_3, this);
     48         mScene4 = Scene.getSceneForLayout(sceneRoot, R.layout.interruption_inner_4, this);
     49 
     50         mScene1RB = findViewById(R.id.scene1RB);
     51         mScene2RB = findViewById(R.id.scene2RB);
     52         mScene3RB = findViewById(R.id.scene3RB);
     53         mScene4RB = findViewById(R.id.scene4RB);
     54 
     55         ChangeBounds changeBounds1 = new ChangeBounds();
     56         changeBounds1.addTarget(R.id.button);
     57         ChangeBounds changeBounds2 = new ChangeBounds();
     58         changeBounds2.addTarget(R.id.button1);
     59 
     60         mSequencedMove.addTransition(changeBounds1).addTransition(changeBounds2);
     61         mSequencedMove.setDuration(1000);
     62     }
     63 
     64     public void onRadioButtonClicked(View clickedButton) {
     65         if (clickedButton == mScene1RB) {
     66             TransitionManager.go(mScene1, mSequencedMove);
     67         } else if (clickedButton == mScene2RB) {
     68             TransitionManager.go(mScene2, mSequencedMove);
     69         } else if (clickedButton == mScene3RB) {
     70             TransitionManager.go(mScene3, mSequencedMove);
     71         } else {
     72             TransitionManager.go(mScene4, mSequencedMove);
     73         }
     74     }
     75 }
     76