Example usage for android.transition Scene getSceneForLayout

List of usage examples for android.transition Scene getSceneForLayout

Introduction

In this page you can find the example usage for android.transition Scene getSceneForLayout.

Prototype

public static Scene getSceneForLayout(ViewGroup sceneRoot, int layoutId, Context context) 

Source Link

Document

Returns a Scene described by the resource file associated with the given layoutId parameter.

Usage

From source file:com.example.android.customtransition.CustomTransitionFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    Context context = getActivity();
    FrameLayout container = (FrameLayout) view.findViewById(R.id.container);
    view.findViewById(R.id.show_next_scene).setOnClickListener(this);
    if (null != savedInstanceState) {
        mCurrentScene = savedInstanceState.getInt(STATE_CURRENT_SCENE);
    }/*from  ww w  . j  av  a 2 s .  co m*/
    // We set up the Scenes here.
    mScenes = new Scene[] { Scene.getSceneForLayout(container, R.layout.scene1, context),
            Scene.getSceneForLayout(container, R.layout.scene2, context),
            Scene.getSceneForLayout(container, R.layout.scene3, context), };
    // This is the custom Transition.
    mTransition = new ChangeColor();
    // Show the initial Scene.
    TransitionManager.go(mScenes[mCurrentScene % mScenes.length]);
}

From source file:com.example.tripi.transitionanimation.BasicTransitionFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_basic_transition, container, false);
    assert view != null;
    RadioGroup radioGroup = (RadioGroup) view.findViewById(R.id.select_scene);
    radioGroup.setOnCheckedChangeListener(this);
    mSceneRoot = (ViewGroup) view.findViewById(R.id.scene_root);

    // BEGIN_INCLUDE(instantiation_from_view)
    // A Scene can be instantiated from a live view hierarchy.
    mScene1 = Scene.getSceneForLayout(mSceneRoot, R.layout.scene1, getActivity());

    //        mScene1 = new Scene(mSceneRoot, (ViewGroup) mSceneRoot.findViewById(R.id.container));

    // END_INCLUDE(instantiation_from_view)

    // BEGIN_INCLUDE(instantiation_from_resource)
    // You can also inflate a generate a Scene from a layout resource file.
    mScene2 = Scene.getSceneForLayout(mSceneRoot, R.layout.scene2, getActivity());
    // END_INCLUDE(instantiation_from_resource)

    // Another scene from a layout resource file.
    mScene3 = Scene.getSceneForLayout(mSceneRoot, R.layout.scene3, getActivity());

    // BEGIN_INCLUDE(custom_transition_manager)
    // We create a custom TransitionManager for Scene 3, in which ChangeBounds and Fade
    // take place at the same time.
    mTransitionManagerForScene3 = TransitionInflater.from(getActivity())
            .inflateTransitionManager(R.transition.scene3_transition_manager, mSceneRoot);
    mTransitionManagerForScene2 = TransitionInflater.from(getActivity())
            .inflateTransitionManager(R.transition.scene2_transition_manager, mSceneRoot);
    mTransitionManagerForScene1 = TransitionInflater.from(getActivity())
            .inflateTransitionManager(R.transition.scene1_transition_manager, mSceneRoot);
    // END_INCLUDE(custom_transition_manager)

    return view;/*from  w  w w.j  a v  a  2 s.  co  m*/
}

From source file:info.ipeanut.googletrainingcoursedemos.customtransition.CustomTransitionFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    Context context = getActivity();
    FrameLayout container = (FrameLayout) view.findViewById(R.id.container);
    view.findViewById(R.id.show_next_scene).setOnClickListener(this);
    if (null != savedInstanceState) {
        mCurrentScene = savedInstanceState.getInt(STATE_CURRENT_SCENE);
    }/*  w  w  w . ja  v a2 s . c om*/
    // We set up the Scenes here.
    mScenes = new Scene[] { Scene.getSceneForLayout(container, R.layout.scene_c1, context),
            Scene.getSceneForLayout(container, R.layout.scene_c2, context),
            Scene.getSceneForLayout(container, R.layout.scene_c3, context), };
    // This is the custom Transition.
    mTransition = new ChangeColor();
    // Show the initial Scene.
    TransitionManager.go(mScenes[mCurrentScene % mScenes.length]);
}

