This file contains 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
package com.sdk.utils | |
import android.util.Log | |
import com.sdk.managers.NetworkAPIManager | |
import kotlinx.coroutines.experimental.CommonPool | |
import kotlinx.coroutines.experimental.Job | |
import kotlinx.coroutines.experimental.delay | |
import kotlinx.coroutines.experimental.launch | |
import java.util.concurrent.TimeUnit |
This file contains 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
package com.sdk.utils | |
import android.util.Log | |
import com.sdk.managers.NetworkAPIManager | |
import kotlinx.coroutines.experimental.CommonPool | |
import kotlinx.coroutines.experimental.Job | |
import kotlinx.coroutines.experimental.delay | |
import kotlinx.coroutines.experimental.launch | |
import java.util.concurrent.TimeUnit |
This file contains 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
/** | |
* Example using Kotlin Coroutines: | |
* https://kotlinlang.org/docs/tutorials/coroutines-basic-jvm.html | |
*/ | |
class SampleActivity: Activity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
launch (UI){ | |
delay(5, TimeUnit.SECONDS) |
This file contains 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 android.app.Activity | |
import android.os.Bundle | |
import android.widget.Toast | |
import kotlinx.coroutines.experimental.android.UI | |
import kotlinx.coroutines.experimental.delay | |
import kotlinx.coroutines.experimental.launch | |
import java.util.concurrent.TimeUnit | |
/** | |
* Example using Kotlin Coroutines: |
This file contains 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 io.mockk.* | |
import org.apache.logging.log4j.ThreadContext | |
import org.junit.Test | |
class Log4jExecutorTest { | |
class MyLog4jExecutor : Log4jExecutor() { | |
fun runBefore(t: Thread?, r: Runnable?) = beforeExecute(t, r) | |
} | |
@Test |
This file contains 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
dependency> | |
<groupId>junit</groupId> | |
<artifactId>junit</artifactId> | |
<version>4.11</version> | |
<scope>test</scope> | |
</dependency> | |
<dependency> | |
<groupId>org.jetbrains.kotlin</groupId> | |
<artifactId>kotlin-stdlib</artifactId> | |
<version>${kotlin.version}</version> |
This file contains 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
<dependency> | |
<groupId>junit</groupId> | |
<artifactId>junit</artifactId> | |
<version>4.11</version> | |
<scope>test</scope> | |
</dependency> | |
<dependency> | |
<groupId>org.jetbrains.kotlin</groupId> | |
<artifactId>kotlin-stdlib</artifactId> | |
<version>${kotlin.version}</version> |
This file contains 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 org.apache.logging.log4j.ThreadContext | |
import java.util.concurrent.LinkedBlockingQueue | |
import java.util.concurrent.ThreadPoolExecutor | |
import java.util.concurrent.TimeUnit | |
class Log4jExecutor : ThreadPoolExecutor(1, 1, | |
0L, TimeUnit.MILLISECONDS, | |
LinkedBlockingQueue()) { | |
override fun beforeExecute(t: Thread, r: Runnable) { |
This file contains 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 kotlinx.coroutines.experimental.Job | |
import kotlinx.coroutines.experimental.delay | |
import kotlinx.coroutines.experimental.launch | |
import kotlin.coroutines.experimental.CoroutineContext | |
/** | |
* Created by Pavel Aizendorf on 11-Apr-18. | |
*/ | |
class ExpectationWatcher { | |
private val jobs = mutableMapOf<String, Job>() |
This file contains 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
inline fun InputStream.readChunk(data: ByteArray, block: (ByteArray, Int) -> Unit) { | |
var index = 0 | |
do { | |
read().takeIf { it != -1 }?.let { data[index++] = it.toByte() } ?: break | |
} while (index < data.size) | |
block(data, index) | |
} |
OlderNewer