List of usage examples for android.transition TransitionInflater from
public static TransitionInflater from(Context context)
From source file:com.bluros.music.utils.NavigationUtils.java
@TargetApi(21) public static void navigateToArtist(Activity context, long artistID, Pair<View, String> transitionViews) { FragmentTransaction transaction = ((AppCompatActivity) context).getSupportFragmentManager() .beginTransaction();//from ww w. java 2 s.c o m Fragment fragment; if (MusicUtils.isLollipop() && transitionViews != null && PreferencesUtility.getInstance(context).getAnimations()) { Transition changeImage = TransitionInflater.from(context) .inflateTransition(R.transition.image_transform); transaction.addSharedElement(transitionViews.first, transitionViews.second); fragment = ArtistDetailFragment.newInstance(artistID, true, transitionViews.second); fragment.setSharedElementEnterTransition(changeImage); } else { transaction.setCustomAnimations(R.anim.activity_fade_in, R.anim.activity_fade_out, R.anim.activity_fade_in, R.anim.activity_fade_out); fragment = ArtistDetailFragment.newInstance(artistID, false, null); } transaction.hide(((AppCompatActivity) context).getSupportFragmentManager() .findFragmentById(R.id.fragment_container)); transaction.add(R.id.fragment_container, fragment); transaction.addToBackStack(null).commit(); }
From source file:com.massivedisaster.activitymanager.FragmentTransaction.java
/** * FragmentTransaction constructor, created to be used by an activity. * * @param activity The activity to be used to add the new fragment. * @param fragmentClass The Fragment to be injected in the activityClass. *//* w w w . jav a 2s. c om*/ @SuppressLint("CommitTransaction") FragmentTransaction(AbstractFragmentActivity activity, Class<? extends Fragment> fragmentClass) { mActivity = activity; mFrgTransaction = mActivity.getSupportFragmentManager().beginTransaction(); try { mFragment = fragmentClass.newInstance(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { mFragment.setSharedElementEnterTransition( TransitionInflater.from(mActivity).inflateTransition(android.R.transition.move)); mFragment.setSharedElementReturnTransition( TransitionInflater.from(mActivity).inflateTransition(android.R.transition.move)); } } catch (InstantiationException e) { Log.e(ActivityFragmentManager.class.getCanonicalName(), e.toString()); } catch (IllegalAccessException e) { Log.e(ActivityFragmentManager.class.getCanonicalName(), e.toString()); } }
From source file:com.melkir.ourstreets.fragment.DetailFragment.java
/** * Create a new instance with details for a given {@link Gallery}. * * @param context The context this runs in. * @param gallery The gallery of which the details should be displayed. * @return A newly instantiated fragment. *//*w ww .j a v a 2 s. c om*/ public static DetailFragment newInstance(@NonNull Context context, @NonNull Gallery gallery, @NonNull CameraPosition cameraPosition) { DetailFragment fragment = new DetailFragment(); Bundle args = new Bundle(); args.putParcelable(IntentKeys.GALLERY, gallery); args.putParcelable(IntentKeys.CAMERA_POSITION, cameraPosition); fragment.setArguments(args); final TransitionInflater inflater = TransitionInflater.from(context); fragment.setSharedElementEnterTransition(inflater.inflateTransition(R.transition.detail_shared_enter)); fragment.setEnterTransition(new Fade()); return fragment; }
From source file:com.syncedsynapse.kore2.ui.AddonsActivity.java
@TargetApi(21) @Override//from w w w.j av a 2 s . c o m protected void onCreate(Bundle savedInstanceState) { // Request transitions on lollipop if (Utils.isLollipopOrLater()) { getWindow().requestFeature(Window.FEATURE_CONTENT_TRANSITIONS); } 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) { AddonListFragment addonListFragment = new AddonListFragment(); // Setup animations if (Utils.isLollipopOrLater()) { addonListFragment.setExitTransition(null); addonListFragment.setReenterTransition( TransitionInflater.from(this).inflateTransition(android.R.transition.fade)); } getSupportFragmentManager().beginTransaction().add(R.id.fragment_container, addonListFragment).commit(); } else { selectedAddonId = savedInstanceState.getString(ADDONID, null); selectedAddonTitle = savedInstanceState.getString(ADDONTITLE, null); } setupActionBar(selectedAddonTitle); }
From source file:com.syncedsynapse.kore2.ui.MoviesActivity.java
@TargetApi(21) @Override/*from w w w. ja v a 2 s . c o m*/ protected void onCreate(Bundle savedInstanceState) { // Request transitions on lollipop if (Utils.isLollipopOrLater()) { getWindow().requestFeature(Window.FEATURE_CONTENT_TRANSITIONS); } 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) { MovieListFragment movieListFragment = new MovieListFragment(); // Setup animations if (Utils.isLollipopOrLater()) { movieListFragment.setExitTransition(null); movieListFragment.setReenterTransition( TransitionInflater.from(this).inflateTransition(android.R.transition.fade)); } getSupportFragmentManager().beginTransaction().add(R.id.fragment_container, movieListFragment).commit(); } else { selectedMovieId = savedInstanceState.getInt(MOVIEID, -1); selectedMovieTitle = savedInstanceState.getString(MOVIETITLE, null); } setupActionBar(selectedMovieTitle); }
From source file:com.techmighty.baseplayer.utils.NavigationUtils.java
@TargetApi(21) public static void navigateToArtist(Activity context, long artistID, Pair<View, String> transitionViews) { FragmentTransaction transaction = ((AppCompatActivity) context).getSupportFragmentManager() .beginTransaction();//from www . jav a2s. c om Fragment fragment; if (BasePlayerUtils.isLollipop() && transitionViews != null && PreferencesUtility.getInstance(context).getAnimations()) { Transition changeImage = TransitionInflater.from(context) .inflateTransition(R.transition.image_transform); transaction.addSharedElement(transitionViews.first, transitionViews.second); fragment = ArtistDetailFragment.newInstance(artistID, true, transitionViews.second); fragment.setSharedElementEnterTransition(changeImage); } else { transaction.setCustomAnimations(R.anim.activity_fade_in, R.anim.activity_fade_out, R.anim.activity_fade_in, R.anim.activity_fade_out); fragment = ArtistDetailFragment.newInstance(artistID, false, null); } transaction.hide(((AppCompatActivity) context).getSupportFragmentManager() .findFragmentById(R.id.fragment_container)); transaction.add(R.id.fragment_container, fragment); transaction.addToBackStack(null).commit(); }
From source file:com.devalladolid.musictoday.utils.NavigationUtils.java
@TargetApi(21) public static void navigateToArtist(Activity context, long artistID, Pair<View, String> transitionViews) { FragmentTransaction transaction = ((AppCompatActivity) context).getSupportFragmentManager() .beginTransaction();// w w w . j a v a2 s . co m Fragment fragment; if (TimberUtils.isLollipop() && transitionViews != null && PreferencesUtility.getInstance(context).getAnimations()) { Transition changeImage = TransitionInflater.from(context) .inflateTransition(R.transition.image_transform); transaction.addSharedElement(transitionViews.first, transitionViews.second); fragment = ArtistDetailFragment.newInstance(artistID, true, transitionViews.second); fragment.setSharedElementEnterTransition(changeImage); } else { transaction.setCustomAnimations(R.anim.activity_fade_in, R.anim.activity_fade_out, R.anim.activity_fade_in, R.anim.activity_fade_out); fragment = ArtistDetailFragment.newInstance(artistID, false, null); } transaction.hide(((AppCompatActivity) context).getSupportFragmentManager() .findFragmentById(R.id.fragment_container)); transaction.add(R.id.fragment_container, fragment); transaction.addToBackStack(null).commit(); }
From source file:com.google.samples.apps.ourstreets.fragment.DetailFragment.java
/** * Create a new instance with details for a given {@link Gallery}. * * @param context The context this runs in. * @param gallery The gallery of which the details should be displayed. * @return A newly instantiated fragment. *//*from w w w . j a va 2 s . co m*/ public static DetailFragment newInstance(@NonNull Context context, @NonNull Gallery gallery, @NonNull CameraPosition cameraPosition) { DetailFragment fragment = new DetailFragment(); Bundle args = new Bundle(); args.putParcelable(IntentKeys.GALLERY, gallery); args.putParcelable(IntentKeys.CAMERA_POSITION, cameraPosition); fragment.setArguments(args); final TransitionInflater inflater = TransitionInflater.from(context); final Transition sharedEnter = inflater.inflateTransition(R.transition.detail_enter); fragment.setSharedElementEnterTransition(sharedEnter); return fragment; }
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;//w ww . j a v a 2s . c om }
From source file:com.ravi.apps.android.newsbytes.DetailsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Set the content view. setContentView(R.layout.activity_details); // Get the toolbar and set it as the action bar. mToolbar = (Toolbar) findViewById(R.id.tool_bar); setSupportActionBar(mToolbar);/*from w w w. j av a 2 s. c om*/ // Enable the up button on the toolbar. getSupportActionBar().setDisplayHomeAsUpEnabled(true); if (savedInstanceState == null) { // Extract extras from intent. Bundle bundle = getIntent().getExtras(); // Create the details fragment object. DetailsFragment detailsFragment = new DetailsFragment(); // Set arguments containing news details. detailsFragment.setArguments(bundle); // Shared element transition - check if device is running on lollipop or above // and if the transition names for the shared element transition are available. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && bundle.containsKey(HeadlinesAdapter.THUMBNAIL_TRANSITION_NAME) && bundle.containsKey(HeadlinesAdapter.HEADLINE_TRANSITION_NAME)) { // Create the starting views for the shared element transition. createTransitionStartViews(bundle); // Set the shared element transition. detailsFragment.setSharedElementEnterTransition( TransitionInflater.from(this).inflateTransition(R.transition.change_image_transform)); detailsFragment.setEnterTransition( TransitionInflater.from(this).inflateTransition(android.R.transition.fade)); // Set the transition names. ViewCompat.setTransitionName(mThumbnailView, bundle.getString(HeadlinesAdapter.THUMBNAIL_TRANSITION_NAME)); ViewCompat.setTransitionName(mHeadlineView, bundle.getString(HeadlinesAdapter.HEADLINE_TRANSITION_NAME)); // Add the fragment onto the container. getFragmentManager().beginTransaction() .replace(R.id.news_details_container, detailsFragment, DetailsFragment.DETAILS_FRAGMENT_TAG) .addSharedElement(mThumbnailView, bundle.getString(HeadlinesAdapter.THUMBNAIL_TRANSITION_NAME)) .addSharedElement(mHeadlineView, bundle.getString(HeadlinesAdapter.HEADLINE_TRANSITION_NAME)) .commit(); } else { // Add the fragment onto the container. getFragmentManager().beginTransaction() .setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out, android.R.animator.fade_in, android.R.animator.fade_out) .add(R.id.news_details_container, detailsFragment, DetailsFragment.DETAILS_FRAGMENT_TAG) .commit(); } } }