Giter Club home page Giter Club logo

Comments (2)

passsy avatar passsy commented on May 21, 2024

To be clear, you are calling getPresenter().onSubmit(getIntent()); and the implementation of #onSubmit(Intent) calls TiPresenter#getView(). TiPresenter#getView() is null and causes the NPE.

If so, everything is correct. TiPresenter#getView() is null until TiPresenter#onWakeUp() has been called (which will be called internally after Activity#onStart()).
I assume #onSubmit(Intent) is in TiActivity#onCreate() for testing and should normally be triggered from a Button. This will work, because the Button can only be clicked when the view is visible to the user. At that point, TiPresenter#onWakeUp() already got called and TiPresenter#getView() will not be null anymore.

When you really want to call the TiPresenter in TiActivity#onCreate() you have to make sure you don't trigger the view when it is not attached. Instead cache data in you Presenter and wait until the view is attached.

You are using if (savedInstanceState == null) which indicates you want some kind of initialization when the activity is initialized for the first time. Why aren't you moving that logic into TiPresenter#onCreate()?
You can pass the Intent into the constructor of your Presenter in TiActivity#providePresenter().

from thirtyinch.

k0shk0sh avatar k0shk0sh commented on May 21, 2024

seems pretty legit to actually pass the intent to the presenter constructor. i got no idea why wouldn't i thought of it. Thank you for the explanation and your answer.

from thirtyinch.

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.