简体   繁体   English

AsyncTask URLConnection MVP设计模式

[英]AsyncTask URLConnection MVP design pattern

It's my first program following the MVP design pattern and i'm a beginner in JAVA. 这是我遵循MVP设计模式的第一个程序,并且是JAVA的初学者。

I'm writing a simple login activity. 我正在编写一个简单的登录活动。 I have to access datas from a database through an API. 我必须通过API访问数据库中的数据。 For this purpose, i'm using httpURLConnection method in an asyncTask subclass. 为此,我在asyncTask子类中使用httpURLConnection方法。

Here is my problem: where should i write the asyncTask subclass (Model class, Presenter class, MainActivity class) ? 这是我的问题:我应该在哪里编写asyncTask子类(模型类,演示者类,MainActivity类)?

Regards, 问候,

Chefty. 客气。

As I understand you database is not a part of application but remove server. 据我了解,数据库不是应用程序的一部分,而是删除服务器。 So in this case async task will do an api call and update the model of your app. 因此,在这种情况下,异步任务将进行api调用并更新您的应用程序模型。

The flow will look like: 流程如下所示:

(view) -[ 1 need data to display]->(presenter)-[ 2 request data]->(model)->[ 3 do async request to server] (视图)-[ 1需要显示数据]->(演示者)-[ 2请求数据]->(模型)-> [ 3对服务器进行异步请求]

Your async task is number 3 您的异步任务是3

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM