List of usage examples for android.transition TransitionInflater inflateTransitionManager
public TransitionManager inflateTransitionManager(@TransitionRes int resource, ViewGroup sceneRoot)
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();/*from w w w. jav a 2s . co 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();/*w ww . j a v a 2 s. c om*/ 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(); }