Git Product home page Git Product logo

Comments (7)

git-xuhao avatar git-xuhao commented on July 17, 2024

@wmjwmj828 可以的,你可以试下,下面是伪代码,不过也可以用 dagger2 实现

abstract class BaseActivity <V:BaseView,T :BasePresenter<V>>: AppCompatActivity(),BaseView {
 open var mPresenter:T?=null
override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    if (null == mPresenter) {
        mPresenter = initPresenter()
    }
   mPresenter!!.attachView(this as V)
}

from kotlinmvp.

mackwu828 avatar mackwu828 commented on July 17, 2024

@git-xuhao 这样子类还要传View,好麻烦,哎如果as BaseView还编译不过
mPresenter!!.attachView(this as BaseView)

from kotlinmvp.

mackwu828 avatar mackwu828 commented on July 17, 2024

用dagger都不用方法注入view了,还是先不用dagger的方法实现,更容易理解

from kotlinmvp.

wangyuan0217 avatar wangyuan0217 commented on July 17, 2024

楼主解决了没,我项目也遇到这个问题,改成kotlin了,结果泛型这边和java有点不同,编译不过,暂时BaseActivity的基类都还是java,不知道如何转kotlin(BaseActivity明明已经实现了BaseView,mPresenter却不能attach(this))

from kotlinmvp.

zhupengxiang avatar zhupengxiang commented on July 17, 2024

同求解决办法 @wmjwmj828 @wangyuan0217 我现在基类也是java

from kotlinmvp.

wangyuan0217 avatar wangyuan0217 commented on July 17, 2024

不知道欸

from kotlinmvp.

git-xuhao avatar git-xuhao commented on July 17, 2024

@zhupengxiang @wangyuan0217 上面不是提供的有方案吗?有试过么?

from kotlinmvp.

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.