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
public actual fun launch( | |
context: CoroutineContext = DefaultDispatcher, | |
start: CoroutineStart = CoroutineStart.DEFAULT, | |
parent: Job? = null, | |
block: suspend CoroutineScope.() -> Unit | |
): Job { | |
val newContext = newCoroutineContext(context, parent) | |
val coroutine = if (start.isLazy) | |
LazyStandaloneCoroutine(newContext, block) else | |
StandaloneCoroutine(newContext, active = true) |
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
abstract fun resume(value: T) | |
abstract fun resumeWithException(exception: Throwable) |
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
@Override | |
protected void subscribeActual(final SingleObserver<? super T> s) { | |
source.subscribe(new ObserveOnSingleObserver<T>(s, scheduler)); | |
} |
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
public static LoadWeatherForecastTask extends AsyncTask<String, Void, WeatherForecast> { | |
private Activity activity; | |
LoadWeatherForecastTask(Activity activity) { | |
this.activity = activity; | |
} | |
} |
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
public static void main() { | |
System.out.println("Hello, world"); | |
} |
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
launch { | |
broadcast.consumeEach { | |
delay(300) | |
val foundRepositories = | |
apiClient.searchRepositories(it).await() | |
repos.adapter = ReposAdapter( | |
foundRepositories.map { it.full_name }, | |
this@RepositoriesActivity | |
) | |
} |
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
publishSubject | |
.debounce(300, TimeUnit.MILLISECONDS) | |
.distinctUntilChanged() | |
.switchMap { | |
searchQuery -> apiClientRxImpl.searchRepositories(searchQuery) | |
} | |
.subscribeOn(Schedulers.io()) | |
.observeOn(AndroidSchedulers.mainThread()) | |
.subscribe({ | |
repos.adapter = ReposAdapter( |
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 connectionObserveration(context: Context): Disposable? { | |
if ((firstObserver == null || firstObserver!!.isDisposed) && (secondObserver == null || secondObserver!!.isDisposed())) { | |
secondObserver = ReactiveNetwork.observeNetworkConnectivity(context) | |
.subscribeOn(AndroidSchedulers.mainThread()) | |
.filter(ConnectivityPredicate.hasState(NetworkInfo.State.CONNECTED, NetworkInfo.State.DISCONNECTED)) | |
.observeOn(AndroidSchedulers.mainThread()) | |
.subscribe({ connectivity -> | |
if (connectivity.state == NetworkInfo.State.CONNECTED) { | |
firstObserver = ReactiveNetwork.observeInternetConnectivity() | |
.subscribeOn(AndroidSchedulers.mainThread()) |
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
ObserveOnSingleObserver(SingleObserver<? super T> actual, Scheduler scheduler) { | |
this.actual = actual; | |
this.scheduler = scheduler; | |
} | |
@Override | |
public void onSuccess(T value) { | |
this.value = value; | |
Disposable d = scheduler.scheduleDirect(this); | |
DisposableHelper.replace(this, d); |
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
@Override | |
protected void subscribeActual(final SingleObserver<? super T> s) { | |
final SubscribeOnObserver<T> parent = new SubscribeOnObserver<T>(s, source); | |
s.onSubscribe(parent); | |
Disposable f = scheduler.scheduleDirect(parent); | |
parent.task.replace(f); | |
} |