Skip to content

Instantly share code, notes, and snippets.

/**
* toggleAutoDownflow() : method triggered by remote config, should
* be used when notifications based downflow is broken.
*/
private fun toggleAutoDownflow() {
automaticDownflowDisposable?.dispose()
isAutomaticDownflowActivated = remoteConfig.automaticDownflow.activated
automaticDownflowIntervalInMinutes = remoteConfig.automaticDownflow.intervalInMinutes
if (isAutomaticDownflowActivated) {
plugins {
id "org.sonarqube" version "2.7"
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
@Test
fun testSuccessfulLogin() {
// Agange
val vm = LoginViewModel(environment())
val loginSuccess = TestSubscriber<Void>()
vm.outputs.loginSuccess().subscribe(loginSuccess)
vm.inputs.email("hello@kickstarter.com")
vm.inputs.password("danisawesome")
// Act
@selmanon
selmanon / KCO-NOTES.txt
Last active April 17, 2019 12:37
Kotlin Coroutines
API (class) Key words : Job, Scope, Context, Dispatchers
- Suspending functions do not block the caller thread.
- Job (is a Element is a Context)
- A background job
- Can be cancled else a CancellationException is rised
- Had a lifecycle
- A Job had childs and can be a parent
- Cancelling a parent Job leads to cancel it's childs
/*
* Any array may be viewed as a number of "runs" of equal numbers.
* For example, the following array has two runs:
* 1, 1, 1, 2, 2
* Three 1's in a row form the first run, and two 2's form the second.
* This array has two runs of length one:
* 3, 4
* And this one has five runs:
* 1, 0, 1, 1, 1, 2, 0, 0, 0, 0, 0, 0, 0
* Your task is to implement the runs() function so that it returns the number
import kotlin.math.ceil
data class Cell(val i: Int, val j: Int, val isAlive: Boolean) {
operator fun get(i: Int, j: Int): Int {
if ((i < 0 || i >= 2) || (j < 0 || j >= 2)) return 0
else
return 0
}
}
if (product.getType == productType.TYPE_A) {
// ...
} else if (product.getType == productType.TYPE_B) {
// ...
} else if (...) {
// ...
}
else {
// ...
}
Observable
.just(1, 2, 3, 4, 5)
.filter(integer -> integer % 2 != 0)
.subscribe(
integer -> Log.i(TAG, String.valueOf(integer)),
error -> Log.e(TAG, "Error"),
() -> Log.i(TAG, "No more results")
);
Observable
.just(1, 2, 3, 4, 5)
.filter(new Func1<Integer, Boolean>() {
@Override
public Boolean call(Integer integer) {
return integer % 2 != 0;
}
}).subscribe(new Observer<Integer>() {
@Override
public void onSubscribe(Disposable d) {
@Test
public void testSuccessfulLogin() {
// Aragnge
final LoginViewModel vm = new LoginViewModel(environment());
final TestSubscriber<Void> loginSuccess = new TestSubscriber<>();
vm.outputs.loginSuccess().subscribe(loginSuccess);
vm.inputs.email("hello@kickstarter.com");
vm.inputs.password("danisawesome");