Coder Social home page Coder Social logo

Comments (6)

wman1980 avatar wman1980 commented on August 24, 2024 1

ok, I worked around my issue by creating a snapshot onPause within my fragment. Sorry to spam with unrelated stuff and thanks for your response.

from android-extensions.

tunjid avatar tunjid commented on August 24, 2024

Hi @wman1980, thanks for checking out the library. MainActivity has an example of this using an extension:

navigator.stackTransactionModifier = navigator.materialFadeThroughTransition()

The full implementation is:

fun MultiStackNavigator.materialFadeThroughTransition(): FragmentTransaction.(Int) -> Unit = fade@{ index ->
    val rootFragmentManager = current?.activity?.supportFragmentManager ?: return@fade

    rootFragmentManager.findFragmentByTag(activeIndex.toString())?.apply {
        enterTransition = null
        if (exitTransition !is MaterialFadeThrough) exitTransition = MaterialFadeThrough().setDuration(300)
    }
    rootFragmentManager.findFragmentByTag(index.toString())?.apply {
        exitTransition = null
        if (enterTransition !is MaterialFadeThrough) enterTransition = MaterialFadeThrough().setDuration(300)
    }
}

from android-extensions.

wman1980 avatar wman1980 commented on August 24, 2024

ahh, that is awesome!

I just forgot about the supportFragmentManager and the index.

Thanks a lot!

from android-extensions.

wman1980 avatar wman1980 commented on August 24, 2024

Hi @tunjid,

I have a follow up question.

If I add some Transition.TransitionListener to that code above to listen to start and end events for each transition. Do you have an idea how I could pass these events to my active and target fragment?

Currently the fragment returned by findFragmentByTag is a StackFragment and it does not offer a lot to me because everything is internal ...

I first though I could just add this listener within my active/target fragment, but there the transition is null. So is there actually a way to get these transitions from my active/target fragment?

Thanks

from android-extensions.

tunjid avatar tunjid commented on August 24, 2024

@wman1980 MultistackNavigator.current and MultistackNavigator.previous should give you you a reference to your Fragment in your Transtion.Listener. Do you have a snippet of what you're trying to achieve with the listener?

from android-extensions.

wman1980 avatar wman1980 commented on August 24, 2024

Actually I have a WebView within android and the webview "flickers/blinks" if a transition (MaterialSharedAxis.X) is started. My plan to prevent that was to create a bitmap snapshot and put that snapshot in front of the webview on transition start and remove that snapshot on transition end. But unfortunately I just discovered that onDestroyView of my fragment is called before onTransitionStart e.g. during a returnTransition. Damn android!

from android-extensions.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.