Project Name | Stars | Downloads | Repos Using This | Packages Using This | Most Recent Commit | Total Releases | Latest Release | Open Issues | License | Language |
---|---|---|---|---|---|---|---|---|---|---|
Jetpackmvvm | 2,550 | 6 months ago | 11 | apache-2.0 | Kotlin | |||||
:chicken::basketball:一个Jetpack结合MVVM的快速开发框架,基于MVVM模式集成谷歌官方推荐的JetPack组件库:LiveData、ViewModel、Lifecycle、Navigation组件 使用Kotlin语言,添加大量拓展函数,简化代码 加入Retrofit网络请求,协程,帮你简化各种操作,让你快速开发项目 | ||||||||||
Awesome Android Kotlin Apps | 1,947 | 23 days ago | 12 | Kotlin | ||||||
👓 A curated list of awesome android kotlin apps by open-source contributors. | ||||||||||
Kotlin Pokedex | 1,393 | 3 days ago | 27 | mit | Kotlin | |||||
:cyclone: A Pokedex app using ViewModel, ViewBinding, LiveData, Room and Navigation | ||||||||||
Disneymotions | 1,336 | 10 months ago | apache-2.0 | Kotlin | ||||||
🦁 A Disney app using transformation motions based on MVVM (ViewModel, Coroutines, Flow, Room, Repository, Koin) architecture. | ||||||||||
Conference App 2018 | 1,297 | 4 years ago | 31 | apache-2.0 | Kotlin | |||||
The Official Conference App for DroidKaigi 2018 Tokyo | ||||||||||
Wanandroid | 1,286 | 8 months ago | 8 | gpl-3.0 | Kotlin | |||||
Jetpack MVVM For Wanandroid 最佳实践 ! | ||||||||||
Mvvm Kotlin Android Architecture | 1,147 | 2 years ago | 6 | apache-2.0 | Kotlin | |||||
MVVM + Kotlin + Retrofit2 + Hilt + Coroutines + Kotlin Flow + mockK + Espresso + Junit5 | ||||||||||
Androidarchitecture | 854 | 3 years ago | 11 | Java | ||||||
Recommended architecture by Android | ||||||||||
Awesome Jetpack Compose Android Apps | 828 | a month ago | 3 | Kotlin | ||||||
👓 A curated list of awesome Jetpack Compose android apps by open-source contributors. | ||||||||||
Jetpack Mvvm Scaffold | 807 | 5 months ago | 2 | Java | ||||||
人生苦短,让脚手架为你节省时间。(目前作为《最佳实践》项目的 Dev 版优先更新) |
NOTICE
The library has been archived. I can't provide support anymore as I no longer use Conductor and instead I use Navigation Component on my projects.
You can still use the library as it is, but I won't be adding new features or reviewing PRs from now on.
Feel free to fork and do any changes or continue supporting it by yourself, but please keep the license and copyright notices.
Miguel, author of the library.
This library adds support for the ViewModel from Architecture Components to the Conductor library.
A ViewModelController is provided that contains all the necessary things to create ViewModels and observe LiveData.
The ViewModelController is a LifecycleOwner that also provides the necessary events for observing LiveData.
The ViewModelController contains its own ViewModelStore, which contains the ViewModels. As Controllers survive configuration changes, the ViewModels will do as well.
// 1. Create a new Controller by extending the ViewModelController.
class MyViewModelController : ViewModelController() {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup): View {
val view = inflater.inflate(R.layout.controller_viewmodel, container, false)
// 2. Obtain your ViewModel using the viewModelProvider() method
val viewModel = viewModelProvider().get(MyViewModel::class.java)
// 2.1 You can also provide a factory to viewModelProvider
// val viewModel = viewModelProvider(factory).get(MyViewModel::class.java)
// 3. Observe your LiveData
viewModel.getLiveData().observe(this, Observer<String> {
//
})
return view
}
}
This library depends on Architecture Components and Conductor.
Those two components are NOT provided and need to be added to your project separately.
Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Step 2. Add the dependency
dependencies {
implementation "com.github.miquelbeltran:conductor-viewmodel:1.0.3"
}
The LiveData observer will be removed (detached) after onDestroyView is called. You don't need to remove the observer manually
Call to liveData.observe() on the onCreateView method.
Call viewModelProvider
and pass your factory as the first parameter.
val viewModel = viewModelProvider(factory).get(MyViewModel::class.java)
Cast the parentController
as ViewModelController
, then access the same
ViewModelProvider
using viewModelProvider()
,
that should give you access to the same ViewModel
instance.
val viewModelFromParent = (parentController as ViewModelController)
.viewModelProvider()
.get(HomeViewModel::class.java)
A sample project is included in the app
module.
I will add Espresso tests in the future to verify that lifecycle events happen correctly.
In order to remove the observers from the LiveData when the view is destroyed.
Conductor
is a library by BlueLine Labs, Inc. bluelinelabs/Conductor
Conductor ViewModel
is a library by Miquel Beltran
Copyright 2018 Miquel Beltran - BELTRAN.WORK
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.