本文整理匯總了Java中android.support.v4.app.Fragment.setSharedElementEnterTransition方法的典型用法代碼示例。如果您正苦於以下問題:Java Fragment.setSharedElementEnterTransition方法的具體用法?Java Fragment.setSharedElementEnterTransition怎麽用?Java Fragment.setSharedElementEnterTransition使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.support.v4.app.Fragment
的用法示例。
在下文中一共展示了Fragment.setSharedElementEnterTransition方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: navigateToAlbum
import android.support.v4.app.Fragment; //導入方法依賴的package包/類
@TargetApi(21)
public static void navigateToAlbum(Activity context, long albumID, Pair<View, String> transitionViews) {
FragmentTransaction transaction = ((AppCompatActivity) context).getSupportFragmentManager().beginTransaction();
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 = AlbumDetailFragment.newInstance(albumID, 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 = AlbumDetailFragment.newInstance(albumID, false, null);
}
transaction.hide(((AppCompatActivity) context).getSupportFragmentManager().findFragmentById(R.id.fragment_container));
transaction.add(R.id.fragment_container, fragment);
transaction.addToBackStack(null).commit();
}
示例2: navigateToArtist
import android.support.v4.app.Fragment; //導入方法依賴的package包/類
@TargetApi(21)
public static void navigateToArtist(Activity context, long artistID, Pair<View, String> transitionViews) {
FragmentTransaction transaction = ((AppCompatActivity) context).getSupportFragmentManager().beginTransaction();
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();
}
示例3: addSharedElement
import android.support.v4.app.Fragment; //導入方法依賴的package包/類
private Fragment addSharedElement(Fragment fragment) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
fragment.setSharedElementEnterTransition(new DetailTransition());
fragment.setEnterTransition(new Fade());
fragment.setSharedElementReturnTransition(new DetailTransition());
}
return fragment;
}
示例4: performTransition
import android.support.v4.app.Fragment; //導入方法依賴的package包/類
private void performTransition()
{
if (isDestroyed())
{
return;
}
Fragment previousFragment = mFragmentManager.findFragmentById(R.id.fragment_container);
Fragment nextFragment = Fragment2.newInstance();
FragmentTransaction fragmentTransaction = mFragmentManager.beginTransaction();
// 1. Exit for Previous Fragment
Fade exitFade = new Fade();
exitFade.setDuration(FADE_DEFAULT_TIME);
previousFragment.setExitTransition(exitFade);
// 2. Shared Elements Transition
TransitionSet enterTransitionSet = new TransitionSet();
enterTransitionSet.addTransition(TransitionInflater.from(this).inflateTransition(android.R.transition.move));
enterTransitionSet.setDuration(MOVE_DEFAULT_TIME);
enterTransitionSet.setStartDelay(FADE_DEFAULT_TIME);
nextFragment.setSharedElementEnterTransition(enterTransitionSet);
// 3. Enter Transition for New Fragment
Fade enterFade = new Fade();
enterFade.setStartDelay(MOVE_DEFAULT_TIME + FADE_DEFAULT_TIME);
enterFade.setDuration(FADE_DEFAULT_TIME);
nextFragment.setEnterTransition(enterFade);
View logo = ButterKnife.findById(this, R.id.fragment1_logo);
fragmentTransaction.addSharedElement(logo, logo.getTransitionName());
fragmentTransaction.replace(R.id.fragment_container, nextFragment);
fragmentTransaction.commitAllowingStateLoss();
}
示例5: setFragmentTransition
import android.support.v4.app.Fragment; //導入方法依賴的package包/類
/**
* Fragment Transition
*
* @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();
}
}
示例6: applyBeforeFragmentTransactionExecuted
import android.support.v4.app.Fragment; //導入方法依賴的package包/類
@Override
public void applyBeforeFragmentTransactionExecuted(FragmentTransaction transaction, Fragment enteringFragment, Fragment exitingFragment) {
enteringFragment.setEnterTransition(mEnterTransition);
exitingFragment.setExitTransition(mExitTransition);
enteringFragment.setSharedElementEnterTransition(mSharedElementTransition);
enteringFragment.setAllowEnterTransitionOverlap(mAllowEnterTransitionOverlap);
if (mSharedElements != null) {
for (Pair<View, String> sharedElement : mSharedElements) {
transaction.addSharedElement(sharedElement.first, sharedElement.second);
}
}
}
示例7: applyAfterFragmentTransactionExecuted
import android.support.v4.app.Fragment; //導入方法依賴的package包/類
@Override
public void applyAfterFragmentTransactionExecuted(Fragment enteringFragment, Fragment exitingFragment) {
enteringFragment.setEnterTransition(null);
exitingFragment.setExitTransition(null);
enteringFragment.setSharedElementEnterTransition(null);
enteringFragment.setAllowEnterTransitionOverlap(true);
}
示例8: showUserInfo
import android.support.v4.app.Fragment; //導入方法依賴的package包/類
@Override
public void showUserInfo() {
Fragment fragment = new UserInfoFragment();
Bundle bundle = new Bundle();
bundle.putLong(UserInfoFragment.ID_BUNDLE_KEY, CurrentUser.getInstance().getCurrentUserId());
bundle.putString(UserInfoFragment.EMAIL_BUNDLE_KEY, CurrentUser.getInstance().getCurrentEmail());
bundle.putString(UserInfoFragment.PHONE_BUNDLE_KEY, CurrentUser.getInstance().getPhone());
bundle.putString(UserInfoFragment.WEBSITE_BUNDLE_KEY, CurrentUser.getInstance().getWebsite());
bundle.putString(UserInfoFragment.FULL_NAME_BUNDLE_KEY, CurrentUser.getInstance().getFullName());
bundle.putParcelable(UserInfoFragment.AVATAR_BUNDLE_KEY, ((BitmapDrawable) drawerAvatar.getDrawable()).getBitmap());
fragment.setArguments(bundle);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
TransitionSet sharedElementTransition = (TransitionSet) TransitionInflater
.from(this)
.inflateTransition(R.transition.user_shared_element);
TransitionSet userInfoTransitionIn = (TransitionSet) TransitionInflater
.from(this)
.inflateTransition(R.transition.user_info_transition_in);
TransitionSet userInfoTransitionOut = (TransitionSet) TransitionInflater
.from(this)
.inflateTransition(R.transition.user_info_transition_out);
fragment.setSharedElementEnterTransition(sharedElementTransition);
fragment.setEnterTransition(userInfoTransitionIn);
fragment.setReturnTransition(userInfoTransitionOut);
fragment.setSharedElementReturnTransition(sharedElementTransition);
}
getSupportFragmentManager()
.beginTransaction()
.replace(R.id.main_screen_container, fragment)
.addSharedElement(drawerAvatar, getString(R.string.transition_user_avatar_name))
.addSharedElement(drawerLogin, getString(R.string.transition_user_full_name))
.addToBackStack(null)
.commit();
}
示例9: setupFragmentTransition
import android.support.v4.app.Fragment; //導入方法依賴的package包/類
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
private void setupFragmentTransition(Fragment fragment) {
final Transition move = TransitionInflater.from(this).inflateTransition(android.R.transition.move);
fragment.setSharedElementEnterTransition(move);
fragment.setExitTransition(new Slide(Gravity.END));
}
示例10: showUserInfo
import android.support.v4.app.Fragment; //導入方法依賴的package包/類
@Override
public void showUserInfo(UserModel user) {
Fragment fragment = new UserInfoFragment();
ImageView sharedImage = presenter.getAdapter().getClickedUserImage();
TextView textView = presenter.getAdapter().getClickedTextView();
Bundle bundle = new Bundle();
bundle.putLong(UserInfoFragment.ID_BUNDLE_KEY, user.getUserId());
bundle.putString(UserInfoFragment.EMAIL_BUNDLE_KEY, user.getEmail());
bundle.putString(UserInfoFragment.PHONE_BUNDLE_KEY, user.getPhone());
bundle.putString(UserInfoFragment.WEBSITE_BUNDLE_KEY, user.getWebsite());
bundle.putString(UserInfoFragment.FULL_NAME_BUNDLE_KEY, user.getFullName());
bundle.putParcelable(UserInfoFragment.AVATAR_BUNDLE_KEY, ((BitmapDrawable) sharedImage.getDrawable()).getBitmap());
fragment.setArguments(bundle);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
TransitionSet sharedElementTransition = (TransitionSet) TransitionInflater
.from(getActivity())
.inflateTransition(R.transition.user_shared_element);
TransitionSet userInfoTransitionIn = (TransitionSet) TransitionInflater
.from(getActivity())
.inflateTransition(R.transition.user_info_transition_in);
TransitionSet userInfoTransitionOut = (TransitionSet) TransitionInflater
.from(getActivity())
.inflateTransition(R.transition.user_info_transition_out);
TransitionSet usersTransitionIn = (TransitionSet) TransitionInflater
.from(getActivity())
.inflateTransition(R.transition.users_transition_in);
TransitionSet usersTransitionOut = (TransitionSet) TransitionInflater
.from(getActivity())
.inflateTransition(R.transition.users_transition_out);
fragment.setSharedElementEnterTransition(sharedElementTransition);
fragment.setEnterTransition(userInfoTransitionIn);
fragment.setReturnTransition(userInfoTransitionOut);
fragment.setSharedElementReturnTransition(sharedElementTransition);
setReenterTransition(usersTransitionIn);
setExitTransition(usersTransitionOut);
}
getActivity().getSupportFragmentManager()
.beginTransaction()
.replace(R.id.main_screen_container, fragment)
.addSharedElement(sharedImage, getString(R.string.transition_user_avatar_name))
.addSharedElement(textView, getString(R.string.transition_user_full_name))
.addToBackStack(null)
.commit();
}