List of usage examples for android.transition TransitionInflater from
public static TransitionInflater from(Context context)
From source file:it.angelic.soulissclient.TagDetailActivity.java
public void showDetails(int pos) { Bundle bundle = new Bundle(); bundle.putInt("key", pos); List<SoulissTypical> typicalList = collected.getAssignedTypicals(); android.support.v4.app.FragmentManager manager = getSupportFragmentManager(); // Check what fragment is currently shown, replace if needed. Fragment details = manager.findFragmentById(R.id.detailPane); Fragment NewFrag = null;//from www . jav a2 s. co m // Istanzia e ci mette l'indice if (typicalList.get(pos).isSensor()) NewFrag = T5nSensorFragment.newInstance(pos, typicalList.get(pos)); else if (typicalList.get(pos) instanceof SoulissTypical16AdvancedRGB) NewFrag = T16RGBAdvancedFragment.newInstance(pos, typicalList.get(pos)); else if (typicalList.get(pos) instanceof SoulissTypical19AnalogChannel) NewFrag = T19SingleChannelLedFragment.newInstance(pos, typicalList.get(pos)); else if (typicalList.get(pos) instanceof SoulissTypical31Heating) NewFrag = T31HeatingFragment.newInstance(pos, typicalList.get(pos)); else if (typicalList.get(pos) instanceof SoulissTypical11DigitalOutput || typicalList.get(pos) instanceof SoulissTypical12DigitalOutputAuto) NewFrag = T1nGenericLightFragment.newInstance(pos, typicalList.get(pos)); else if (typicalList.get(pos) instanceof SoulissTypical41AntiTheft || typicalList.get(pos) instanceof SoulissTypical42AntiTheftPeer || typicalList.get(pos) instanceof SoulissTypical43AntiTheftLocalPeer) NewFrag = T4nFragment.newInstance(pos, typicalList.get(pos)); FragmentTransaction ft = manager.beginTransaction(); if (NewFrag != null) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { //details.setSharedElementReturnTransition(TransitionInflater.from(this).inflateTransition(android.R.transition.move)); //details.setExitTransition(TransitionInflater.from(this).inflateTransition(android.R.transition.fade)); // Create new fragment to add (Fragment B) // NewFrag.setSharedElementEnterTransition(TransitionInflater.from(this).inflateTransition(android.R.transition.move)); NewFrag.setEnterTransition( TransitionInflater.from(this).inflateTransition(android.R.transition.explode)); // Our shared element (in Fragment A) ImageView mProductImage = (ImageView) details.getView().findViewById(R.id.card_thumbnail_image2); TextView mProductText = (TextView) findViewById(R.id.TextViewTypicalsTitle); AppBarLayout.Behavior beh = new AppBarLayout.Behavior(); // Add Fragment B manager.beginTransaction().replace(R.id.detailPane, NewFrag).addToBackStack("transaction") .addSharedElement(mProductText, "hero_title").commit();//NOT WORK //.addSharedElement(mProductText, "ToolbarText"); } else { // if (opzioni.isAnimationsEnabled()) // ft.setCustomAnimations(R.anim.slide_in_right, R.anim.slide_out_left); ft.replace(R.id.detailPane, NewFrag); ft.addToBackStack(null); // ft.remove(details); //ft.add(NewFrag,"BOH"); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE); ft.commit(); } } else { Toast.makeText(getApplicationContext(), "No detail to show", Toast.LENGTH_SHORT).show(); } }
From source file:com.syncedsynapse.kore2.ui.MusicActivity.java
@TargetApi(21) public void onAlbumSelected(int albumId, String albumTitle) { selectedAlbumId = albumId;/*from w ww. j ava 2 s . co m*/ selectedAlbumTitle = albumTitle; // Replace list fragment AlbumDetailsFragment albumDetailsFragment = AlbumDetailsFragment.newInstance(albumId); FragmentTransaction fragTrans = getSupportFragmentManager().beginTransaction(); // Set up transitions if (Utils.isLollipopOrLater()) { albumDetailsFragment.setEnterTransition( TransitionInflater.from(this).inflateTransition(R.transition.media_details)); albumDetailsFragment.setReturnTransition(null); } else { fragTrans.setCustomAnimations(R.anim.fragment_details_enter, 0, R.anim.fragment_list_popenter, 0); } fragTrans.replace(R.id.fragment_container, albumDetailsFragment).addToBackStack(null).commit(); setupActionBar(albumTitle, null, null, null); }
From source file:com.amazon.android.utils.Helpers.java
/** * Handles the activity's enter fade transition. * * @param activity The activity./*from www .j a va 2s .c o m*/ * @param fadeDuration The fade duration in milliseconds. */ public static void handleActivityEnterFadeTransition(Activity activity, int fadeDuration) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Transition changeTransform = TransitionInflater.from(activity) .inflateTransition(R.transition.change_image_transform); Transition fadeTransform = TransitionInflater.from(activity) .inflateTransition(android.R.transition.fade); fadeTransform.setStartDelay(0); fadeTransform.setDuration(fadeDuration); activity.getWindow().setSharedElementEnterTransition(changeTransform); activity.getWindow().setEnterTransition(fadeTransform); } }
From source file:org.xbmc.kore.ui.MusicActivity.java
@TargetApi(21) public void onArtistSelected(ArtistListFragment.ViewHolder viewHolder) { selectedArtistId = viewHolder.artistId; selectedArtistName = viewHolder.artistName; // Replace list fragment final ArtistDetailsFragment artistDetailsFragment = ArtistDetailsFragment.newInstance(viewHolder); FragmentTransaction fragTrans = getSupportFragmentManager().beginTransaction(); // Setup animations if (Utils.isLollipopOrLater()) { android.support.v4.app.SharedElementCallback seCallback = new android.support.v4.app.SharedElementCallback() { @Override// w w w .j ava 2 s . co m public void onMapSharedElements(List<String> names, Map<String, View> sharedElements) { View sharedView = artistDetailsFragment.getSharedElement(); if (sharedView == null) { // shared element not visible clearSharedElements = true; } } }; artistDetailsFragment.setEnterSharedElementCallback(seCallback); artistDetailsFragment.setEnterTransition( TransitionInflater.from(this).inflateTransition(R.transition.media_details)); artistDetailsFragment.setReturnTransition(null); Transition changeImageTransition = TransitionInflater.from(this) .inflateTransition(R.transition.change_image); artistDetailsFragment.setSharedElementReturnTransition(changeImageTransition); artistDetailsFragment.setSharedElementEnterTransition(changeImageTransition); fragTrans.addSharedElement(viewHolder.artView, viewHolder.artView.getTransitionName()); } else { fragTrans.setCustomAnimations(R.anim.fragment_details_enter, 0, R.anim.fragment_list_popenter, 0); } fragTrans.replace(R.id.fragment_container, artistDetailsFragment).addToBackStack(null).commit(); navigationDrawerFragment.animateDrawerToggle(true); setupActionBar(null, selectedArtistName, null, null); }
From source file:com.syncedsynapse.kore2.ui.MusicActivity.java
@TargetApi(21) public void onMusicVideoSelected(int musicVideoId, String musicVideoTitle) { selectedMusicVideoId = musicVideoId; selectedMusicVideoTitle = musicVideoTitle; // Replace list fragment MusicVideoDetailsFragment detailsFragment = MusicVideoDetailsFragment.newInstance(musicVideoId); FragmentTransaction fragTrans = getSupportFragmentManager().beginTransaction(); // Set up transitions if (Utils.isLollipopOrLater()) { detailsFragment.setEnterTransition( TransitionInflater.from(this).inflateTransition(R.transition.media_details)); detailsFragment.setReturnTransition(null); } else {//w ww .j av a2 s.com fragTrans.setCustomAnimations(R.anim.fragment_details_enter, 0, R.anim.fragment_list_popenter, 0); } fragTrans.replace(R.id.fragment_container, detailsFragment).addToBackStack(null).commit(); setupActionBar(null, null, null, musicVideoTitle); }
From source file:org.xbmc.kore.ui.MusicActivity.java
@TargetApi(21) public void onAlbumSelected(AlbumListFragment.ViewHolder vh) { selectedAlbumId = vh.albumId;/* w w w .j ava2s . c o m*/ selectedAlbumTitle = vh.albumTitle; // Replace list fragment final AlbumDetailsFragment albumDetailsFragment = AlbumDetailsFragment.newInstance(vh); FragmentTransaction fragTrans = getSupportFragmentManager().beginTransaction(); // Set up transitions if (Utils.isLollipopOrLater()) { 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 it the app will crash during transition setup. Not sure, but might // be a v4 support package bug. if (albumDetailsFragment.isVisible()) { View sharedView = albumDetailsFragment.getSharedElement(); if (sharedView == null) { // shared element not visible clearSharedElements = true; } } } }; albumDetailsFragment.setEnterSharedElementCallback(seCallback); albumDetailsFragment.setEnterTransition( TransitionInflater.from(this).inflateTransition(R.transition.media_details)); albumDetailsFragment.setReturnTransition(null); Transition changeImageTransition = TransitionInflater.from(this) .inflateTransition(R.transition.change_image); albumDetailsFragment.setSharedElementReturnTransition(changeImageTransition); albumDetailsFragment.setSharedElementEnterTransition(changeImageTransition); fragTrans.addSharedElement(vh.artView, vh.artView.getTransitionName()); } else { fragTrans.setCustomAnimations(R.anim.fragment_details_enter, 0, R.anim.fragment_list_popenter, 0); } fragTrans.replace(R.id.fragment_container, albumDetailsFragment).addToBackStack(null).commit(); setupActionBar(selectedAlbumTitle, null, null, null); }
From source file:com.rks.musicx.misc.utils.Helper.java
/** * Fragment Transition//from w w w. java 2 s .co m * * @param activity * @param firstFragment * @param secondFragment */ @TargetApi(Build.VERSION_CODES.LOLLIPOP) public static void setFragmentTransition(MainActivity activity, Fragment firstFragment, Fragment secondFragment, View view, String name, String tag) { if (activity == null) { return; } FragmentManager fragmentManager = activity.getSupportFragmentManager(); boolean fragmentPopped = fragmentManager.popBackStackImmediate(tag, 0); if (fragmentPopped) { // fragment is pop from backStack } else { Transition transitionFade = TransitionInflater.from(activity) .inflateTransition(R.transition.change_image_transform); Transition transitionImage = TransitionInflater.from(activity) .inflateTransition(R.transition.change_image_transform); firstFragment.setSharedElementReturnTransition(transitionImage); firstFragment.setEnterTransition(transitionFade); firstFragment.setExitTransition(transitionFade); secondFragment.setSharedElementEnterTransition(transitionImage); secondFragment.setEnterTransition(transitionFade); secondFragment.setExitTransition(transitionFade); fragmentManager.beginTransaction().replace(R.id.container, secondFragment).addSharedElement(view, name) .addToBackStack(tag).commit(); } }
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 */// ww w .jav a 2s . c o m 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:org.xbmc.kore.ui.MusicActivity.java
@TargetApi(21) public void onMusicVideoSelected(MusicVideoListFragment.ViewHolder vh) { selectedMusicVideoId = vh.musicVideoId; selectedMusicVideoTitle = vh.musicVideoTitle; // Replace list fragment final MusicVideoDetailsFragment detailsFragment = MusicVideoDetailsFragment.newInstance(vh); FragmentTransaction fragTrans = getSupportFragmentManager().beginTransaction(); // Set up transitions if (Utils.isLollipopOrLater()) { android.support.v4.app.SharedElementCallback seCallback = new android.support.v4.app.SharedElementCallback() { @Override//from ww w .j a v a 2 s . com 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 it the app will crash during transition setup. Not sure, but might // be a v4 support package bug. if (detailsFragment.isVisible()) { View sharedView = detailsFragment.getSharedElement(); if (sharedView == null) { // shared element not visible LogUtils.LOGD(TAG, "onMusicVideoSelected: setting clearedSharedElements to true"); clearSharedElements = true; } } } }; detailsFragment.setEnterSharedElementCallback(seCallback); detailsFragment.setEnterTransition( TransitionInflater.from(this).inflateTransition(R.transition.media_details)); detailsFragment.setReturnTransition(null); Transition changeImageTransition = TransitionInflater.from(this) .inflateTransition(R.transition.change_image); detailsFragment.setSharedElementReturnTransition(changeImageTransition); detailsFragment.setSharedElementEnterTransition(changeImageTransition); fragTrans.addSharedElement(vh.artView, vh.artView.getTransitionName()); } else { fragTrans.setCustomAnimations(R.anim.fragment_details_enter, 0, R.anim.fragment_list_popenter, 0); } fragTrans.replace(R.id.fragment_container, detailsFragment).addToBackStack(null).commit(); setupActionBar(null, null, null, selectedMusicVideoTitle); }
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 www. j a va2s.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); }