GithubHelp home page GithubHelp logo

Comments (4)

Jeevuz avatar Jeevuz commented on July 17, 2024

Hi!
Take a look at the createActivityIntent(String screenKey, Object data).
Here you have your data and this is your responsibility to put it into the Intent you are creating.

from cicerone.

pablodeafsapps avatar pablodeafsapps commented on July 17, 2024

Hi again,
I did not quite understand your recommendation, so I ended up doing the following in my code:

private val navigator: Navigator? by lazy {
        object : Navigator {
            override fun applyCommand(command: Command) {
                if (command is Forward) {
                    forward(command)
                }
            }
            private fun forward(command: Forward) {
                val data = (command.transitionData as Map<*, *>).filter { it.value == true }
                when (command.screenKey) {
                    RssFeedActivity.TAG -> startActivity(Intent(this@SportsListActivity, RssFeedActivity::class.java)
                            .putExtra("data", data as HashMap))
                    else -> Log.e("Cicerone", "Unknown screen: " + command.screenKey)
                }
            }
        }
    }

And in the receiver 'Activity':

override fun onResume() {
        super.onResume()
        presenter?.onViewCreated(intent.getSerializableExtra("data")?.let { it as HashMap<*, *> })
    }

Although it works, I would like to know whether this is the most appropriate way when using 'Cicerone'. Specifically, I do not like this approach since it requires doing a couple of explicit casts (as HashMap<*, *>, for instance), which I believe it is not a good practice.

Could you please drop me your thoughts?! Thanks and regards.

from cicerone.

Jeevuz avatar Jeevuz commented on July 17, 2024

Hm. I think you should see the sample and predefined navigators.
Regarding the data passing usually we create the Params class in the Presenter to hold all the data passing to the screen. Then create it when do the navigation, and cast the Object data to Params in the navigator. Then pass it from screen (eg. fragment) to the Presenter.

from cicerone.

Jeevuz avatar Jeevuz commented on July 17, 2024

If you have no more questions i think we can close this issue.

from cicerone.

Related Issues (20)

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.