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
/** | |
* 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) { |
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
plugins { | |
id "org.sonarqube" version "2.7" | |
} | |
apply plugin: 'com.android.application' | |
apply plugin: 'kotlin-android' | |
apply plugin: 'kotlin-android-extensions' |
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
@Test | |
fun testSuccessfulLogin() { | |
// Agange | |
val vm = LoginViewModel(environment()) | |
val loginSuccess = TestSubscriber<Void>() | |
vm.outputs.loginSuccess().subscribe(loginSuccess) | |
vm.inputs.email("[email protected]") | |
vm.inputs.password("danisawesome") | |
// Act |
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
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 |
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
/* | |
* 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 |
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
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 | |
} | |
} |
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
if (product.getType == productType.TYPE_A) { | |
// ... | |
} else if (product.getType == productType.TYPE_B) { | |
// ... | |
} else if (...) { | |
// ... | |
} | |
else { | |
// ... | |
} |
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
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") | |
); |
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
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) { |
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
@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("[email protected]"); | |
vm.inputs.password("danisawesome"); |
NewerOlder