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
| private fun pullRequests(view: T): ConnectableObservable<Pair<List<PullRequest>, String>> { | |
| return Observable.combineLatest( | |
| view.intentPullToRefresh().startWith { Object() }, | |
| connectionProvider.connections(), | |
| BiFunction<Any, BitbucketConnection, BitbucketConnection> { _, conn -> conn } | |
| ).switchMap { (_, serverUrl, api, token) -> | |
| repositoriesStorage.selectedRepositories() | |
| .switchMap { list -> | |
| Observable.fromIterable(list) | |
| .flatMap { (slug, _, project) -> |
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
| private fun calculateTeamMembership(): Observable<Timed<Map<User, Density>>> { | |
| return Observable.combineLatest( | |
| connectionProvider.connections(), | |
| repositoriesStorage.selectedRepositories(), | |
| BiFunction<BitbucketConnection, List<Repository>, Observable<Timed<Map<User, Density>>>> { | |
| (userName, _, api, token), repositories -> | |
| return@BiFunction Observable.fromIterable(repositories) | |
| .flatMap { (slug, _, project) -> | |
| BitbucketApi.queryPaged { start -> | |
| api.getPullRequests(token, project.key, slug, start, |
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
| fun currentNetwork(context: Context, | |
| scheduler: Scheduler = AndroidSchedulers.mainThread()) | |
| : Flowable<Network> { | |
| val connectivityManager = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager | |
| return Flowable.create<Network>({ emitter -> | |
| val worker = scheduler.createWorker() | |
| val emit = { network: Network -> | |
| worker.schedule { emitter.onNext(network) } |
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
| currentNetwork(this) | |
| .subscribe { | |
| Log.i("TMPTAG", "Current network: $it on thread: ${Thread.currentThread().name}") | |
| } |
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
| fun currentNetwork(context: Context): Flowable<Network> { | |
| val connectivityManager = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager | |
| return Flowable.create<Network>({ emitter -> | |
| emitter.onNext(Network.NONE) | |
| val request = NetworkRequest.Builder() | |
| .addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR) | |
| .build() | |
| val networkCallback = object: ConnectivityManager.NetworkCallback() { |
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
| enum class Network { | |
| NONE, | |
| CELLULAR | |
| } |
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
| static <T> Flowable<T> create(FlowableOnSubscribe<T> source, BackpressureStrategy mode) |
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
| sharedPreferenceValues(preferences, "key") | |
| .subscribe { Log.i("TMPTAG", "Obtained a new preferences value: $it") } |
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
| private fun contacts(): Flowable<SimpleContact> = | |
| Flowable.generate<SimpleContact, Cursor>( | |
| Callable<Cursor> { | |
| contentResolver.query(Contacts.CONTENT_URI, | |
| arrayOf(Contacts.DISPLAY_NAME, Contacts.STARRED), | |
| null, null, | |
| "${Contacts.DISPLAY_NAME} ASC") | |
| }, | |
| BiFunction<Cursor, Emitter<SimpleContact>, Cursor> { cursor, emitter -> |
NewerOlder