android MVP结构中context该如何传递?
怪我咯
怪我咯 2017-04-17 17:40:39
0
3
649

context变量肯定是从activity开始传递,不清楚该如何在presenter中使用,
是传递到进去,还是通过接口调用view中的方法?求赐教

怪我咯
怪我咯

走同样的路,发现不同的人生

reply all (3)
伊谢尔伦

Just write a getContext function in View

    大家讲道理

    Just pass it over. The interface actually defines a specification, which can increase maintainability in large projects.

      巴扎黑

      The Presenter must hold a reference to the Interface of the Viwe layer and the Interface of the Model layer, while the View layer holds a reference to the Interface of the Presenter layer. The activity is equivalent to the View layer, so you need to instantiate it in the activity. The Presenter implementation class passes the context in. In this way, after you load the data in the Presenter implementation class, you can directly call the Interface method of the View layer. If it prompts that the loading is successful, but the loading success and other methods are implemented in the activity, because the activity is equivalent to the View layer. My humble opinion on the Interface implementation class, please correct me if you understand it wrong

        Latest Downloads
        More>
        Web Effects
        Website Source Code
        Website Materials
        Front End Template
        About us Disclaimer Sitemap
        php.cn:Public welfare online PHP training,Help PHP learners grow quickly!