List of usage examples for android.transition TransitionInflater inflateTransition
public Transition inflateTransition(@TransitionRes int resource)
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. */// www . j a v a2s. 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); final Transition sharedEnter = inflater.inflateTransition(R.transition.detail_enter); fragment.setSharedElementEnterTransition(sharedEnter); return fragment; }
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 w w . 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.andremion.louvre.home.GalleryActivity.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP) private void setupTransition() { TransitionInflater inflater = TransitionInflater.from(this); getWindow().setExitTransition(inflater.inflateTransition(R.transition.gallery_exit)); getWindow().setReenterTransition(inflater.inflateTransition(R.transition.gallery_reenter)); Transition sharedElementExitTransition = inflater.inflateTransition(R.transition.shared_element); // Listener to reset shared element exit transition callbacks. sharedElementExitTransition.addListener(mSharedElementExitListener); getWindow().setSharedElementExitTransition(sharedElementExitTransition); }
From source file:com.andremion.louvre.preview.PreviewActivity.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP) private void setupTransition() { TransitionInflater inflater = TransitionInflater.from(this); Transition sharedElementEnterTransition = inflater.inflateTransition(R.transition.shared_element); sharedElementEnterTransition.addListener(new TransitionCallback() { @Override/*from ww w. j av a 2s . co m*/ public void onTransitionEnd(Transition transition) { mAdapter.setDontAnimate(false); } }); getWindow().setSharedElementEnterTransition(sharedElementEnterTransition); }
From source file:us.phyxsi.gameshelf.ui.FeedAdapter.java
/** * The shared element transition to dribbble shots & dn stories can intersect with the FAB. * This can cause a strange layers-passing-through-each-other effect, especially on return. * In this situation, hide the FAB on exit and re-show it on return. *///from w w w . j a va 2 s.c om private void setGridItemContentTransitions(View gridItem) { if (host.findViewById(R.id.fab) == null) return; if (!ViewUtils.viewsIntersect(gridItem, host.findViewById(R.id.fab))) return; final TransitionInflater ti = TransitionInflater.from(host); host.getWindow().setExitTransition(ti.inflateTransition(R.transition.home_content_item_exit)); final Transition reenter = ti.inflateTransition(R.transition.home_content_item_reenter); // we only want this content transition in certain cases so clear it out after it's done. reenter.addListener(new AnimUtils.TransitionListenerAdapter() { @Override public void onTransitionEnd(Transition transition) { host.getWindow().setExitTransition(null); host.getWindow().setReenterTransition(null); } }); host.getWindow().setReenterTransition(reenter); }
From source file:de.unipassau.isl.evs.ssh.app.activity.AppMainActivity.java
/** * Displays a fragment and takes care of lifecycle actions like saving state when rotating the * screen or managing the back button behavior. * * @param clazz the class of the fragment to show * @param bundle the bundle that is given with the new fragment *//*from ww w .ja v a2 s . c om*/ public void showFragmentByClass(Class clazz, Bundle bundle) { Class classToShow = clazz; final boolean isRegistered = isRegistered(); final Permission permission = permissionForFragment.get(classToShow); if (permission != null && !hasPermission(permission) && isRegistered) { Toast.makeText(this, String.format(getString(R.string.fragment_access_denied), permission.toLocalizedString(this)), Toast.LENGTH_SHORT).show(); return; } final Fragment currentFragment = getCurrentFragment(); if (currentFragment != null && Objects.equals(classToShow, currentFragment.getClass())) { return; } // avoid leaving the welcome fragment before registration if (!isRegistered) { classToShow = WelcomeScreenFragment.class; } final Fragment fragment; try { fragment = (Fragment) classToShow.newInstance(); if (bundle != null) { fragment.setArguments(bundle); } } catch (InstantiationException | IllegalAccessException e) { Log.wtf(TAG, "Could not instantiate fragment", e); return; } // Hide Keyboard before every fragment transaction View view = getCurrentFocus(); if (view != null) { InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(view.getWindowToken(), 0); } FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.replace(R.id.fragment_container, fragment); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (currentFragment instanceof MainFragment && fragment instanceof HolidayFragment) { View fragmentView = currentFragment.getView(); if (fragmentView != null) { transaction.addSharedElement(fragmentView.findViewById(R.id.holidayButton), "holidayIconTransition"); } final TransitionInflater inflater = TransitionInflater.from(this); currentFragment.setSharedElementReturnTransition( inflater.inflateTransition(R.transition.change_image_trans)); currentFragment.setExitTransition(inflater.inflateTransition(android.R.transition.explode)); fragment.setSharedElementEnterTransition( inflater.inflateTransition(R.transition.change_image_trans)); fragment.setEnterTransition(inflater.inflateTransition(android.R.transition.explode)); } else if (fragment instanceof MainFragment && currentFragment != null) { transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE); } else { transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); } } transaction.commit(); }
From source file:io.plaidapp.ui.FeedAdapter.java
/** * The shared element transition to dribbble shots & dn stories can intersect with the FAB. * This can cause a strange layers-passing-through-each-other effect, especially on return. * In this situation, hide the FAB on exit and re-show it on return. *///www . j a v a2s . c om private void setGridItemContentTransitions(View gridItem) { if (!ViewUtils.viewsIntersect(gridItem, host.findViewById(R.id.fab))) return; final TransitionInflater ti = TransitionInflater.from(host); host.getWindow().setExitTransition(ti.inflateTransition(R.transition.home_content_item_exit)); final Transition reenter = ti.inflateTransition(R.transition.home_content_item_reenter); // we only want this content transition in certain cases so clear it out after it's done. reenter.addListener(new AnimUtils.TransitionListenerAdapter() { @Override public void onTransitionEnd(Transition transition) { host.getWindow().setExitTransition(null); host.getWindow().setReenterTransition(null); } }); host.getWindow().setReenterTransition(reenter); }
From source file:android.app.FragmentState.java
private static Transition loadTransition(Context context, TypedArray typedArray, Transition currentValue, Transition defaultValue, int id) { if (currentValue != defaultValue) { return currentValue; }//from w ww . j a va2 s . co m int transitionId = typedArray.getResourceId(id, 0); Transition transition = defaultValue; if (transitionId != 0 && transitionId != com.android.internal.R.transition.no_transition) { TransitionInflater inflater = TransitionInflater.from(context); transition = inflater.inflateTransition(transitionId); if (transition instanceof TransitionSet && ((TransitionSet) transition).getTransitionCount() == 0) { transition = null; } } return transition; }