From source file:com.example.android.basictransition.BasicTransitionFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_basic_transition, container, false);
    assert view != null;
    RadioGroup radioGroup = (RadioGroup) view.findViewById(R.id.select_scene);
    radioGroup.setOnCheckedChangeListener(this);
    mSceneRoot = (ViewGroup) view.findViewById(R.id.scene_root);

    // BEGIN_INCLUDE(instantiation_from_view)
    // A Scene can be instantiated from a live view hierarchy.
    mScene1 = new Scene(mSceneRoot, (ViewGroup) mSceneRoot.findViewById(R.id.container));
    // END_INCLUDE(instantiation_from_view)

    // BEGIN_INCLUDE(instantiation_from_resource)
    // You can also inflate a generate a Scene from a layout resource file.
    mScene2 = Scene.getSceneForLayout(mSceneRoot, R.layout.scene2, getActivity());
    // END_INCLUDE(instantiation_from_resource)

    // Another scene from a layout resource file.
    mScene3 = Scene.getSceneForLayout(mSceneRoot, R.layout.scene3, getActivity());

    // BEGIN_INCLUDE(custom_transition_manager)
    // We create a custom TransitionManager for Scene 3, in which ChangeBounds and Fade
    // take place at the same time.
    mTransitionManagerForScene3 = TransitionInflater.from(getActivity())
            .inflateTransitionManager(R.transition.scene3_transition_manager, mSceneRoot);
    // END_INCLUDE(custom_transition_manager)

    return view;//from   www  . j  a  v a 2  s . c o m
}

From source file:info.ipeanut.googletrainingcoursedemos.basictransition.BasicTransitionFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_basic_transition, container, false);
    assert view != null;
    RadioGroup radioGroup = (RadioGroup) view.findViewById(R.id.select_scene);
    radioGroup.setOnCheckedChangeListener(this);
    mSceneRoot = (ViewGroup) view.findViewById(R.id.scene_root);

    // A Scene can be instantiated from a live view hierarchy.
    mScene1 = new Scene(mSceneRoot, (ViewGroup) mSceneRoot.findViewById(R.id.container));

    // You can also inflate a generate a Scene from a layout resource file.
    mScene2 = Scene.getSceneForLayout(mSceneRoot, R.layout.scene_b2, getActivity());

    // Another scene from a layout resource file.
    mScene3 = Scene.getSceneForLayout(mSceneRoot, R.layout.scene_b3, getActivity());

    // We create a custom TransitionManager for Scene 3, in which ChangeBounds and Fade
    // take place at the same time.
    mTransitionManagerForScene3 = TransitionInflater.from(getActivity())
            .inflateTransitionManager(R.transition.scene3_transition_manager, mSceneRoot);

    return view;//from  w  w w.ja v a 2s  .c om
}

From source file:com.example.st.animsharedemo.transitions.BasicTransitionFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_basic_transition, container, false);
    assert view != null;
    RadioGroup radioGroup = (RadioGroup) view.findViewById(R.id.select_scene);
    radioGroup.setOnCheckedChangeListener(this);
    mSceneRoot = (ViewGroup) view.findViewById(R.id.scene_root);

    // BEGIN_INCLUDE(instantiation_from_view)
    // A Scene can be instantiated from a live view hierarchy.
    mScene1 = new Scene(mSceneRoot, (ViewGroup) mSceneRoot.findViewById(R.id.container));
    // END_INCLUDE(instantiation_from_view)

    // BEGIN_INCLUDE(instantiation_from_resource)
    // You can also inflate a generate a Scene from a layout resource file.
    mScene2 = Scene.getSceneForLayout(mSceneRoot, R.layout.scene22, getActivity());
    // END_INCLUDE(instantiation_from_resource)

    // Another scene from a layout resource file.
    mScene3 = Scene.getSceneForLayout(mSceneRoot, R.layout.scene33, getActivity());

    // BEGIN_INCLUDE(custom_transition_manager)
    // We create a custom TransitionManager for Scene 3, in which ChangeBounds and Fade
    // take place at the same time.
    mTransitionManagerForScene3 = TransitionInflater.from(getActivity())
            .inflateTransitionManager(R.transition.scene3_transition_manager, mSceneRoot);
    // END_INCLUDE(custom_transition_manager)

    return view;//from w w  w.j  ava  2 s . c  o  m
}

From source file:com.shinobicontrols.transitions.StoryDetailActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_story_detail);

    if (savedInstanceState == null) {
        // Load the data from the intent on first pass
        Intent intent = getIntent();/*w w  w. ja va 2s. c o  m*/
        String story_id = intent.getStringExtra(ARG_STORY_ID);
        mItem = StoryContent.STORY_MAP.get(story_id);
    }

    // Get hold of some relevant content
    final ViewGroup container = (ViewGroup) findViewById(R.id.container);

    // What are the layouts we should be able to transition between
    List<Integer> sceneLayouts = Arrays.asList(R.layout.content_scene_00, R.layout.content_scene_01,
            R.layout.content_scene_02);
    // Create the scenes
    sceneList = new ArrayList<Scene>();
    for (int layout : sceneLayouts) {
        // Create the scene
        Scene scene = Scene.getSceneForLayout(container, layout, this);
        // Just before the transition starts, ensure that the content has been loaded
        scene.setEnterAction(new Runnable() {
            @Override
            public void run() {
                addContentToViewGroup(container);
            }
        });
        // Save the scene into
        sceneList.add(scene);
    }

    // Build the transition manager
    TransitionInflater transitionInflater = TransitionInflater.from(this);
    mTransitionManager = transitionInflater.inflateTransitionManager(R.transition.story_transition_manager,
            container);

    // Show the Up button in the action bar.
    final ActionBar actionBar = getActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);

        // Specify we want some tabs
        actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

        // Create a listener to cope with tab changes
        ActionBar.TabListener tabListener = new ActionBar.TabListener() {
            @Override
            public void onTabSelected(ActionBar.Tab tab, FragmentTransaction ft) {
                // If there's a scene for this tab index, then transition to it
                if (tab.getPosition() <= sceneList.size()) {
                    performTransitionToScene(sceneList.get(tab.getPosition()));
                }
            }

            @Override
            public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction ft) {
                // Can ignore this event
            }

            @Override
            public void onTabReselected(ActionBar.Tab tab, FragmentTransaction ft) {
                // Can ignore this event
            }

            private void performTransitionToScene(Scene scene) {
                mTransitionManager.transitionTo(scene);
            }
        };

        // Add some tabs
        for (int i = 0; i < sceneList.size(); i++) {
            actionBar.addTab(actionBar.newTab().setText("Scene " + i).setTabListener(tabListener));
        }
    }

    // Load the first scene
    sceneList.get(0).enter();
}

