MVP Design for Android: How to adopt to my application?

前端 未结 1 1380
不思量自难忘°
不思量自难忘° 2021-01-27 09:56

I am writing an application that will have a JSON file which contains data that should be parsed and saved into ItemModel POJOs.

Let\'s assume

相关标签:
1条回答
  • 2021-01-27 10:16

    There is no exact/correct definition of implementing MVP in Android

    Here's a great article on MVP

    I'd do MVP as follow.

    1. Model - POJO's, parsing, Storing (SQLlite) and retrieving data (http). Obviously I'd divide the POJO's, parsing and DB logic into sub folders - but this all falls into Model for me.
    2. View - Activity, Fragment, Adapters - Activities & Fragment hold reference to a Presenter that gives them data to display. How this data/messages are displayed, look + feel etc. is dealt with in the View.
    3. Presenter - The Middle man, provides the logic to inputs i.e. Button Clicks, retrieval of data, validation of inputs & then passes the result back to the View (Activity or Fragment)

    Here's a simplified diagram of MVP

    0 讨论(0)
提交回复
热议问题