开发者

Android components-based application design: How should I represent this model?

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开发者_JAVA技巧'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.

Android components-based application design: How should I represent this model?

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!


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