Created
February 5, 2019 17:48
-
-
Save eoinahern/95ad39a199b6d700f529fda4886b019d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val whatsappRelay: BehaviorRelay<Boolean> = BehaviorRelay.create() | |
val telegramRelay: BehaviorRelay<Boolean> = BehaviorRelay.create() | |
val checkTextValid: BehaviorRelay<Boolean> = BehaviorRelay.create() | |
val openAppIntentRelay: BehaviorRelay<Intent> = BehaviorRelay.create() | |
val checkShowTextUnderSend: BehaviorRelay<Boolean> = BehaviorRelay.create() | |
val messageSent: BehaviorRelay<Boolean> = BehaviorRelay.create() | |
fun checkAppsInstalled() { | |
val whatsappObs = Observable.just(packageManagerHelper.checkAppInstalledOrNot(whatsappPackage)) | |
val telegramObs = Observable.just(packageManagerHelper.checkAppInstalledOrNot(telegramPackage)) | |
compositeDisposables.add( | |
Observable.zip( | |
whatsappObs, | |
telegramObs, | |
BiFunction<Boolean, Boolean, Unit> { whatsApp, telegram -> | |
if (whatsApp) whatsappRelay.accept(whatsApp) | |
if (telegram) telegramRelay.accept(telegram) | |
if (whatsApp || telegram) checkShowTextUnderSend.accept(true) | |
}).execute() | |
.subscribe() | |
) | |
} | |
fun createOpenAppIntent(packageName: String) { | |
openAppIntentRelay.accept(packageManagerHelper.createOpenAppIntent(packageName)) | |
} | |
fun validateText(messageText: String) { | |
if (messageText.length >= 10) checkTextValid.accept(true) else checkTextValid.accept(false) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment