Skip to content

一个基于MVVM用Kotlin+Retrofit+协程Flow+Databinding+LiveData来封装的开发框架

Notifications You must be signed in to change notification settings

SaberAlpha/WanAndroidScope

Repository files navigation

WanAndroidScope

  • 该项目基于 鸿洋 大佬的 玩Android 接口
  • 项目采用 Kotlin 语言
  • 整体采用 MVVM 架构编写
  • 使用到的 JetPack组件有 LiveData 、 ViewModel 、 Lifecycle 、 DataBinding 、 Navigation
  • 使用协程Flow代替rxjava,开发更加顺滑

核心代码

使用Flow代替rxjava进行网络请求

     public fun <T> Flow<BaseResult<T>>.subscribe(scope: CoroutineScope,success: (T?) -> Unit,
                                              onServerError: (ResponseThrowable) -> Unit = {}){
         this.onEach {
                 when(it.errorCode){
                     0->success(it.data)
                 }
             }.catch {
                 val exception = ExceptionHandle.handleException(it)
                 onServerError(exception)
                 LogUtils.d("error",exception.message)
             }
             .launchIn(scope)
     }

    
    NetworkManager.instance.getBanner()
                .onStart { showLoading() }
                .onCompletion { dismissLoading() }
                .subscribe(viewModelScope,{
                    
                })

已有功能

  • 首页最新文章
  • 公众号列表

待完善功能及后续开发计划

  • 搜索
  • 每日一问文章列表
  • 广场文章列表
  • 项目文章列表
  • 知识体系
  • 网站导航
  • 收藏、分享文章
  • 代办清单
  • 用户详细页
  • 积分详细、排名
  • 换肤

特别感谢

支持一下

如果本项目对你有帮助,请点击右上角的 start 支持一下

About

一个基于MVVM用Kotlin+Retrofit+协程Flow+Databinding+LiveData来封装的开发框架

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages