Corbind (recyclerview)

Kotlin Coroutine binding APIs for Android UI widgets from the platform and support libraries.

License

License

GroupId

GroupId

ru.ldralighieri.corbind
ArtifactId

ArtifactId

ccorbind-recyclerview
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

aar
Description

Description

Corbind (recyclerview)
Kotlin Coroutine binding APIs for Android UI widgets from the platform and support libraries.
Project URL

Project URL

https://github.com/LDRAlighieri/Corbind/
Source Code Management

Source Code Management

https://github.com/LDRAlighieri/Corbind/

Download ccorbind-recyclerview

How to add to project

<!-- https://jarcasting.com/artifacts/ru.ldralighieri.corbind/ccorbind-recyclerview/ -->
<dependency>
    <groupId>ru.ldralighieri.corbind</groupId>
    <artifactId>ccorbind-recyclerview</artifactId>
    <version>1.0.0</version>
    <type>aar</type>
</dependency>
// https://jarcasting.com/artifacts/ru.ldralighieri.corbind/ccorbind-recyclerview/
implementation 'ru.ldralighieri.corbind:ccorbind-recyclerview:1.0.0'
// https://jarcasting.com/artifacts/ru.ldralighieri.corbind/ccorbind-recyclerview/
implementation ("ru.ldralighieri.corbind:ccorbind-recyclerview:1.0.0")
'ru.ldralighieri.corbind:ccorbind-recyclerview:aar:1.0.0'
<dependency org="ru.ldralighieri.corbind" name="ccorbind-recyclerview" rev="1.0.0">
  <artifact name="ccorbind-recyclerview" type="aar" />
</dependency>
@Grapes(
@Grab(group='ru.ldralighieri.corbind', module='ccorbind-recyclerview', version='1.0.0')
)
libraryDependencies += "ru.ldralighieri.corbind" % "ccorbind-recyclerview" % "1.0.0"
[ru.ldralighieri.corbind/ccorbind-recyclerview "1.0.0"]

Dependencies

compile (2)

Group / Artifact Type Version
ru.ldralighieri.corbind : corbind jar 1.0.0
androidx.recyclerview » recyclerview jar 1.0.0

Project Modules

There are no modules declared in this project.

Corbind

Maven Central Kotlin Version Kotlin Coroutines Version GitHub license

Codacy Badge API Android Weekly


Kotlin Coroutines binding APIs for Android UI widgets from the platform and support libraries. Supports Flow, ReceiveChannel and Actor.

Description

This library is for Android applications only. Help you to transform Android UI events into cold Flow, hot ReceiveChannel or just perform an action through an Actor.

Download

Platform bindings:

implementation 'ru.ldralighieri.corbind:corbind:1.4.0'

AndroidX library bindings:

implementation 'ru.ldralighieri.corbind:corbind-appcompat:1.4.0'
implementation 'ru.ldralighieri.corbind:corbind-core:1.4.0'
implementation 'ru.ldralighieri.corbind:corbind-drawerlayout:1.4.0'
implementation 'ru.ldralighieri.corbind:corbind-leanback:1.4.0'
implementation 'ru.ldralighieri.corbind:corbind-navigation:1.4.0'
implementation 'ru.ldralighieri.corbind:corbind-recyclerview:1.4.0'
implementation 'ru.ldralighieri.corbind:corbind-slidingpanelayout:1.4.0'
implementation 'ru.ldralighieri.corbind:corbind-swiperefreshlayout:1.4.0'
implementation 'ru.ldralighieri.corbind:corbind-viewpager:1.4.0'
implementation 'ru.ldralighieri.corbind:corbind-viewpager2:1.4.0'

Google 'material' library bindings:

implementation 'ru.ldralighieri.corbind:corbind-material:1.4.0'

Snapshot build:

repositories {
    maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
}
      
dependencies {
   implementation 'ru.ldralighieri.corbind:{module}:1.4.1-SNAPSHOT'
}

List of extensions

You can find a list of extensions in the description of each module:
corbind
corbind-appcompat
corbind-core
corbind-drawerlayout
corbind-leanback
corbind-material
corbind-navigation
corbind-recyclerview
corbind-slidingpanelayout
corbind-swiperefreshlayout
corbind-viewpager
corbind-viewpager2

How to use it?

If you need to get a text change events of EditText widget, simple use case with cold Flow will look something like this:

findViewById<EditText>(R.id.et_name)
    .textChanges() // Flow<CharSequence>
    .onEach { /* handle text change events */ }
    .launchIn(scope)

If you prefer hot ReceiveChannel and you need to get a ViewPager page selection events, then the use case will transform in something like this:

launch {
    findViewById<ViewPager>(R.id.vp_slides)
        .pageSelections(scope) // ReceiveChannel<Int>
        .consumeEach {
            /* handle ViewPager events */
        }
}

And if you just need to perform an action on button click, the easiest way will be:

launch {
    findViewById<AppCompatButton>(R.id.bt_confirm)
        .clicks {
            /* perform an action on View click events */
        }
}

Just one more traditional example of login button enabling/disabling by email and password field validation:

combine(
    et_email.textChanges()
        .map { Patterns.EMAIL_ADDRESS.matcher(it).matches() },

    et_password.textChanges()
        .map { it.length > 7 },

    transform = { email, password -> email && password }
)
    .onEach { bt_login.isEnabled = it }
    .launchIn(scope)

More examples in module descriptions and in source code

Missed or forgot something?

If I forgot something or you have any ideas what can be added or corrected, please create an issue or contact me directly.

Special thanks to

Jake Wharton. This project is inspired by RxBinding.

License

Copyright 2019 Vladimir Raupov

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.

Versions

Version
1.0.0
1.0.0-RC