英文文档|中文文档
Cov is a lightweight tool-collection for quickly-developing an android app use (Kotlin + JetPack + DataBinding)
How to import
- Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}
- Add the dependency
dependencies {
// current latest release version is 0.7.1
implementation 'com.github.kukyxs:CoMvvmHelper:version'
}
Migrate version to 0.7.x
// replace your `Activity/Fragment's KoinScopeComponent` by `AndroidScopeComponent`
// crate `scope`: replace `by lazy{ activityScope() } / by lazy { createScopeAndLink() }` by `by activityScope()/ by fragmentScope()`
// replace `scopeInject` by `AndroidScopeComponent.inject`
// activity
class GuideActivity : BaseActivity<ActivityGuideBinding>(), AndroidScopeComponent {
// create koin scope
override val scope: Scope by activityScope()
// replace `scopeInject` by `inject`
private val mGuideAdapter by inject<GuideAdapter> {
parametersOf(mGuideItems)
}
}
// fragment 操作
class TestNewKoinFragment : BaseFragment<FragmentTestNewKoinBinding>(), AndroidScopeComponent {
// create koin scope
override val scope: Scope by fragmentScope()
// replace `scopeInject` by `inject`
private val aInstance by inject<EntityForKoinScopeTest>()
}
Migrate version to 0.5.x
Due to koin lifecycleScope has been Deprecated and not supported any more, you can implementation KoinScopeComponent and override scope field,
then call scopeInject
(an extension function for KoinScopeComponent) to replace lifecycleScope.inject
, for example
// register your koin scoped
val adapterModule = module {
scope<GuideActivity> {
scoped { (items: MutableList<GuideDisplay>) -> GuideAdapter(items) }
}
scope<TestNewKoinFragment> {
scoped { EntityForKoinScopeTest() }
}
}
// make your activity implement from KoinScopeComponent
class GuideActivity : BaseActivity<ActivityGuideBinding>(), KoinScopeComponent {
// create koin scope
override val scope: Scope by lazy { activityScope() }
// your registered scope instance
private val mGuideAdapter by scopeInject<GuideAdapter> {
parametersOf(mGuideItems)
}
override fun onDestroy() {
super.onDestroy()
scope.close() // close tied scope
}
}
// make your fragment implement from KoinScopeComponent
class TestNewKoinFragment : BaseFragment<FragmentTestNewKoinBinding>(), KoinScopeComponent {
// create koin scope
override val scope: Scope by lazy { createScopeAndLink() }
// your registered scope instance
private val aInstance by scopeInject<EntityForKoinScopeTest>()
override fun onDestroy() {
super.onDestroy()
scope.close() // close tied scope
}
}
How to use
Application configurations -> App
ImageLoadEngine(if use default image DataBindingAdapter) -> example: GlideEngine
Permission Demo -> PermissionDemoActivity
Http Demo(include download, dsl http request, request by retrofit) -> HttpDemoActivity
LiveDataManagerPool Demo() -> HttpDemoActivity
RecyclerView Demo(include Update Items, add HeaderView/FooterView, MultiItemLayout) -> RecyclerViewDemoActivity
MultiDisplay Demo -> MultiItemDisplayActivity
ImageDisplay and DataStore(alpha branch) Demo -> ImageDisplayActivity, ImageDisplayAlpha
DialogFragment Demo -> DemoDialogFragment, MultiItemDisplayActivity
Background By DataBinding -> activity_shape_display
Paging3 Demo -> PagingDemoActivity
More Koltin Extension Functions can read source code
Third Libraries Implemented at Cov
see -> LibConfigs
proguard rules referer the proguard rules of third library(OkHttp and Retrofit proguard rules has been added)
License
MIT License
Copyright (c) 2020 kuky_xs
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.