From source file:com.ijunes.transitions.StoryDetailActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_story_detail);

    if (savedInstanceState == null) {
        // Load the data from the intent on first pass
        Intent intent = getIntent();/*from   w w  w.j av  a2 s.  c  o m*/
        String story_id = intent.getStringExtra(ARG_STORY_ID);
        mItem = StoryContent.STORY_MAP.get(story_id);
    }

    // Get hold of some relevant content
    final ViewGroup container = (ViewGroup) findViewById(R.id.container);

    // What are the layouts we should be able to transition between
    List<Integer> sceneLayouts = Arrays.asList(R.layout.content_scene_00, R.layout.content_scene_01,
            R.layout.content_scene_02);
    // Create the scenes
    sceneList = new ArrayList<Scene>();
    for (int layout : sceneLayouts) {
        // Create the scene
        Scene scene = Scene.getSceneForLayout(container, layout, this);
        // Just before the transition starts, ensure that the content has been loaded
        scene.setEnterAction(new Runnable() {
            @Override
            public void run() {
                addContentToViewGroup(container);
            }
        });
        // Save the scene into
        sceneList.add(scene);
    }

    // Build the transition manager
    TransitionInflater transitionInflater = TransitionInflater.from(this);
    mTransitionManager = transitionInflater.inflateTransitionManager(R.transition.story_transition_manager,
            container);

    // Show the Up button in the action bar.
    final ActionBar actionBar = getActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);

        // Specify we want some tabs
        actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

        // Create a listener to cope with tab changes
        tabListener = new ActionBar.TabListener() {
            @Override
            public void onTabSelected(ActionBar.Tab tab, FragmentTransaction ft) {
                // If there's a scene for this tab index, then transition to it

                if (tab.getPosition() <= sceneList.size()) {
                    tabPosition = tab.getPosition();
                    performTransitionToScene(sceneList.get(tab.getPosition()));
                }
            }

            @Override
            public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction ft) {
                // Can ignore this event
            }

            @Override
            public void onTabReselected(ActionBar.Tab tab, FragmentTransaction ft) {
                // Can ignore this event
            }

            public void performTransitionToScene(Scene scene) {
                mTransitionManager.transitionTo(scene);
            }
        };

        // Add some tabs
        for (int i = 0; i < sceneList.size(); i++) {
            actionBar.addTab(actionBar.newTab().setText("Scene " + i).setTabListener(tabListener));
        }
    }

    // Load the first scene
    sceneList.get(0).enter();
}

From source file:com.example.android.fragmenttransition.DetailFragment.java

@Override
public void onAnimationEnd(Animation animation) {
    // This method is called at the end of the animation for the fragment transaction,
    // which is perfect time to start our Transition.
    Log.i(TAG, "Fragment animation ended. Starting a Transition.");
    final Scene scene = Scene.getSceneForLayout((ViewGroup) getView(), R.layout.fragment_detail_content,
            getActivity());//from  w  ww  .ja v a2s  .  c o m
    TransitionManager.go(scene);
    // Note that we need to bind views with data after we call TransitionManager.go().
    bind(scene.getSceneRoot());
}

From source file:com.intel.demo.fragmenttransition.DetailFragment.java

@TargetApi(Build.VERSION_CODES.KITKAT)
@Override//  w w  w  . j  a  v  a 2s . com
public void onAnimationEnd(Animation animation) {
    // This method is called at the end of the animation for the fragment transaction,
    // which is perfect time to start our Transition.
    Log.i(TAG, "Fragment animation ended. Starting a Transition.");
    final Scene scene = Scene.getSceneForLayout((ViewGroup) getView(), R.layout.fragment_detail_content,
            getActivity());
    TransitionManager.go(scene);
    // Note that we need to bind views with data after we call TransitionManager.go().
    bind(scene.getSceneRoot());
}