基于Android组件的应用程序设计:我应该如何表示这个模型?

发布于 2024-10-04 02:24:32 字数 718 浏览 0 评论 0原文

我想将我的应用程序重新设计成组件,这样它更加模块化,并且将来更容易重用,但我从未真正设计过应用程序,所以我真的不知道应该如何做到这一点。

以下是该应用程序的简要说明:

  • 是允许用户创建将本地存储在设备上并通过网络发送的“事件”。

  • 用户可以通过 2 个活动与应用程序交互:“NewEventActivity”允许他创建新事件,“LogbookActivity”允许他浏览以前创建的事件。

  • 本地存储应由 SQLite 数据库处理

  • 事件应以特定的二进制格式发送。

  • 其他应用程序应该能够使用发送组件以相同的格式格式化和发送其他类型的消息。

这张图代表了我如何考虑组织组件。方框代表组件,箭头代表没有这些组件的交互。 alt text

这是我的问题:

  • 这个模型看起来还好吗?您能看到一些可以改进的地方吗?
  • 我的 SQLiteHelper 应该是 ContentProvider 还是 ContentResolver?
  • 我应该为每种类型的信号创建一个 BroadcastReceiver 类,还是应该创建一个大的 BroadcastReceiver 来处理我的应用程序可以处理的所有类型的信号?

谢谢你!

I would like to re-design my application into components, so it is more modular and easier to re-use in the future, but I've never really designed applications, so I don't really know how I should do this.

Here is a brief description of the application:

  • The purpose of the Application is to allow the User to create "Events" that are going to be stored locally on the Device and sent over the network.

  • The User can interact with the application through 2 Activities: A "NewEventActivity" that allows him to create the new Events and a "LogbookActivity" that allows him to browse previously created Events.

  • The local storage should be handled by a SQLite Database

  • The Event should be sent in a specific Binary format.

  • Other applications should be able to Use the Sending component to Format and send other type of messages in the same format.

This drawing represents how I was thinking of organizing the components. Boxes represent components, and arrows represent interactions without those components.
alt text

Here are my questions:

  • Does this model look OK? Can you see something that could be improved?
  • Should my SQLiteHelper be a ContentProvider or a ContentResolver?
  • Should I create one BroadcastReceiver class per type of Signal, or should I create one big BroadcastReceiver that handles all the kind of Signals my application can handle?

Thank you!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

似梦非梦 2024-10-11 02:24:32

简化设计的一些建议:

  • 如果 EventWriterEventReader 仅由于直接用户交互而与 Activity 交互,则它们不需要 广播接收器。事实上,它们可能只是活动中的方法。

  • 根据您选择何时发送事件的方式,您还可以将 MessageFormatterSender 重构为 IntentService,它将定期轮询内容提供者并选择要发送的数据片段。您可以通过警报安排 IntentService

我的 SQLiteHelper 应该是
ContentProvider 还是 ContentResolver?

它应该实现 ContentProvider(因为它提供对数据的访问)。

我应该创建一个广播接收器吗
每种信号类型的类,或者我应该
创建一个大的 BroadcastReceiver
处理我的所有类型的信号
应用程序可以处理吗?

我倾向于每种信号类型使用一个接收器,但这实际上只是一种偏好。

A few suggestions to simplify the design:

  • If EventWriter and EventReader only interact with the activity due to direct user interaction, they don't need to be BroadcastReceivers. In fact, they could just be methods in the activities.

  • Depending on how you choose when to send Events, you could also refactor MessageFormatter and Sender into an IntentService which will periodically poll the content provider and choose which pieces of data to send. You can schedule the IntentService via alarms.

Should my SQLiteHelper be a
ContentProvider or a ContentResolver?

It should implement ContentProvider (since it provides access to data).

Should I create one BroadcastReceiver
class per type of Signal, or should I
create one big BroadcastReceiver that
handles all the kind of Signals my
application can handle?

I lean towards one receiver per signal type, but that's really just a preference.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文