diff options
author | Allan Wang <me@allanwang.ca> | 2018-09-26 14:56:44 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-26 14:56:44 -0400 |
commit | 438affb07ae106e490884fafa3c2dd825e7649a4 (patch) | |
tree | b94e182bf4d083af049120a6b5f94f82c4595318 /app/src/main/kotlin/com/pitchedapps/frost/injectors | |
parent | c5e769deabeb80d7257b85c5c3d802cf46e6b191 (diff) | |
download | frost-438affb07ae106e490884fafa3c2dd825e7649a4.tar.gz frost-438affb07ae106e490884fafa3c2dd825e7649a4.tar.bz2 frost-438affb07ae106e490884fafa3c2dd825e7649a4.zip |
Cleanup (#1087)
* Feature/download manager (#855)
* Add initial github release check
* Create update service
* Clean old manager directory
* Update kau
* Update updateActivity snippet
* Add back gradle keys
* Remove update service functionality
* Update changelog
* Misc (#865)
* Clean up git code
* Update download link
* Update theme
* Reorder settings, resolvees #856
* Do not log undeliverable exception
* Handle potential lack of webview
* Set notification epoch default to now, resolves #857
* Fix notification epoch time init
* Update changelog
* Update theme
* Add slack url, resolves #880
* Prepare for image update
* Fix view full image (#882)
* Test including full photo viewer
* Test cookie in glide
* Fix parser and add redirects to view full image
* Update changelog
* Fix compilation and add new keys
* Update all versions
* Fix signing configs
* Fix exoplayer api update
* Change string usage
* Test scss on travis
* Test with node_js flag
* Add back css
* Update versions and fix video view
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/injectors')
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/injectors/JsInjector.kt | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/injectors/JsInjector.kt b/app/src/main/kotlin/com/pitchedapps/frost/injectors/JsInjector.kt index 1698ae13..e45e86b1 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/injectors/JsInjector.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/injectors/JsInjector.kt @@ -5,6 +5,7 @@ import com.pitchedapps.frost.utils.L import com.pitchedapps.frost.web.FrostWebViewClient import io.reactivex.Single import io.reactivex.android.schedulers.AndroidSchedulers +import io.reactivex.disposables.Disposable import io.reactivex.subjects.SingleSubject import org.apache.commons.text.StringEscapeUtils import java.util.* @@ -76,28 +77,29 @@ interface InjectorContract { /** * Helper method to inject multiple functions simultaneously with a single callback */ -fun WebView.jsInject(vararg injectors: InjectorContract, callback: ((Int) -> Unit)? = null) { +fun WebView.jsInject(vararg injectors: InjectorContract, callback: ((Int) -> Unit)? = null): Disposable? { val validInjectors = injectors.filter { it != JsActions.EMPTY } if (validInjectors.isEmpty()) { callback?.invoke(0) - return + return null } L.d { "Injecting ${validInjectors.size} items" } if (callback == null) { validInjectors.forEach { it.inject(this) } - return + return null } - val observables = Array(validInjectors.size, { SingleSubject.create<Unit>() }) - Single.zip<Unit, Int>(observables.asList(), { it.size }) + val observables = Array(validInjectors.size) { SingleSubject.create<Unit>() } + val disposable = Single.zip<Unit, Int>(observables.asList()) { it.size } .observeOn(AndroidSchedulers.mainThread()) .subscribe { res, _ -> callback(res) } (0 until validInjectors.size).forEach { i -> - validInjectors[i].inject(this, { + validInjectors[i].inject(this) { observables[i].onSuccess(Unit) - }) + } } + return disposable } fun FrostWebViewClient.jsInject(vararg injectors: InjectorContract, |