List of usage examples for android.transition TransitionInflater from
public static TransitionInflater from(Context context)
From source file:com.syncedsynapse.kore2.ui.MusicActivity.java
@TargetApi(21) @Override/*from ww w.j av a 2 s .co m*/ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_generic_media); // Set up the drawer. navigationDrawerFragment = (NavigationDrawerFragment) getSupportFragmentManager() .findFragmentById(R.id.navigation_drawer); navigationDrawerFragment.setUp(R.id.navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout)); if (savedInstanceState == null) { MusicListFragment musicListFragment = new MusicListFragment(); // Setup animations if (Utils.isLollipopOrLater()) { musicListFragment.setExitTransition(null); musicListFragment.setReenterTransition( TransitionInflater.from(this).inflateTransition(android.R.transition.fade)); } getSupportFragmentManager().beginTransaction().add(R.id.fragment_container, musicListFragment).commit(); } else { selectedAlbumId = savedInstanceState.getInt(ALBUMID, -1); selectedArtistId = savedInstanceState.getInt(ARTISTID, -1); selectedGenreId = savedInstanceState.getInt(GENREID, -1); selectedMusicVideoId = savedInstanceState.getInt(MUSICVIDEOID, -1); selectedAlbumTitle = savedInstanceState.getString(ALBUMTITLE, null); selectedArtistName = savedInstanceState.getString(ARTISTNAME, null); selectedGenreTitle = savedInstanceState.getString(GENRETITLE, null); selectedMusicVideoTitle = savedInstanceState.getString(MUSICVIDEOTITLE, null); } setupActionBar(selectedAlbumTitle, selectedArtistName, selectedGenreTitle, selectedMusicVideoTitle); // // Setup system bars and content padding, allowing averlap with the bottom bar // setupSystemBarsColors(); // UIUtils.setPaddingForSystemBars(this, findViewById(R.id.fragment_container), true, true, true); // UIUtils.setPaddingForSystemBars(this, findViewById(R.id.drawer_layout), true, true, true); }
From source file:com.amitupadhyay.aboutexample.ui.AboutActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_about); ButterKnife.bind(this); pager.setAdapter(new AboutPagerAdapter(AboutActivity.this)); pager.setPageMargin(getResources().getDimensionPixelSize(R.dimen.spacing_normal)); pageIndicator.setViewPager(pager);//w w w . j a v a 2 s . c om draggableFrame.addListener(new ElasticDragDismissFrameLayout.SystemChromeFader(this) { @Override public void onDragDismissed() { // if we drag dismiss downward then the default reversal of the enter // transition would slide content upward which looks weird. So reverse it. if (draggableFrame.getTranslationY() > 0) { getWindow().setReturnTransition(TransitionInflater.from(AboutActivity.this) .inflateTransition(R.transition.about_return_downward)); } finishAfterTransition(); } }); }
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 . j a v a2 s . 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:tomerbu.edu.transitionsdemo.MyRecyclerAdapter.java
@Override public void onBindViewHolder(final MyViewHolder holder, int position) { final Cheese cheese = data.get(position); holder.tvTitle.setText(cheese.getDescription()); holder.ivImage.setImageResource(cheese.getImageResID()); holder.itemView.setOnClickListener(new View.OnClickListener() { @Override/* w w w . j a v a2 s .c o m*/ public void onClick(View view) { Intent intent = new Intent(context, DetailsActivity.class); intent.putExtra(EXTRA_CHEESE, cheese); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { holder.tvTitle.setTransitionName("description"); holder.ivImage.setTransitionName("image"); View tvTitle = holder.tvTitle; View ivImage = holder.ivImage; Pair<View, String> pair1 = Pair.create(tvTitle, tvTitle.getTransitionName()); Pair<View, String> pair2 = Pair.create(ivImage, ivImage.getTransitionName()); MainActivity act = (MainActivity) context; ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(act, pair1, pair2); Transition transition = TransitionInflater.from(act).inflateTransition(R.transition.arc_bounds); /* Transition transition = new Slide(); ArcMotion arc = new ArcMotion(); arc.setMinimumHorizontalAngle(90); transition.setPathMotion(arc);*/ act.getWindow().setSharedElementEnterTransition(transition); act.getWindow().setSharedElementExitTransition(transition); act.getWindow().setSharedElementReenterTransition(transition); act.getWindow().setSharedElementReturnTransition(transition); ActivityCompat.startActivity(act, intent, options.toBundle()); } else { context.startActivity(intent); } } }); }
From source file:org.xbmc.kore.ui.MusicActivity.java
@TargetApi(21) @Override//from www . jav a 2s. c om protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_generic_media); // Set up the drawer. navigationDrawerFragment = (NavigationDrawerFragment) getSupportFragmentManager() .findFragmentById(R.id.navigation_drawer); navigationDrawerFragment.setUp(R.id.navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout)); if (savedInstanceState == null) { musicListFragment = new MusicListFragment(); // Setup animations if (Utils.isLollipopOrLater()) { musicListFragment.setExitTransition(null); musicListFragment.setReenterTransition( TransitionInflater.from(this).inflateTransition(android.R.transition.fade)); musicListFragment.setExitSharedElementCallback(new SharedElementCallback() { @Override public void onMapSharedElements(List<String> names, Map<String, View> sharedElements) { // Clearing must be done in the reentering fragment // as this is called last. Otherwise, the app will crash during transition setup. Not sure, but might // be a v4 support package bug. if (clearSharedElements) { names.clear(); sharedElements.clear(); clearSharedElements = false; } } }); } getSupportFragmentManager().beginTransaction().add(R.id.fragment_container, musicListFragment).commit(); } else { selectedAlbumId = savedInstanceState.getInt(ALBUMID, -1); selectedArtistId = savedInstanceState.getInt(ARTISTID, -1); selectedGenreId = savedInstanceState.getInt(GENREID, -1); selectedMusicVideoId = savedInstanceState.getInt(MUSICVIDEOID, -1); selectedAlbumTitle = savedInstanceState.getString(ALBUMTITLE, null); selectedArtistName = savedInstanceState.getString(ARTISTNAME, null); selectedGenreTitle = savedInstanceState.getString(GENRETITLE, null); selectedMusicVideoTitle = savedInstanceState.getString(MUSICVIDEOTITLE, null); } setupActionBar(selectedAlbumTitle, selectedArtistName, selectedGenreTitle, selectedMusicVideoTitle); // // Setup system bars and content padding, allowing averlap with the bottom bar // setupSystemBarsColors(); // UIUtils.setPaddingForSystemBars(this, findViewById(R.id.fragment_container), true, true, true); // UIUtils.setPaddingForSystemBars(this, findViewById(R.id.drawer_layout), true, true, true); }
From source file:com.clemot.julian.easylib.EasyActivity.java
public FragmentTransaction addTransitions(FragmentTransaction fragmentTransaction, Fragment currentFragment, final Fragment nextFragment, Pair<View, String>... sharedElements) { if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { // Set shared and scene transitions //setSharedElementReturnTransition(TransitionInflater.from(getActivity()).inflateTransition(R.transition.trans_move)); //setExitTransition(TransitionInflater.from(getActivity()).inflateTransition(android.R.transition.explode)); //Exit Transition for the current Fragment currentFragment// ww w. ja v a2 s. co m .setExitTransition(TransitionInflater.from(this).inflateTransition(R.transition.trans_move)); //ReEnter Transition for the current Fragment currentFragment .setReenterTransition(TransitionInflater.from(this).inflateTransition(R.transition.trans_move)); nextFragment.setSharedElementReturnTransition( TransitionInflater.from(this).inflateTransition(R.transition.trans_move)); // Set shared and scene transitions on 2nd fragment nextFragment.setSharedElementEnterTransition( TransitionInflater.from(this).inflateTransition(R.transition.trans_move)); Transition transition = TransitionInflater.from(this).inflateTransition(android.R.transition.explode); transition.addListener(new Transition.TransitionListener() { @Override public void onTransitionStart(Transition transition) { ((EasyFragment) nextFragment).onTransitionStart(transition); } @Override public void onTransitionEnd(Transition transition) { ((EasyFragment) nextFragment).onTransitionEnd(transition); } @Override public void onTransitionCancel(Transition transition) { ((EasyFragment) nextFragment).onTransitionEnd(transition); } @Override public void onTransitionPause(Transition transition) { ((EasyFragment) nextFragment).onTransitionPause(transition); } @Override public void onTransitionResume(Transition transition) { ((EasyFragment) nextFragment).onTransitionResume(transition); } }); nextFragment.setEnterTransition(transition); //Return Transition for the next Fragment nextFragment.setReturnTransition( TransitionInflater.from(this).inflateTransition(android.R.transition.explode)); for (int i = 0; i < sharedElements.length; i++) { ViewCompat.setTransitionName(sharedElements[i].first, sharedElements[i].second); fragmentTransaction.addSharedElement(sharedElements[i].first, sharedElements[i].second); } } return fragmentTransaction; }
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 w w.j a v a 2 s . com 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:org.xbmc.kore.utils.SharedElementTransition.java
/** * Sets up the transition for the entering fragment * @param fragmentTransaction/*from w w w.j av a2s.co m*/ * @param fragment entering fragment * @param sharedElement must have the transition name set */ @TargetApi(21) public void setupEnterTransition(Context context, FragmentTransaction fragmentTransaction, final Fragment fragment, View sharedElement) { if (!(fragment instanceof SharedElement)) { LogUtils.LOGD(TAG, "Enter transition fragment must implement SharedElement interface"); return; } android.support.v4.app.SharedElementCallback seCallback = new android.support.v4.app.SharedElementCallback() { @Override public void onMapSharedElements(List<String> names, Map<String, View> sharedElements) { // On returning, onMapSharedElements for the exiting fragment is called before the onMapSharedElements // for the reentering fragment. We use this to determine if we are returning and if // we should clear the shared element lists. Note that, clearing must be done in the reentering fragment // as this is called last. Otherwise, the app will crash during transition setup. Not sure, but might // be a v4 support package bug. if (fragment.isVisible() && (!((SharedElement) fragment).isSharedElementVisible())) { // shared element not visible clearSharedElements = true; } } }; fragment.setEnterSharedElementCallback(seCallback); fragment.setEnterTransition(TransitionInflater.from(context).inflateTransition(R.transition.media_details)); fragment.setReturnTransition(null); Transition changeImageTransition = TransitionInflater.from(context) .inflateTransition(R.transition.change_image); fragment.setSharedElementReturnTransition(changeImageTransition); fragment.setSharedElementEnterTransition(changeImageTransition); fragmentTransaction.addSharedElement(sharedElement, sharedElement.getTransitionName()); }
From source file:com.saulmm.cui.OrderDialogFragment.java
@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); orderSelection = new OrderSelection(); selectedViewTransition = TransitionInflater.from(getContext()) .inflateTransition(R.transition.transition_selected_view); binding.setProduct(getProduct());/* www. j a va2 s . c o m*/ binding.imgProduct.setImageDrawable(createProductImageDrawable(getProduct())); binding.btnGo.setBackground(new ColorDrawable(ContextCompat.getColor(getContext(), getProduct().color))); initOrderStepOneView(binding.layoutStep1); }
From source file:us.phyxsi.gameshelf.ui.SearchActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_search); ButterKnife.bind(this); setupSearchView();/* w w w . j a v a2s . c o m*/ auto = TransitionInflater.from(this).inflateTransition(R.transition.auto); dataManager = new SearchDataManager(this) { @Override public void onDataLoaded(List<? extends Boardgame> data) { if (data != null && data.size() > 0) { if (results.getVisibility() != View.VISIBLE) { TransitionManager.beginDelayedTransition(container, auto); progress.setVisibility(View.GONE); results.setVisibility(View.VISIBLE); } adapter.addAndResort(data); } else { TransitionManager.beginDelayedTransition(container, auto); progress.setVisibility(View.GONE); setNoResultsVisibility(View.VISIBLE); } } }; adapter = new FeedAdapter(this, SearchActivity.this, dataManager, columns); results.setAdapter(adapter); GridLayoutManager layoutManager = new GridLayoutManager(this, columns); layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { @Override public int getSpanSize(int position) { return adapter.getItemColumnSpan(position); } }); results.setLayoutManager(layoutManager); results.setHasFixedSize(true); // extract the search icon's location passed from the launching activity, minus 4dp to // compensate for different paddings in the views searchBackDistanceX = getIntent().getIntExtra(EXTRA_MENU_LEFT, 0) - (int) TypedValue .applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4, getResources().getDisplayMetrics()); searchIconCenterX = getIntent().getIntExtra(EXTRA_MENU_CENTER_X, 0); // translate icon to match the launching screen then animate back into position searchBackContainer.setTranslationX(searchBackDistanceX); searchBackContainer.animate().translationX(0f).setDuration(650L) .setInterpolator(AnimationUtils.loadInterpolator(this, android.R.interpolator.fast_out_slow_in)); // transform from search icon to back icon AnimatedVectorDrawable searchToBack = (AnimatedVectorDrawable) ContextCompat.getDrawable(this, R.drawable.avd_search_to_back); searchBack.setImageDrawable(searchToBack); searchToBack.start(); // for some reason the animation doesn't always finish (leaving a part arrow!?) so after // the animation set a static drawable. Also animation callbacks weren't added until API23 // so using post delayed :( // TODO fix properly!! searchBack.postDelayed(new Runnable() { @Override public void run() { searchBack.setImageDrawable( ContextCompat.getDrawable(SearchActivity.this, R.drawable.ic_arrow_back_padded)); } }, 600L); // fade in the other search chrome searchBackground.animate().alpha(1f).setDuration(300L) .setInterpolator(AnimationUtils.loadInterpolator(this, android.R.interpolator.linear_out_slow_in)); searchView.animate().alpha(1f).setStartDelay(400L).setDuration(400L) .setInterpolator(AnimationUtils.loadInterpolator(this, android.R.interpolator.linear_out_slow_in)) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { searchView.requestFocus(); ImeUtils.showIme(searchView); } }); // animate in a scrim over the content behind scrim.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { @Override public boolean onPreDraw() { scrim.getViewTreeObserver().removeOnPreDrawListener(this); AnimatorSet showScrim = new AnimatorSet(); showScrim.playTogether( ViewAnimationUtils.createCircularReveal(scrim, searchIconCenterX, searchBackground.getBottom(), 0, (float) Math.hypot(searchBackDistanceX, scrim.getHeight() - searchBackground.getBottom())), ObjectAnimator.ofArgb(scrim, ViewUtils.BACKGROUND_COLOR, Color.TRANSPARENT, ContextCompat.getColor(SearchActivity.this, R.color.scrim))); showScrim.setDuration(400L); showScrim.setInterpolator(AnimationUtils.loadInterpolator(SearchActivity.this, android.R.interpolator.linear_out_slow_in)); showScrim.start(); return false; } }); onNewIntent(getIntent()); }