• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

msesma/Karchitec: Kotlin RSS reader using Google android architecture components ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

msesma/Karchitec

开源软件地址(OpenSource Url):

https://github.com/msesma/Karchitec

开源编程语言(OpenSource Language):

Kotlin 99.6%

开源软件介绍(OpenSource Introduction):

Karchitec

Kotlin RSS reader using Google android architecture components libraries

Pet project for testing several technologies:

  • Kotlin
  • MVVM architecture slightly modified (It has a presenter :D)
  • Google architecture components : ViewModel, LiveData and Room
  • Dagger 2 Dependency injection (And Butterknife)
  • Retrofit 2
  • Constraint layout
  • Chrome Custom Tabs
  • Stetho for Okhttp and db debugging
  • MockWebServer based Unit testing
  • Espresso tests
  • Detekt static code analysis

Simple RSS reader for technology testing. It is mostly a pet project to test the architecture components in kotlin.

Instead using a fragment as View, here we use a decorator class in order to maintain the activities as clean as possible. There is also a presenter for removing the not Data related logic from the ViewModel.

A time limited OkHttp caché acts as rate limiter avoiding network calls before 30 seconds after the last one. Some sites can overwrite this time.

More information about the architecture implemented in this post.

Error management and network status:

Instead creating an object that wraps network state and the actual data, here a second LiveData is used. This LiveData is feeded by the repository with interpreted results of Network calls. This LiveData is also stored in the MainActivity ViewModel and the decorator subscribes to it as it does with the data one. this way, errors are also lifecycle aware.

This approach is simple and effective, keeping the responsibilities separated. Detail activity never does network calls so it doesn't use the error flow.

Espresso tests:

Creating a mock repository class that returns mock MutableLiveData with controlled data is enough to easily test anything we want on the UI. We coud even test errors mocking also the network error LiveData.

I've left there the code for IdLingResource although it is not extrictly necessary using a fake Repository. With real repositories we must wait until the activity is iddle to ensure the data has arrived and the recyclerView is rendered.

JUnit tests

Webservice and mappers (RefreshUseCase) are tested using MockWebServer and a TestExecutor.

Alt text




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap