Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
dmdevgo committed Mar 28, 2019
2 parents 91ec3df + e5caab1 commit 7ab0320
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 47 deletions.
16 changes: 8 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
buildscript {
ext.kotlinVersion = '1.2.71'
ext.kotlinVersion = '1.3.21'
repositories {
jcenter()
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
classpath 'com.android.tools.build:gradle:3.3.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
}
}

allprojects {
repositories {
jcenter()
google()
jcenter()
}
}

Expand All @@ -25,7 +25,7 @@ ext {
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 28
buildToolsVersion = '28.0.2'
buildToolsVersion = '28.0.3'

supportVersion = '28.0.0'
supportAppCompat = "com.android.support:appcompat-v7:$supportVersion"
Expand All @@ -36,11 +36,11 @@ ext {

kotlinStdlib = "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"

rxJava2 = "io.reactivex.rxjava2:rxjava:2.2.2"
rxJava2 = "io.reactivex.rxjava2:rxjava:2.2.8"
rxRelay2 = "com.jakewharton.rxrelay2:rxrelay:2.1.0"
rxAndroid2 = "io.reactivex.rxjava2:rxandroid:2.1.0"

rxBinding2Version = '2.1.1'
rxBinding2Version = '2.2.0'
rxBindingKotlin = "com.jakewharton.rxbinding2:rxbinding-kotlin:$rxBinding2Version"
rxBindingSupportV4Kotlin = "com.jakewharton.rxbinding2:rxbinding-support-v4-kotlin:$rxBinding2Version"
rxBindingSupportV7Kotlin = "com.jakewharton.rxbinding2:rxbinding-appcompat-v7-kotlin:$rxBinding2Version"
Expand All @@ -49,5 +49,5 @@ ext {
outlast = "me.jeevuz.outlast:outlast:1.1"

junitKotlin = "org.jetbrains.kotlin:kotlin-test-junit:$kotlinVersion"
mockitoKotlin = 'com.nhaarman.mockitokotlin2:mockito-kotlin:2.0.0-RC2'
mockitoKotlin = 'com.nhaarman.mockitokotlin2:mockito-kotlin:2.1.0'
}
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Tue Oct 02 20:33:55 MSK 2018
#Thu Mar 28 23:45:32 MSK 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
6 changes: 3 additions & 3 deletions rxpm/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ android {
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

sourceSets {
Expand Down Expand Up @@ -72,7 +72,7 @@ ext {
bintrayName = 'RxPM'
publishedGroupId = 'me.dmdev.rxpm'
artifact = 'rxpm'
libraryVersion = '1.2.3'
libraryVersion = '1.2.4'
gitUrl = 'https://github.com/dmdevgo/RxPM'
allLicenses = ['MIT']
}
Expand Down
10 changes: 4 additions & 6 deletions rxpm/src/main/kotlin/me/dmdev/rxpm/PmExtensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ inline fun <T> Observable<T>.skipWhileInProgress(progressState: Observable<Boole
Pair(t, inProgress)
}
)
.filter { !it.second }
.map { it.first }
.filter { (_, inProgress) -> !inProgress }
.map { (item, _) -> item }
}

/**
Expand Down Expand Up @@ -103,16 +103,14 @@ inline fun <T> Observable<T>.bufferWhileIdle(
isIdle
.distinctUntilChanged()
.filter { it },
Function<Boolean, Observable<Boolean>> { _ ->
Function<Boolean, Observable<Boolean>> {
isIdle
.distinctUntilChanged()
.filter { it.not() }
}
)
.map {
.flatMapIterable {
if (bufferSize != null) it.takeLast(bufferSize) else it
}
.flatMapIterable { it }

)
}
19 changes: 6 additions & 13 deletions rxpm/src/main/kotlin/me/dmdev/rxpm/PresentationModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,12 @@ abstract class PresentationModel {
@Suppress("WHEN_ENUM_CAN_BE_NULL_IN_JAVA")
when (it) {
Lifecycle.CREATED -> onCreate()
Lifecycle.BINDED -> onBind()
Lifecycle.BINDED -> {
unbind.accept(false)
onBind()
}
Lifecycle.UNBINDED -> {
unbind.accept(true)
compositeUnbind.clear()
onUnbind()
}
Expand All @@ -64,17 +68,6 @@ abstract class PresentationModel {
}
}
}

lifecycle
.takeUntil { it == Lifecycle.DESTROYED }
.subscribe {
when (it) {
Lifecycle.BINDED -> unbind.accept(false)
Lifecycle.UNBINDED -> unbind.accept(true)
else -> {
}
}
}
}

/**
Expand Down Expand Up @@ -331,7 +324,7 @@ abstract class PresentationModel {
/**
* Observable of this [Command].
*/
val observable =
val observable: Observable<T> =
if (bufferSize == 0) {
relay.asObservable()
} else {
Expand Down
2 changes: 1 addition & 1 deletion rxpm/src/main/kotlin/me/dmdev/rxpm/widget/InputControl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ internal inline fun InputControl.bind(
.observeOn(AndroidSchedulers.mainThread())
.subscribe {
val editable = editText.text
if (!it.contentEquals(editable)) {
if (!it!!.contentEquals(editable)) {
editing = true
if (editable is Spanned) {
val ss = SpannableString(it)
Expand Down
8 changes: 4 additions & 4 deletions rxpm/src/test/kotlin/me/dmdev/rxpm/util/SchedulersRule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import org.junit.rules.ExternalResource

class SchedulersRule : ExternalResource() {

lateinit var testScheduler: TestScheduler
private lateinit var testScheduler: TestScheduler

override fun before() {
RxJavaPlugins.setIoSchedulerHandler { _ -> Schedulers.trampoline() }
RxAndroidPlugins.setInitMainThreadSchedulerHandler { _ -> Schedulers.trampoline() }
RxJavaPlugins.setIoSchedulerHandler { Schedulers.trampoline() }
RxAndroidPlugins.setInitMainThreadSchedulerHandler { Schedulers.trampoline() }

testScheduler = TestScheduler()
RxJavaPlugins.setComputationSchedulerHandler { _ -> testScheduler }
RxJavaPlugins.setComputationSchedulerHandler { testScheduler }
}

override fun after() {
Expand Down
7 changes: 6 additions & 1 deletion sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ android {
versionName "1.0"
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
Expand All @@ -39,6 +44,6 @@ dependencies {
implementation rootProject.rxBindingSupportV7Kotlin

implementation "com.jakewharton.timber:timber:4.7.1"
implementation 'com.googlecode.libphonenumber:libphonenumber:8.9.9'
implementation 'com.googlecode.libphonenumber:libphonenumber:8.9.14'

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package me.dmdev.rxpm.sample.counter

import android.os.Bundle
import com.jakewharton.rxbinding2.view.clicks
import com.jakewharton.rxbinding2.widget.text
import kotlinx.android.synthetic.main.activity_counter.*
import me.dmdev.rxpm.base.PmSupportActivity
import me.dmdev.rxpm.sample.R
Expand All @@ -18,9 +17,9 @@ class CounterActivity : PmSupportActivity<CounterPm>() {

override fun onBindPresentationModel(pm: CounterPm) {

pm.count.observable.map { it.toString() } bindTo counterText.text()
pm.minusButtonEnubled bindTo minusButton::setEnabled
pm.plusButtonEnubled bindTo plusButton::setEnabled
pm.count.observable.map { it.toString() } bindTo counterText::setText
pm.minusButtonEnabled bindTo minusButton::setEnabled
pm.plusButtonEnabled bindTo plusButton::setEnabled

minusButton.clicks() bindTo pm.minusButtonClicks
plusButton.clicks() bindTo pm.plusButtonClicks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ class CounterPm : PresentationModel() {
}

val count = State(initialValue = 0)
val minusButtonEnubled = State(false)
val plusButtonEnubled = State(false)
val minusButtonEnabled = State(false)
val plusButtonEnabled = State(false)

val minusButtonClicks = Action<Unit>()
val plusButtonClicks = Action<Unit>()
Expand All @@ -20,12 +20,12 @@ class CounterPm : PresentationModel() {

count.observable
.map { it > 0 }
.subscribe(minusButtonEnubled.consumer)
.subscribe(minusButtonEnabled.consumer)
.untilDestroy()

count.observable
.map { it < MAX_COUNT }
.subscribe(plusButtonEnubled.consumer)
.subscribe(plusButtonEnabled.consumer)
.untilDestroy()

minusButtonClicks.observable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class CodeConfirmationScreen : Screen<CodeConfirmationPm>() {

override fun providePresentationModel(): CodeConfirmationPm {
return CodeConfirmationPm(
arguments!!.getString(ARG_PHONE),
arguments!!.getString(ARG_PHONE)!!,
App.component.resourceProvider,
App.component.authModel
)
Expand Down

0 comments on commit 7ab0320

Please sign in to comment.