简体   繁体   English

我应该在MVVM中的哪里放置下载器类?

[英]Where should i put downloader classes in MVVM?

I've written a download manager app for Android. 我已经为Android编写了一个下载管理器应用程序。 Now i want to refactor it's structure to MVVM. 现在我想将其结构重构为MVVM。 but i have some questions. 但是我有一些问题。

  1. Into what layer I should move downloader classes such as DownloadManager.java (which manages download queue, etc), Downloader.java (which creates an empty file then downloads data and write into that empty file), etc? 我应该将诸如DownloadManager.java (管理下载队列等), Downloader.java (创建一个空文件然后下载数据并写入该空文件)之类的downloader类移到哪一层?

  2. into what layer i should move Application class which is responsible for creating database for the first time? 我应该将负责首次创建数据库的Application类移到哪一层?

thanks. 谢谢。

Let's say you have 3 layers, 假设您有3层,

  • View(Activities, Fragments, CustomView, ..) 视图(活动,片段,CustomView等)
  • BusinessLogic(Presenter, Viewmodel, ..) BusinessLogic(演示者,Viewmodel等)
  • Data(Repository, ..) 数据(存储库,..)

Downloader.java should be in the Data layer Downloader.java应该在数据层中

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

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