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.Scene; 23 import android.transition.TransitionInflater; 24 import android.transition.Transition; 25 import android.transition.TransitionManager; 26 27 28 public class ResourceLoadingTest extends Activity { 29 30 private static final int SEARCH_SCREEN = 0; 31 private static final int RESULTS_SCREEN = 1; 32 ViewGroup mSceneRoot; 33 static int mCurrentScene; 34 TransitionManager mTransitionManager = null; 35 TransitionInflater mInflater; 36 37 @Override onCreate(Bundle savedInstanceState)38 public void onCreate(Bundle savedInstanceState) { 39 super.onCreate(savedInstanceState); 40 setContentView(R.layout.search_screen); 41 42 View container = (View) findViewById(R.id.container); 43 mSceneRoot = (ViewGroup) container.getParent(); 44 45 mCurrentScene = SEARCH_SCREEN; 46 47 mInflater = TransitionInflater.from(this); 48 } 49 sendMessage(View view)50 public void sendMessage(View view) { 51 if (mTransitionManager == null) { 52 try { 53 TransitionInflater inflater = TransitionInflater.from(this); 54 mTransitionManager = 55 inflater.inflateTransitionManager(R.transition.my_transition_mgr, 56 mSceneRoot); 57 Scene loadedScene = new Scene(mSceneRoot); 58 System.out.println("loadedScene = " + loadedScene); 59 Transition loadedTransition = inflater.inflateTransition(R.transition.my_transition); 60 System.out.println("loadedTransition = " + loadedTransition); 61 } catch (Exception e) { 62 System.out.println("Problem loading scene resource: " + e); 63 } 64 } 65 if (mCurrentScene == RESULTS_SCREEN) { 66 Scene scene = Scene.getSceneForLayout(mSceneRoot, R.layout.search_screen, this); 67 mTransitionManager.transitionTo(scene); 68 mCurrentScene = SEARCH_SCREEN; 69 } else { 70 Scene scene = Scene.getSceneForLayout(mSceneRoot, R.layout.results_screen, this); 71 mTransitionManager.transitionTo(scene); 72 mCurrentScene = RESULTS_SCREEN; 73 } 74 } 75 } 76