Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
LDRAlighieri committed Sep 14, 2019
2 parents 2bffbe4 + 281ce96 commit d353f5d
Show file tree
Hide file tree
Showing 121 changed files with 526 additions and 976 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,14 @@
# ChangeLog


## Version 1.1.2

* Update: Kotlin coroutines modules dependency to v1.3.1
* Update: Android sdk to v29
* Update: Updated sample
* Fix: Fixed various inaccuracies, refactoring


## Version 1.1.0

* New: ViewPager2 module
Expand Down
23 changes: 12 additions & 11 deletions README.md
Expand Up @@ -2,6 +2,7 @@

[![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.3.50-blue.svg)](https://kotlinlang.org)
[![Kotlin Coroutines Version](https://img.shields.io/badge/Coroutines-v1.3.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)
Expand All @@ -21,25 +22,25 @@ This library is for Android applications only. Help you to transform Android UI

Platform bindings:
```groovy
implementation 'ru.ldralighieri.corbind:corbind:1.1.0'
implementation 'ru.ldralighieri.corbind:corbind:1.1.2'
```

AndroidX library bindings:
```groovy
implementation 'ru.ldralighieri.corbind:corbind-appcompat:1.1.0'
implementation 'ru.ldralighieri.corbind:corbind-core:1.1.0'
implementation 'ru.ldralighieri.corbind:corbind-drawerlayout:1.1.0'
implementation 'ru.ldralighieri.corbind:corbind-leanback:1.1.0'
implementation 'ru.ldralighieri.corbind:corbind-recyclerview:1.1.0'
implementation 'ru.ldralighieri.corbind:corbind-slidingpanelayout:1.1.0'
implementation 'ru.ldralighieri.corbind:corbind-swiperefreshlayout:1.1.0'
implementation 'ru.ldralighieri.corbind:corbind-viewpager:1.1.0'
implementation 'ru.ldralighieri.corbind:corbind-viewpager2:1.1.0'
implementation 'ru.ldralighieri.corbind:corbind-appcompat:1.1.2'
implementation 'ru.ldralighieri.corbind:corbind-core:1.1.2'
implementation 'ru.ldralighieri.corbind:corbind-drawerlayout:1.1.2'
implementation 'ru.ldralighieri.corbind:corbind-leanback:1.1.2'
implementation 'ru.ldralighieri.corbind:corbind-recyclerview:1.1.2'
implementation 'ru.ldralighieri.corbind:corbind-slidingpanelayout:1.1.2'
implementation 'ru.ldralighieri.corbind:corbind-swiperefreshlayout:1.1.2'
implementation 'ru.ldralighieri.corbind:corbind-viewpager:1.1.2'
implementation 'ru.ldralighieri.corbind:corbind-viewpager2:1.1.2'
```

Google 'material' library bindings:
```groovy
implementation 'ru.ldralighieri.corbind:corbind-material:1.1.0'
implementation 'ru.ldralighieri.corbind:corbind-material:1.1.2'
```


Expand Down
12 changes: 6 additions & 6 deletions build.gradle
Expand Up @@ -19,12 +19,12 @@ buildscript {
ext {
versions = [
'kotlin' : '1.3.50',
'kotlin_coroutines' : '1.3.0',
'kotlin_coroutines' : '1.3.1',
'android_gradle' : '3.5.0',
'androidx' : [
'core' : '1.0.2',
'core' : '1.1.0',
'annotation' : '1.1.0',
'appcompat' : '1.0.2',
'appcompat' : '1.1.0',
'drawerlayout' : '1.0.0',
'leanback' : '1.0.0',
'recycler_view' : '1.0.0',
Expand Down Expand Up @@ -66,9 +66,9 @@ buildscript {
]

buildConfig = [
'compileSdk': 28,
'compileSdk': 29,
'minSdk': 14,
'targetSdk': 28
'targetSdk': 29
]
}

Expand All @@ -95,7 +95,7 @@ buildscript {

plugins {
id "com.diffplug.gradle.spotless" version "3.24.2"
id 'com.github.ben-manes.versions' version '0.22.0'
id 'com.github.ben-manes.versions' version '0.25.0'
id "io.gitlab.arturbosch.detekt" version "1.0.1"
}

Expand Down
2 changes: 1 addition & 1 deletion corbind-appcompat/README.md
Expand Up @@ -4,7 +4,7 @@
To add androidx appcompat bindings, import `corbind-appcompat` module:

```groovy
implementation 'ru.ldralighieri.corbind:corbind-appcompat:1.1.0'
implementation 'ru.ldralighieri.corbind:corbind-appcompat:1.1.2'
```

## List of extensions
Expand Down
Expand Up @@ -44,7 +44,6 @@ fun ActionMenuView.itemClicks(
capacity: Int = Channel.RENDEZVOUS,
action: suspend (MenuItem) -> Unit
) {

val events = scope.actor<MenuItem>(Dispatchers.Main, capacity) {
for (item in channel) action(item)
}
Expand All @@ -54,7 +53,7 @@ fun ActionMenuView.itemClicks(
}

/**
* Perform an action on clicked menu item in [ActionMenuView] inside new [CoroutineScope].
* Perform an action on clicked menu item in [ActionMenuView], inside new [CoroutineScope].
*
* @param capacity Capacity of the channel's buffer (no buffer by default)
* @param action An action to perform
Expand All @@ -63,13 +62,7 @@ suspend fun ActionMenuView.itemClicks(
capacity: Int = Channel.RENDEZVOUS,
action: suspend (MenuItem) -> Unit
) = coroutineScope {

val events = actor<MenuItem>(Dispatchers.Main, capacity) {
for (item in channel) action(item)
}

setOnMenuItemClickListener(listener(this, events::offer))
events.invokeOnClose { setOnMenuItemClickListener(null) }
itemClicks(this, capacity, action)
}

/**
Expand Down
Expand Up @@ -46,7 +46,6 @@ fun PopupMenu.dismisses(
capacity: Int = Channel.RENDEZVOUS,
action: suspend () -> Unit
) {

val events = scope.actor<Unit>(Dispatchers.Main, capacity) {
for (unit in channel) action()
}
Expand All @@ -56,7 +55,7 @@ fun PopupMenu.dismisses(
}

/**
* Perform an action on [PopupMenu] dismiss events inside new [CoroutineScope].
* Perform an action on [PopupMenu] dismiss events, inside new [CoroutineScope].
*
* *Warning:* The created actor uses [PopupMenu.setOnDismissListener] to emit dismiss change.
* Only one actor can be used for a view at a time.
Expand All @@ -68,13 +67,7 @@ suspend fun PopupMenu.dismisses(
capacity: Int = Channel.RENDEZVOUS,
action: suspend () -> Unit
) = coroutineScope {

val events = actor<Unit>(Dispatchers.Main, capacity) {
for (unit in channel) action()
}

setOnDismissListener(listener(this, events::offer))
events.invokeOnClose { setOnMenuItemClickListener(null) }
dismisses(this, capacity, action)
}

/**
Expand Down
Expand Up @@ -47,7 +47,6 @@ fun PopupMenu.itemClicks(
capacity: Int = Channel.RENDEZVOUS,
action: suspend (MenuItem) -> Unit
) {

val events = scope.actor<MenuItem>(Dispatchers.Main, capacity) {
for (item in channel) action(item)
}
Expand All @@ -57,7 +56,7 @@ fun PopupMenu.itemClicks(
}

/**
* Perform an action on clicked item in [PopupMenu] inside new [CoroutineScope].
* Perform an action on clicked item in [PopupMenu], inside new [CoroutineScope].
*
* *Warning:* The created actor uses [PopupMenu.setOnMenuItemClickListener] to emit dismiss
* change. Only one actor can be used for a view at a time.
Expand All @@ -69,13 +68,7 @@ suspend fun PopupMenu.itemClicks(
capacity: Int = Channel.RENDEZVOUS,
action: suspend (MenuItem) -> Unit
) = coroutineScope {

val events = actor<MenuItem>(Dispatchers.Main, capacity) {
for (item in channel) action(item)
}

setOnMenuItemClickListener(listener(this, events::offer))
events.invokeOnClose { setOnMenuItemClickListener(null) }
itemClicks(this, capacity, action)
}

/**
Expand Down
Expand Up @@ -49,18 +49,17 @@ fun SearchView.queryTextChangeEvents(
capacity: Int = Channel.RENDEZVOUS,
action: suspend (SearchViewQueryTextEvent) -> Unit
) {

val events = scope.actor<SearchViewQueryTextEvent>(Dispatchers.Main, capacity) {
for (event in channel) action(event)
}

events.offer(SearchViewQueryTextEvent(this, query, false))
setOnQueryTextListener(listener(scope = scope, searchView = this, emitter = events::offer))
setOnQueryTextListener(listener(scope, this, events::offer))
events.invokeOnClose { setOnQueryTextListener(null) }
}

/**
* Perform an action on [query text events][SearchViewQueryTextEvent] on [SearchView] inside new
* Perform an action on [query text events][SearchViewQueryTextEvent] on [SearchView], inside new
* [CoroutineScope].
*
* @param capacity Capacity of the channel's buffer (no buffer by default)
Expand All @@ -70,15 +69,7 @@ suspend fun SearchView.queryTextChangeEvents(
capacity: Int = Channel.RENDEZVOUS,
action: suspend (SearchViewQueryTextEvent) -> Unit
) = coroutineScope {

val events = actor<SearchViewQueryTextEvent>(Dispatchers.Main, capacity) {
for (event in channel) action(event)
}

events.offer(SearchViewQueryTextEvent(this@queryTextChangeEvents, query, false))
setOnQueryTextListener(listener(scope = this, searchView = this@queryTextChangeEvents,
emitter = events::offer))
events.invokeOnClose { setOnQueryTextListener(null) }
queryTextChangeEvents(this, capacity, action)
}

/**
Expand Down
Expand Up @@ -43,7 +43,6 @@ fun SearchView.queryTextChanges(
capacity: Int = Channel.RENDEZVOUS,
action: suspend (CharSequence) -> Unit
) {

val events = scope.actor<CharSequence>(Dispatchers.Main, capacity) {
for (chars in channel) action(chars)
}
Expand All @@ -54,7 +53,7 @@ fun SearchView.queryTextChanges(
}

/**
* Perform an action on character sequences for query text changes on [SearchView] inside new
* Perform an action on character sequences for query text changes on [SearchView], inside new
* [CoroutineScope].
*
* @param capacity Capacity of the channel's buffer (no buffer by default)
Expand All @@ -64,14 +63,7 @@ suspend fun SearchView.queryTextChanges(
capacity: Int = Channel.RENDEZVOUS,
action: suspend (CharSequence) -> Unit
) = coroutineScope {

val events = actor<CharSequence>(Dispatchers.Main, capacity) {
for (chars in channel) action(chars)
}

events.offer(query)
setOnQueryTextListener(listener(this, events::offer))
events.invokeOnClose { setOnQueryTextListener(null) }
queryTextChanges(this, capacity, action)
}

/**
Expand Down
Expand Up @@ -44,7 +44,6 @@ fun Toolbar.itemClicks(
capacity: Int = Channel.RENDEZVOUS,
action: suspend (MenuItem) -> Unit
) {

val events = scope.actor<MenuItem>(Dispatchers.Main, capacity) {
for (item in channel) action(item)
}
Expand All @@ -54,7 +53,7 @@ fun Toolbar.itemClicks(
}

/**
* Perform an action on the clicked item in [Toolbar] menu inside new [CoroutineScope].
* Perform an action on the clicked item in [Toolbar] menu, inside new [CoroutineScope].
*
* @param capacity Capacity of the channel's buffer (no buffer by default)
* @param action An action to perform
Expand All @@ -63,13 +62,7 @@ suspend fun Toolbar.itemClicks(
capacity: Int = Channel.RENDEZVOUS,
action: suspend (MenuItem) -> Unit
) = coroutineScope {

val events = actor<MenuItem>(Dispatchers.Main, capacity) {
for (item in channel) action(item)
}

setOnMenuItemClickListener(listener(this, events::offer))
events.invokeOnClose { setOnMenuItemClickListener(null) }
itemClicks(this, capacity, action)
}

/**
Expand Down
Expand Up @@ -47,7 +47,6 @@ fun Toolbar.navigationClicks(
capacity: Int = Channel.RENDEZVOUS,
action: suspend () -> Unit
) {

val events = scope.actor<Unit>(Dispatchers.Main, capacity) {
for (unit in channel) action()
}
Expand All @@ -57,7 +56,7 @@ fun Toolbar.navigationClicks(
}

/**
* Perform an action on [Toolbar] navigation click events inside new [CoroutineScope].
* Perform an action on [Toolbar] navigation click events, inside new [CoroutineScope].
*
* *Warning:* The created actor uses [Toolbar.setNavigationOnClickListener] to emit clicks. Only
* one actor can be used for a view at a time.
Expand All @@ -69,13 +68,7 @@ suspend fun Toolbar.navigationClicks(
capacity: Int = Channel.RENDEZVOUS,
action: suspend () -> Unit
) = coroutineScope {

val events = actor<Unit>(Dispatchers.Main, capacity) {
for (unit in channel) action()
}

setNavigationOnClickListener(listener(this, events::offer))
events.invokeOnClose { setNavigationOnClickListener(null) }
navigationClicks(this, capacity, action)
}

/**
Expand Down
2 changes: 1 addition & 1 deletion corbind-core/README.md
Expand Up @@ -4,7 +4,7 @@
To add androidx core bindings, import `corbind-core` module:

```groovy
implementation 'ru.ldralighieri.corbind:corbind-core:1.1.0'
implementation 'ru.ldralighieri.corbind:corbind-core:1.1.2'
```

## List of extensions
Expand Down
Expand Up @@ -44,7 +44,6 @@ fun NestedScrollView.scrollChangeEvents(
capacity: Int = Channel.RENDEZVOUS,
action: suspend (ViewScrollChangeEvent) -> Unit
) {

val events = scope.actor<ViewScrollChangeEvent>(Dispatchers.Main, capacity) {
for (event in channel) action(event)
}
Expand All @@ -56,7 +55,7 @@ fun NestedScrollView.scrollChangeEvents(
}

/**
* Perform an action on scroll-change events for [NestedScrollView] inside new [CoroutineScope].
* Perform an action on scroll-change events for [NestedScrollView], inside new [CoroutineScope].
*
* @param capacity Capacity of the channel's buffer (no buffer by default)
* @param action An action to perform
Expand All @@ -65,15 +64,7 @@ suspend fun NestedScrollView.scrollChangeEvents(
capacity: Int = Channel.RENDEZVOUS,
action: suspend (ViewScrollChangeEvent) -> Unit
) = coroutineScope {

val events = actor<ViewScrollChangeEvent>(Dispatchers.Main, capacity) {
for (event in channel) action(event)
}

setOnScrollChangeListener(listener(this, events::offer))
events.invokeOnClose {
setOnScrollChangeListener(null as NestedScrollView.OnScrollChangeListener?)
}
scrollChangeEvents(this, capacity, action)
}

/**
Expand Down
2 changes: 1 addition & 1 deletion corbind-drawerlayout/README.md
Expand Up @@ -4,7 +4,7 @@
To add androidx drawerlayout bindings, import `corbind-drawerlayout` module:

```groovy
implementation 'ru.ldralighieri.corbind:corbind-drawerlayout:1.1.0'
implementation 'ru.ldralighieri.corbind:corbind-drawerlayout:1.1.2'
```

## List of extensions
Expand Down

0 comments on commit d353f5d

Please sign in to comment.