Skip to content

Commit

Permalink
Merge branch 'update-dependencies'
Browse files Browse the repository at this point in the history
  • Loading branch information
LDRAlighieri committed May 8, 2022
2 parents 8ba2e07 + 13b39d1 commit 7cd6240
Show file tree
Hide file tree
Showing 25 changed files with 116 additions and 136 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@
# ChangeLog


## Version 1.5.4

* Update: `SlidingPaneLayout` `panelOpens` extensions. Changed listener setting method from `set` to `add`.
* Update: `SlidingPaneLayout` `panelSlides` extensions. Changed listener setting method from `set` to `add`.
* Update: `ChipGroup` `checkedChanges` extensions. Replace ChipGroup.OnCheckedChangeListener with
ChipGroup.OnCheckedStateChangeListener. Supports multiple checked IDs and no longer requires the
single selection flag.
* Update: Kotlin modules dependency to v1.6.21.
* Update: Kotlin coroutines modules dependency to v1.6.1.
* Update: Material components dependency to v1.6.0.
* Update: Minor update of other libraries.


## Version 1.5.3

* Update: Kotlin modules dependency to v1.6.10.
Expand Down
36 changes: 18 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[![Corbind](logo.svg)](https://ldralighieri.github.io/Corbind)

[![Maven Central](https://img.shields.io/maven-central/v/ru.ldralighieri.corbind/corbind.svg)](https://search.maven.org/search?q=g:ru.ldralighieri.corbind)
[![Kotlin Version](https://img.shields.io/badge/Kotlin-v1.6.10-blue.svg)](https://kotlinlang.org)
[![Kotlin Coroutines Version](https://img.shields.io/badge/Coroutines-v1.6.0-blue.svg)](https://kotlinlang.org/docs/reference/coroutines-overview.html)
[![Kotlin Version](https://img.shields.io/badge/Kotlin-v1.6.21-blue.svg)](https://kotlinlang.org)
[![Kotlin Coroutines Version](https://img.shields.io/badge/Coroutines-v1.6.1-blue.svg)](https://kotlinlang.org/docs/reference/coroutines-overview.html)
[![GitHub license](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg?style=flat)](https://www.apache.org/licenses/LICENSE-2.0)

[![Codacy Badge](https://api.codacy.com/project/badge/Grade/a1c9a1b1d1ce4ca7a201ab93492bf6e0)](https://www.codacy.com/app/LDRAlighieri/Corbind?utm_source=github.com&utm_medium=referral&utm_content=LDRAlighieri/Corbind&utm_campaign=Badge_Grade)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/a1c9a1b1d1ce4ca7a201ab93492bf6e0)](https://app.codacy.com/gh/LDRAlighieri/Corbind)
[![API](https://img.shields.io/badge/API-14%2B-brightgreen.svg?style=flat)](https://android-arsenal.com/api?level=14)

[![Google Dev Library](https://img.shields.io/badge/Featured%20in%20devlibrary.withgoogle.com-Corbind-blue)](https://devlibrary.withgoogle.com/products/android/repos/LDRAlighieri-Corbind)
Expand All @@ -25,28 +25,28 @@ This library is for Android applications only. Help you to transform Android UI

Platform bindings:
```groovy
implementation 'ru.ldralighieri.corbind:corbind:1.5.3'
implementation 'ru.ldralighieri.corbind:corbind:1.5.4'
```

AndroidX library bindings:
```groovy
implementation 'ru.ldralighieri.corbind:corbind-activity:1.5.3'
implementation 'ru.ldralighieri.corbind:corbind-appcompat:1.5.3'
implementation 'ru.ldralighieri.corbind:corbind-core:1.5.3'
implementation 'ru.ldralighieri.corbind:corbind-drawerlayout:1.5.3'
implementation 'ru.ldralighieri.corbind:corbind-leanback:1.5.3'
implementation 'ru.ldralighieri.corbind:corbind-lifecycle:1.5.3'
implementation 'ru.ldralighieri.corbind:corbind-navigation:1.5.3'
implementation 'ru.ldralighieri.corbind:corbind-recyclerview:1.5.3'
implementation 'ru.ldralighieri.corbind:corbind-slidingpanelayout:1.5.3'
implementation 'ru.ldralighieri.corbind:corbind-swiperefreshlayout:1.5.3'
implementation 'ru.ldralighieri.corbind:corbind-viewpager:1.5.3'
implementation 'ru.ldralighieri.corbind:corbind-viewpager2:1.5.3'
implementation 'ru.ldralighieri.corbind:corbind-activity:1.5.4'
implementation 'ru.ldralighieri.corbind:corbind-appcompat:1.5.4'
implementation 'ru.ldralighieri.corbind:corbind-core:1.5.4'
implementation 'ru.ldralighieri.corbind:corbind-drawerlayout:1.5.4'
implementation 'ru.ldralighieri.corbind:corbind-leanback:1.5.4'
implementation 'ru.ldralighieri.corbind:corbind-lifecycle:1.5.4'
implementation 'ru.ldralighieri.corbind:corbind-navigation:1.5.4'
implementation 'ru.ldralighieri.corbind:corbind-recyclerview:1.5.4'
implementation 'ru.ldralighieri.corbind:corbind-slidingpanelayout:1.5.4'
implementation 'ru.ldralighieri.corbind:corbind-swiperefreshlayout:1.5.4'
implementation 'ru.ldralighieri.corbind:corbind-viewpager:1.5.4'
implementation 'ru.ldralighieri.corbind:corbind-viewpager2:1.5.4'
```

Google 'material' library bindings:
```groovy
implementation 'ru.ldralighieri.corbind:corbind-material:1.5.3'
implementation 'ru.ldralighieri.corbind:corbind-material:1.5.4'
```

Snapshot build:
Expand All @@ -56,7 +56,7 @@ repositories {
}
dependencies {
implementation 'ru.ldralighieri.corbind:{module}:1.5.4-SNAPSHOT'
implementation 'ru.ldralighieri.corbind:{module}:1.5.5-SNAPSHOT'
}
```

Expand Down
6 changes: 2 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ subprojects {
allWarningsAsErrors = true

// Enable experimental coroutines APIs
freeCompilerArgs += "-Xopt-in=kotlinx.coroutines.ObsoleteCoroutinesApi"
freeCompilerArgs += "-Xopt-in=kotlinx.coroutines.ExperimentalCoroutinesApi"
freeCompilerArgs += "-opt-in=kotlinx.coroutines.ObsoleteCoroutinesApi"
freeCompilerArgs += "-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi"
}
}

Expand Down Expand Up @@ -109,8 +109,6 @@ subprojects {


detekt {
toolVersion = libs.versions.detekt.get()

allRules = false
buildUponDefaultConfig = true

Expand Down
2 changes: 1 addition & 1 deletion corbind-activity/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
To add androidx activity bindings, import `corbind-activity` module:

```groovy
implementation 'ru.ldralighieri.corbind:corbind-activity:1.5.3'
implementation 'ru.ldralighieri.corbind:corbind-activity:1.5.4'
```

## List of extensions
Expand Down
2 changes: 1 addition & 1 deletion corbind-appcompat/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
To add androidx appcompat bindings, import `corbind-appcompat` module:

```groovy
implementation 'ru.ldralighieri.corbind:corbind-appcompat:1.5.3'
implementation 'ru.ldralighieri.corbind:corbind-appcompat:1.5.4'
```

## List of extensions
Expand Down
2 changes: 1 addition & 1 deletion corbind-core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
To add androidx core bindings, import `corbind-core` module:

```groovy
implementation 'ru.ldralighieri.corbind:corbind-core:1.5.3'
implementation 'ru.ldralighieri.corbind:corbind-core:1.5.4'
```

## List of extensions
Expand Down
2 changes: 1 addition & 1 deletion corbind-drawerlayout/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
To add androidx drawerlayout bindings, import `corbind-drawerlayout` module:

```groovy
implementation 'ru.ldralighieri.corbind:corbind-drawerlayout:1.5.3'
implementation 'ru.ldralighieri.corbind:corbind-drawerlayout:1.5.4'
```

## List of extensions
Expand Down
2 changes: 1 addition & 1 deletion corbind-leanback/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
To add androidx leanback bindings, import `corbind-leanback` module:

```groovy
implementation 'ru.ldralighieri.corbind:corbind-leanback:1.5.3'
implementation 'ru.ldralighieri.corbind:corbind-leanback:1.5.4'
```

## List of extensions
Expand Down
2 changes: 1 addition & 1 deletion corbind-lifecycle/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
To add androidx lifecycle bindings, import `corbind-lifecycle` module:

```groovy
implementation 'ru.ldralighieri.corbind:corbind-lifecycle:1.5.3'
implementation 'ru.ldralighieri.corbind:corbind-lifecycle:1.5.4'
```

## List of extensions
Expand Down
4 changes: 2 additions & 2 deletions corbind-material/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
To add material bindings, import `corbind-material` module:

```groovy
implementation 'ru.ldralighieri.corbind:corbind-material:1.5.3'
implementation 'ru.ldralighieri.corbind:corbind-material:1.5.4'
```

## List of extensions
Expand All @@ -15,7 +15,7 @@ Component | Extension | Description
**View**<br>(BottomSheetBehavior) | `slides` | Called when the bottom sheet is being dragged.
  | `stateChanges` | Called when the bottom sheet changes its state.
**Chip** | `closeIconClicks` | Called when the chip’s close icon is clicked.
**ChipGroup** | `checkedChanges` | Called when the checked chip has changed (only in single selection mode).
**ChipGroup** | `checkedChanges` | Called when the checked chips are changed.
**MaterialButton** | `checkedChanges` | Called when the checked state of a MaterialButton has changed.
**MaterialButtonToggleGroup** | `buttonCheckedChangeEvents` | Called when a `MaterialButton` in this group is checked or unchecked (only *not* in single selection mode).
  | `buttonCheckedChanges` | Called when a `MaterialButton` in this group is checked (only in single selection mode).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package ru.ldralighieri.corbind.material

import android.view.View
import androidx.annotation.CheckResult
import com.google.android.material.chip.ChipGroup
import kotlinx.coroutines.CoroutineScope
Expand All @@ -33,10 +32,10 @@ import ru.ldralighieri.corbind.internal.asInitialValueFlow
import ru.ldralighieri.corbind.internal.corbindReceiveChannel

/**
* Perform an action on checked view ID changes in [ChipGroup].
* Perform an action on checked view IDs changes in [ChipGroup].
*
* *Warning:* The created actor uses [ChipGroup.setOnCheckedChangeListener]. Only one actor can be
* used at a time.
* *Warning:* The created actor uses [ChipGroup.setOnCheckedStateChangeListener]. Only one actor can
* be used at a time.
*
* @param scope Root coroutine scope
* @param capacity Capacity of the channel's buffer (no buffer by default)
Expand All @@ -45,50 +44,48 @@ import ru.ldralighieri.corbind.internal.corbindReceiveChannel
fun ChipGroup.checkedChanges(
scope: CoroutineScope,
capacity: Int = Channel.RENDEZVOUS,
action: suspend (Int) -> Unit
action: suspend (List<Int>) -> Unit
) {
val events = scope.actor<Int>(Dispatchers.Main.immediate, capacity) {
val events = scope.actor<List<Int>>(Dispatchers.Main.immediate, capacity) {
for (checkedId in channel) action(checkedId)
}

checkSelectionMode(this)
events.trySend(checkedChipId)
setOnCheckedChangeListener(listener(scope, events::trySend))
events.invokeOnClose { setOnCheckedChangeListener(null) }
events.trySend(checkedChipIds)
setOnCheckedStateChangeListener(listener(scope, events::trySend))
events.invokeOnClose { setOnCheckedStateChangeListener(null) }
}

/**
* Perform an action on checked view ID changes in [ChipGroup], inside new [CoroutineScope].
* Perform an action on checked view IDs changes in [ChipGroup], inside new [CoroutineScope].
*
* *Warning:* The created actor uses [ChipGroup.setOnCheckedChangeListener]. Only one actor can be
* used at a time.
* *Warning:* The created actor uses [ChipGroup.setOnCheckedStateChangeListener]. Only one actor can
* be used at a time.
*
* @param capacity Capacity of the channel's buffer (no buffer by default)
* @param action An action to perform
*/
suspend fun ChipGroup.checkedChanges(
capacity: Int = Channel.RENDEZVOUS,
action: suspend (Int) -> Unit
action: suspend (List<Int>) -> Unit
) = coroutineScope {
checkedChanges(this, capacity, action)
}

/**
* Create a channel of the checked view ID changes in [ChipGroup].
* Create a channel of the checked view IDs changes in [ChipGroup].
*
* *Warning:* Only in single selection mode.
* *Warning:* The created channel uses [ChipGroup.setOnCheckedChangeListener]. Only one channel can
* be used at a time.
* *Warning:* The created channel uses [ChipGroup.setOnCheckedStateChangeListener]. Only one channel
* can be used at a time.
*
* *Note:* A value will be emitted immediately.
* *Note:* When the selection is cleared, checkedId is [View.NO_ID].
* *Note:* When the selection is cleared, checkedIds will be an empty list.
*
* Example:
*
* ```
* launch {
* chipGroup.checkedChanges(scope)
* .consumeEach { /* handle checked view */ }
* .consumeEach { /* handle checked ids */ }
* }
* ```
*
Expand All @@ -99,29 +96,27 @@ suspend fun ChipGroup.checkedChanges(
fun ChipGroup.checkedChanges(
scope: CoroutineScope,
capacity: Int = Channel.RENDEZVOUS
): ReceiveChannel<Int> = corbindReceiveChannel(capacity) {
checkSelectionMode(this@checkedChanges)
trySend(checkedChipId)
setOnCheckedChangeListener(listener(scope, ::trySend))
invokeOnClose { setOnCheckedChangeListener(null) }
): ReceiveChannel<List<Int>> = corbindReceiveChannel(capacity) {
trySend(checkedChipIds)
setOnCheckedStateChangeListener(listener(scope, ::trySend))
invokeOnClose { setOnCheckedStateChangeListener(null) }
}

/**
* Create a flow of the checked view ID changes in [ChipGroup].
* Create a flow of the checked view IDs changes in [ChipGroup].
*
* *Warning:* Only in single selection mode.
* *Warning:* The created flow uses [ChipGroup.setOnCheckedChangeListener]. Only one flow can be
* used at a time.
* *Warning:* The created flow uses [ChipGroup.setOnCheckedStateChangeListener]. Only one flow can
* be used at a time.
*
* *Note:* A value will be emitted immediately.
* *Note:* When the selection is cleared, checkedId is [View.NO_ID].
* *Note:* When the selection is cleared, checkedIds will be an empty list.
*
* Examples:
*
* ```
* // handle initial value
* chipGroup.checkedChanges()
* .onEach { /* handle checked view */ }
* .onEach { /* handle checked ids */ }
* .flowWithLifecycle(lifecycle)
* .launchIn(lifecycleScope) // lifecycle-runtime-ktx
*
Expand All @@ -134,27 +129,15 @@ fun ChipGroup.checkedChanges(
* ```
*/
@CheckResult
fun ChipGroup.checkedChanges(): InitialValueFlow<Int> = channelFlow {
checkSelectionMode(this@checkedChanges)
setOnCheckedChangeListener(listener(this, ::trySend))
awaitClose { setOnCheckedChangeListener(null) }
}.asInitialValueFlow(checkedChipId)

private fun checkSelectionMode(group: ChipGroup) {
check(group.isSingleSelection) { "The ChipGroup is not in single selection mode." }
}
fun ChipGroup.checkedChanges(): InitialValueFlow<List<Int>> = channelFlow {
setOnCheckedStateChangeListener(listener(this, ::trySend))
awaitClose { setOnCheckedStateChangeListener(null) }
}.asInitialValueFlow(checkedChipIds)

@CheckResult
private fun listener(
scope: CoroutineScope,
emitter: (Int) -> Unit
) = object : ChipGroup.OnCheckedChangeListener {

private var lastChecked = View.NO_ID
override fun onCheckedChanged(group: ChipGroup, checkedId: Int) {
if (scope.isActive && checkedId != lastChecked) {
lastChecked = checkedId
emitter(checkedId)
}
}
emitter: (List<Int>) -> Unit
) = ChipGroup.OnCheckedStateChangeListener { _, checkedIds ->
if (scope.isActive) { emitter(checkedIds) }
}
2 changes: 1 addition & 1 deletion corbind-navigation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
To add androidx navigation bindings, import `corbind-navigation` module:

```groovy
implementation 'ru.ldralighieri.corbind:corbind-navigation:1.5.3'
implementation 'ru.ldralighieri.corbind:corbind-navigation:1.5.4'
```

## List of extensions
Expand Down
2 changes: 1 addition & 1 deletion corbind-recyclerview/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
To add androidx recyclerview bindings, import `corbind-recyclerview` module:

```groovy
implementation 'ru.ldralighieri.corbind:corbind-recyclerview:1.5.3'
implementation 'ru.ldralighieri.corbind:corbind-recyclerview:1.5.4'
```

## List of extensions
Expand Down
2 changes: 1 addition & 1 deletion corbind-slidingpanelayout/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
To add androidx slidingpanelayout bindings, import `corbind-slidingpanelayout` module:

```groovy
implementation 'ru.ldralighieri.corbind:corbind-slidingpanelayout:1.5.3'
implementation 'ru.ldralighieri.corbind:corbind-slidingpanelayout:1.5.4'
```

## List of extensions
Expand Down
Loading

0 comments on commit 7cd6240

Please sign in to comment.