Android Studio “mobile” and “wear” project modules, shared components location

两盒软妹~` 提交于 2019-12-19 07:34:33

问题


In my Android Studio project there are two android modules "mobile" and "wear", these seem to be the views and controllers for the types of android devices that will be able to run this application

I expect them to share some logic, such as the model files and POJOs so where should that be stored? I expect the "mobile" module to do a lot more heavy lifting than the "wear" module, but should I put the model objects in that module, or should I make a new third module that they can both use? (or some other design paradigm)


回答1:


Take a look there: https://github.com/tajchert/SWear_Weather

I created common module that (in my case) have constant variables, and is shared between phone and Wear module.

About where to put your objects... if you expect to use same objects on Wear an mobile, put them in common project so they are automatically shared between those two (no code duplication), but if particular object is used only on mobile and there is no need in future to add him on Wear, just put him in mobile project.

Also common project can allow you to share stuff like assets (icons etc.) between mobile and Wear device.



来源:https://stackoverflow.com/questions/25505629/android-studio-mobile-and-wear-project-modules-shared-components-location

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!