android.transition.TransitionInflater Java Examples
The following examples show how to use
android.transition.TransitionInflater.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DetailActivity.java From Android-Developer-Fundamentals-Version-2 with GNU General Public License v3.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_detail); TextView sportsTitle = findViewById(R.id.titleDetail); ImageView sportsImage = findViewById(R.id.sportsImageDetail); TextView sportsDetail = findViewById(R.id.subTitleDetail); getWindow().setSharedElementEnterTransition(TransitionInflater.from(this).inflateTransition(R.transition.shared_element)); Intent intent = getIntent(); String titleString = intent.getStringExtra("title"); int imageInt = intent.getIntExtra("image_resource", 0); String details = intent.getStringExtra("details"); sportsTitle.setText(titleString); Glide.with(this).load(imageInt).into(sportsImage); sportsDetail.setText(details); }
Example #2
Source File: SampleTransitionAnimationProvider.java From Alligator with MIT License | 6 votes |
@SuppressLint("RtlHardcoded") private TransitionAnimation createSlideAnimation(boolean forward, AnimationData animationData) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Transition enterTransition = forward ? new Slide(Gravity.RIGHT) : new Slide(Gravity.LEFT); Transition exitTransition = forward ? new Slide(Gravity.LEFT) : new Slide(Gravity.RIGHT); LollipopTransitionAnimation animation = new LollipopTransitionAnimation(enterTransition, exitTransition); animation.setAllowEnterTransitionOverlap(false); Fragment currentFragment = mActivity.getSupportFragmentManager().findFragmentById(R.id.fragment_container); if (currentFragment instanceof SharedElementProvider) { SharedElementProvider sharedElementProvider = (SharedElementProvider) currentFragment; View sharedElement = sharedElementProvider.getSharedElement(animationData); String shareElementName = sharedElementProvider.getSharedElementName(animationData); animation.addSharedElement(sharedElement, shareElementName); Transition moveTransition = TransitionInflater.from(mActivity).inflateTransition(android.R.transition.move); moveTransition.setDuration(600); animation.setSharedElementTransition(moveTransition); } return animation; } else { int enterAnimRes = forward ? R.anim.slide_in_right : R.anim.slide_in_left; int exitAnimRes = forward ? R.anim.slide_out_left : R.anim.slide_out_right; return new SimpleTransitionAnimation(enterAnimRes, exitAnimRes); } }
Example #3
Source File: NavigationUtils.java From Muzesto with GNU General Public License v3.0 | 6 votes |
@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(); }
Example #4
Source File: ContentActivity.java From ticdesign with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_content); ButterKnife.bind(this); if (getIntent() != null) { int avatar = getIntent().getIntExtra(getString(R.string.transition_shared_avatar), 0); String title = getIntent().getStringExtra(getString(R.string.transition_shared_title)); if (avatar > 0) { imageAvatar.setImageResource(avatar); colorize(((BitmapDrawable) imageAvatar.getDrawable()).getBitmap()); } if (title != null) { textTitle.setText(title); } Transition transition = TransitionInflater.from(this).inflateTransition(R.transition.slide_bottom); getWindow().setEnterTransition(transition); } }
Example #5
Source File: OrderDialogFragment.java From From-design-to-Android-part1 with Apache License 2.0 | 6 votes |
@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()); binding.imgProduct.setImageDrawable(createProductImageDrawable(getProduct())); binding.btnGo.setBackground(new ColorDrawable(ContextCompat.getColor( getContext(), getProduct().color))); initOrderStepOneView(binding.layoutStep1); }
Example #6
Source File: AboutActivity.java From android-proguards with Apache License 2.0 | 6 votes |
@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); 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(); } }); }
Example #7
Source File: NavigationUtils.java From Muzesto with GNU General Public License v3.0 | 6 votes |
@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(); }
Example #8
Source File: FragmentSelect.java From imageres_resolution with MIT License | 6 votes |
private void switchToPreview(Uri uri) { Fragment fragment = FragmentPreview.instance(uri); if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) { int duration = getResources().getInteger(android.R.integer.config_mediumAnimTime); Slide slideTransition = new Slide(Gravity.LEFT); slideTransition.setDuration(duration); setExitTransition(slideTransition); Slide slideTransition2 = new Slide(Gravity.RIGHT); slideTransition2.setDuration(duration); fragment.setEnterTransition(slideTransition2); TransitionInflater inflater = TransitionInflater.from(getContext()); Transition transition = inflater.inflateTransition(R.transition.transition_default); fragment.setSharedElementEnterTransition(transition); } getFragmentManager() .beginTransaction() .replace(R.id.frg_docker, fragment) .addSharedElement(mBtnFindWrapper, ViewCompat.getTransitionName(mBtnFindWrapper)) .addToBackStack("select") .commitAllowingStateLoss(); }
Example #9
Source File: DetailsFragment.java From mosby with Apache License 2.0 | 6 votes |
@TargetApi(21) private void initTransitions() { Window window = getActivity().getWindow(); window.setEnterTransition( new ExplodeFadeEnterTransition(senderNameView, senderMailView, separatorLine)); window.setExitTransition(new ExcludedExplodeTransition()); window.setReenterTransition(new ExcludedExplodeTransition()); window.setReturnTransition(new ExcludedExplodeTransition()); TransitionSet textSizeSet = new TransitionSet(); textSizeSet.addTransition( TransitionInflater.from(getActivity()).inflateTransition(android.R.transition.move)); TextSizeTransition textSizeTransition = new TextSizeTransition(); textSizeTransition.addTarget(R.id.subject); textSizeTransition.addTarget(getString(R.string.shared_mail_subject)); textSizeSet.addTransition(textSizeTransition); textSizeSet.setOrdering(TransitionSet.ORDERING_TOGETHER); window.setSharedElementEnterTransition(textSizeSet); getActivity().setEnterSharedElementCallback( new TextSizeEnterSharedElementCallback(getActivity())); }
Example #10
Source File: ImageFFActivity.java From ChatView with MIT License | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if(getSupportActionBar()!=null) { getSupportActionBar().hide(); } getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.activity_image_ff); photoView = findViewById(R.id.photoView); Picasso.with(getApplicationContext()).load(getIntent().getStringExtra("photoURI")).into(photoView); getWindow().setSharedElementEnterTransition(TransitionInflater.from(this).inflateTransition(R.transition.image_transition)); photoView.setTransitionName("photoTransition"); }
Example #11
Source File: OverviewStaggeredGridFragment.java From Easy_xkcd with Apache License 2.0 | 6 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { setupVariables(); View v = inflater.inflate(R.layout.recycler_layout, container, false); rv = v.findViewById(R.id.rv); rv.setHasFixedSize(true); rv.setFastScrollEnabled(false); setupAdapter(); if (savedInstanceState == null) { animateToolbar(); postponeEnterTransition(); } setSharedElementEnterTransition(TransitionInflater.from(getContext()).inflateTransition(R.transition.image_shared_element_transition)); return v; }
Example #12
Source File: DetailActivity.java From Android-Developer-Fundamentals-Version-2 with GNU General Public License v3.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_detail); TextView sportsTitle = findViewById(R.id.titleDetail); ImageView sportsImage = findViewById(R.id.sportsImageDetail); TextView sportsDetail = findViewById(R.id.subTitleDetail); getWindow().setSharedElementEnterTransition(TransitionInflater.from(this).inflateTransition(R.transition.shared_element)); Intent intent = getIntent(); String titleString = intent.getStringExtra("title"); int imageInt = intent.getIntExtra("image_resource", 0); String details = intent.getStringExtra("details"); sportsTitle.setText(titleString); Glide.with(this).load(imageInt).into(sportsImage); sportsDetail.setText(details); }
Example #13
Source File: DetailActivity.java From Android-Developer-Fundamentals-Version-2 with GNU General Public License v3.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_detail); TextView sportsTitle = findViewById(R.id.titleDetail); ImageView sportsImage = findViewById(R.id.sportsImageDetail); TextView sportsDetail = findViewById(R.id.subTitleDetail); getWindow().setSharedElementEnterTransition(TransitionInflater.from(this).inflateTransition(R.transition.shared_element)); Intent intent = getIntent(); String titleString = intent.getStringExtra("title"); int imageInt = intent.getIntExtra("image_resource", 0); String details = intent.getStringExtra("details"); sportsTitle.setText(titleString); Glide.with(this).load(imageInt).into(sportsImage); sportsDetail.setText(details); }
Example #14
Source File: OverviewListFragment.java From Easy_xkcd with Apache License 2.0 | 6 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { setupVariables(); View v = inflater.inflate(R.layout.overview_list, container, false); list = (ListView) v.findViewById(R.id.list); list.setFastScrollEnabled(true); setupAdapter(); if (savedInstanceState == null) { animateToolbar(); postponeEnterTransition(); } setEnterTransition(new Slide(Gravity.LEFT)); setSharedElementEnterTransition(TransitionInflater.from(getContext()).inflateTransition(R.transition.image_shared_element_transition)); return v; }
Example #15
Source File: OverviewCardsFragment.java From Easy_xkcd with Apache License 2.0 | 6 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { setupVariables(); View v = inflater.inflate(R.layout.recycler_layout, container, false); rv = v.findViewById(R.id.rv); rv.setLayoutManager(new LinearLayoutManager(getActivity())); rv.setHasFixedSize(true); rv.setVerticalScrollBarEnabled(false); setupAdapter(); if (savedInstanceState == null) { animateToolbar(); postponeEnterTransition(); } setSharedElementEnterTransition(TransitionInflater.from(getContext()).inflateTransition(R.transition.image_shared_element_transition)); return v; }
Example #16
Source File: SwitchAnimActivity.java From AndroidAnimationExercise with Apache License 2.0 | 6 votes |
@Override public void onClick(View v) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { switch (v.getId()) { case R.id.exlpode: transition = TransitionInflater.from(this).inflateTransition(R.transition.explode); break; case R.id.slide: transition = TransitionInflater.from(this).inflateTransition(R.transition.slide); break; default: break; } //退出时使用 getWindow().setExitTransition(transition); //第一次进入时使用 getWindow().setEnterTransition(transition); //再次进入时使用 getWindow().setReenterTransition(transition); Bundle bundle = ActivityOptions.makeSceneTransitionAnimation(this).toBundle(); Intent intent = new Intent(mContext, TweenedAnimationActivity.class); startActivity(intent,bundle); } }
Example #17
Source File: SharedElementTransition.java From Kore with Apache License 2.0 | 6 votes |
/** * Sets up the transition for the exiting fragment * @param fragment */ @TargetApi(21) public void setupExitTransition(Context context, Fragment fragment) { Transition fade = TransitionInflater .from(context) .inflateTransition(android.R.transition.fade); fragment.setExitTransition(fade); fragment.setReenterTransition(fade); fragment.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; } } }); }
Example #18
Source File: Fragment.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
private static Transition loadTransition(Context context, TypedArray typedArray, Transition currentValue, Transition defaultValue, int id) { if (currentValue != defaultValue) { return currentValue; } 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; }
Example #19
Source File: TVShowsActivity.java From Kore with Apache License 2.0 | 6 votes |
@TargetApi(21) private void startFragment(AbstractFragment fragment) { // Replace list fragment FragmentTransaction fragTrans = getSupportFragmentManager().beginTransaction(); // Set up transitions if (Utils.isLollipopOrLater()) { fragment.setEnterTransition( TransitionInflater.from(this).inflateTransition(R.transition.media_details)); fragment.setReturnTransition(null); } else { fragTrans.setCustomAnimations(R.anim.fragment_details_enter, 0, R.anim.fragment_list_popenter, 0); } fragTrans.replace(R.id.fragment_container, fragment) .addToBackStack(null) .commit(); }
Example #20
Source File: GridFragment.java From animation-samples with Apache License 2.0 | 6 votes |
/** * Prepares the shared element transition to the pager fragment, as well as the other transitions * that affect the flow. */ private void prepareTransitions() { setExitTransition(TransitionInflater.from(getContext()) .inflateTransition(R.transition.grid_exit_transition)); // A similar mapping is set at the ImagePagerFragment with a setEnterSharedElementCallback. setExitSharedElementCallback( new SharedElementCallback() { @Override public void onMapSharedElements(List<String> names, Map<String, View> sharedElements) { // Locate the ViewHolder for the clicked position. RecyclerView.ViewHolder selectedViewHolder = recyclerView .findViewHolderForAdapterPosition(MainActivity.currentPosition); if (selectedViewHolder == null) { return; } // Map the first shared element name to the child ImageView. sharedElements .put(names.get(0), selectedViewHolder.itemView.findViewById(R.id.card_image)); } }); }
Example #21
Source File: FileChooserActivity.java From Mp3Cutter with GNU General Public License v3.0 | 5 votes |
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { android.transition.Transition transition = TransitionInflater.from(this).inflateTransition(R.transition.explode); getWindow().setEnterTransition(transition); } StatusBarUtil.setColor(this, Color.TRANSPARENT); mDataBinding.btnUpdate.setOnClickListener(this); mDataBinding.btnUpdate.measure(0, 0); mUpdateBtnLeft = ScreenUtils.getScreenSize(this)[0] - mDataBinding.btnUpdate.getMeasuredWidth() - DensityUtils.dp2px(this ,10); initToolbar(); mDataBinding.rlMusice.setLayoutManager(new LinearLayoutManager(this)); mAdapter = new CommonAdapter<MusicInfo>(this, R.layout.item_musicfile, mMusicList) { @Override protected void convert(ViewHolder holder, final MusicInfo musicInfo, int position) { holder.setText(R.id.tv_name, musicInfo.getTitle()); holder.setText(R.id.tv_size, FileUtils.formetFileSize(musicInfo.getFileSize())); if(TextUtils.isEmpty(musicInfo.getCoverPath())){ holder.setImageDrawable(R.id.iv_icon, getResources().getDrawable(R.mipmap.music_icon)); } else { RequestOptions options = new RequestOptions().placeholder(R.mipmap.music_icon); Glide.with(FileChooserActivity.this).load(musicInfo.getCoverPath()) .apply(options).into((ImageView) holder.getView(R.id.iv_icon)); } // holder.setImageBitmap(R.id.iv_icon, CoverLoader.getInstance().loadThumbnail(musicInfo)); holder.itemView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { clickItem(musicInfo); } }); } }; mDataBinding.rlMusice.setAdapter(mAdapter); mDataBinding.rlMusice.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL)); FileChooserActivityPermissionsDispatcher.refreshDataWithPermissionCheck(this, false); }
Example #22
Source File: SplashActivity.java From Saude-no-Mapa with MIT License | 5 votes |
@SuppressLint("NewApi") private void setupWindowAnimations() { Transition slideLeft = TransitionInflater.from(this).inflateTransition(android.R.transition.fade); Transition slideRight = TransitionInflater.from(this).inflateTransition(android.R.transition.fade); getWindow().setExitTransition(slideLeft); getWindow().setEnterTransition(slideRight); getWindow().setBackgroundDrawable(new ColorDrawable(Color.parseColor("#793A37"))); }
Example #23
Source File: BaseActivity.java From Saude-no-Mapa with MIT License | 5 votes |
@SuppressLint("NewApi") private void setupWindowAnimations() { Transition slideLeft = TransitionInflater.from(this).inflateTransition(android.R.transition.slide_left); Transition slideRight = TransitionInflater.from(this).inflateTransition(android.R.transition.slide_right); getWindow().setExitTransition(slideLeft); getWindow().setEnterTransition(slideRight); getWindow().setBackgroundDrawable(new ColorDrawable(Color.DKGRAY)); }
Example #24
Source File: CategorySelectionActivity.java From CoolSignIn with Apache License 2.0 | 5 votes |
@SuppressLint("NewApi") private void signOut() { AsyncHttpHelper.clearAllCookies(); PreferencesHelper.signOut(this); if (ApiLevelHelper.isAtLeast(Build.VERSION_CODES.LOLLIPOP)) { getWindow().setExitTransition(TransitionInflater.from(this) .inflateTransition(R.transition.category_enter)); } SignInActivity.start(this, false); ActivityCompat.finishAfterTransition(this); }
Example #25
Source File: WalkthroughActivity.java From Saude-no-Mapa with MIT License | 5 votes |
@SuppressLint("NewApi") private void setupWindowAnimations() { Transition slideLeft = TransitionInflater.from(this).inflateTransition(android.R.transition.slide_left); Transition slideRight = TransitionInflater.from(this).inflateTransition(android.R.transition.slide_right); getWindow().setExitTransition(slideLeft); getWindow().setEnterTransition(slideRight); getWindow().setBackgroundDrawable(new ColorDrawable(Color.WHITE)); }
Example #26
Source File: CategoryFragment.java From openshop.io-android with MIT License | 5 votes |
private void prepareRecyclerAdapter() { productsRecyclerAdapter = new ProductsRecyclerAdapter(getActivity(), new CategoryRecyclerInterface() { @Override public void onProductSelected(View caller, Product product) { if (android.os.Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) { setReenterTransition(TransitionInflater.from(getActivity()).inflateTransition(android.R.transition.fade)); } ((MainActivity) getActivity()).onProductSelected(product.getId()); } }); }
Example #27
Source File: MainActivity.java From openshop.io-android with MIT License | 5 votes |
/** * Launch {@link ProductFragment}. * * @param productId id of product for display. */ public void onProductSelected(long productId) { Fragment fragment = ProductFragment.newInstance(productId); if (android.os.Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) { fragment.setReturnTransition(TransitionInflater.from(this).inflateTransition(android.R.transition.fade)); } replaceFragment(fragment, ProductFragment.class.getSimpleName()); }
Example #28
Source File: SearchActivity.java From android-proguards with Apache License 2.0 | 5 votes |
Transition getTransition(@TransitionRes int transitionId) { Transition transition = transitions.get(transitionId); if (transition == null) { transition = TransitionInflater.from(this).inflateTransition(transitionId); transitions.put(transitionId, transition); } return transition; }
Example #29
Source File: ComicFragment.java From Easy_xkcd with Apache License 2.0 | 5 votes |
protected View inflateLayout(int resId, LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(resId, container, false); setHasOptionsMenu(true); pager = (HackyViewPager) view.findViewById(R.id.pager); pager.setOffscreenPageLimit(2); prefHelper = getMainActivity().getPrefHelper(); themePrefs = getMainActivity().getThemePrefs(); databaseManager = getMainActivity().getDatabaseManager(); if (!(this instanceof FavoritesFragment)) { if (savedInstanceState != null) { lastComicNumber = savedInstanceState.getInt(LAST_COMIC); } else if (lastComicNumber == 0) { lastComicNumber = prefHelper.getLastComic(); } if (MainActivity.overviewLaunch && !SearchResultsActivity.isOpen ) { MainActivity.overviewLaunch = false; getMainActivity().showOverview(false); } } if (savedInstanceState == null && transitionPending) { postponeEnterTransition(); Timber.d("posponing transition..."); setSharedElementEnterTransition(TransitionInflater.from(getContext()).inflateTransition(R.transition.image_shared_element_transition)); } if (getMainActivity().getCurrentFragment() == MainActivity.CurrentFragment.Browser && (this instanceof ComicBrowserFragment || this instanceof OfflineFragment)) getMainActivity().getToolbar().setSubtitle(prefHelper.subtitleEnabled() ? String.valueOf(lastComicNumber) : ""); return view; }
Example #30
Source File: SharedElementTransition.java From Kore with Apache License 2.0 | 5 votes |
/** * Sets up the transition for the entering fragment * @param fragmentTransaction * @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; } androidx.core.app.SharedElementCallback seCallback = new androidx.core.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()); }