谷歌IO其余的设计模式,完成ContentProvider的,现在卡模式、现在、谷歌、IO

2023-09-04 07:46:24 作者:寂寞陪衬

所以,看后非常知道视频上这个话题我决定去与设计模式B.使用ContentProvider的与servicehelper。

So after watching the very know video on this topic i decided to go with design pattern B. Using a contentprovider with servicehelper.

Basicly我有以下文件:

Basicly i have the following files:

MYPROVIDER MyDatabase的 Mycontract

在活动现在我可以得到ContentResolver的并查询供应商。所有的是伟大的工作至今。

in the activity i can now get the contentresolver and query the provider. All is working great so far.

现在我需要同步我的ContentProvider从我的REST API获取数据。 因此我需要实现一个服务辅助服务和休息方法。 研究谷歌的IO应用程序帮助我很多,即时通讯新手与Android所以它仍然很难搞清楚。

Now i need to sync my contentprovider to fetch data from my REST API. Thus i need to implement a service helper service and Rest method. Studying the Google IO app has helped me alot, im novice with android so it's still hard to figure it out.

我看到谷歌使用RemoteHandlers处理外部数据,我猜他们是图中的处理器类?

I see Google uses RemoteHandlers to process the external data, i guess they are the Processor classes in the diagram?

我不明白什么是我怎么能实现servicehelper +服务的一部分从网络获取数据。

What i dont understand is how i can implement the servicehelper + service part to get the data from the network.

我在哪里可以调用该服务帮助? 什么是服务和帮助需要做的是什么呢? 有没有这个确切的设计模式的任何好的例子?

我看了几个主题堆栈这一点,所有的提示不同的方法。我发现一个例子至极声明一个restprovider然后MYPROVIDER有延长的供应商。我不喜欢这些解决方案,并要遵循这一结构化的设计模式。 IM希望你们能帮助我了!

I have read several topics on stack about this, all suggesting different methods. I found an example wich declares a restprovider and then myProvider has to extend that provider. I dont like those solutions and want to follow this structured design pattern. Im hoping you guys can help me out!

编辑:项目源可用: https://github.com/samvdb/TracknTrace

推荐答案

在我的理解模式是:

请不要显示一个空的活动,并在背景中加载的内容。当加载失败,无法显示任何内容。 而不是通过显示内容提供商和适配器存储在数据库中存取数据 - 这保证了用户总能看到内容 在后台获取新的数据,一旦数据是手机的活性是通过适配器自动更新

要您的问题(我改的顺序):

To your questions (I changed the order):

我从哪儿调用服务的帮手? 我选择守夜通话模式的。在这种情况下,呼叫取决于你的应用。你可以触发更新应用程序启动时,在创建活动或当用户选择更新按钮时。我会选择在活动创作。 您已经选择的模式B.在这种情况下,很显然,内容提供商必须触发更新。什么时候?为了获得新的数据:在创建时或之后的第一个读访问。我会使用创建时间。对于创建,更新,在您的内容提供相应的动作后删除。 是否有这个确切的设计模式的任何好的例子? 从我的岗位在 http://stackoverflow.com/a/8693919/734687 :唯一的开源参考实现,我知道正在 http://datadroid.foxykeep.com 可用。这是一个库,你可以在自己的应用程序中使用。该架构下/ presentation解释 - 确保你读它 什么是服务,帮助需要做的是什么呢? 如果你看一下href="http://dl.google.com/googleio/2010/android-developing-RESTful-android-apps.pdf">幻灯片在幻灯片19