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 sayaaa.rpscience.com.sayaaaa; | |
import android.graphics.Color; | |
import android.hardware.Camera; | |
import java.util.concurrent.atomic.AtomicBoolean; | |
public class ImageProcessing { | |
private int averageIndex = 0; | |
private final int averageArraySize = 4; |
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.Application | |
import android.arch.lifecycle.AndroidViewModel | |
import android.arch.lifecycle.MutableLiveData | |
import kotlinx.coroutines.experimental.* | |
import kotlinx.coroutines.experimental.android.Main | |
import kotlin.coroutines.experimental.CoroutineContext | |
abstract class BaseFragmentViewModel(application: Application) : AndroidViewModel(application), CoroutineScope { | |
private val job = 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
package com.earlysense.sdk.rs232 | |
class SignalDataCollector() { | |
private var index = 0 | |
private var signalData = ByteArray(DATA_VAL_MAX_PACKET_SIZE) | |
var callback: ((signalData: ByteArray) -> Unit)? = null | |
/** | |
* Building chunks from the buffer, every chunk must be [DATA_VAL_MAX_PACKET_SIZE] | |
* @param buffer the buffer into which the data was read |
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) | |
} |
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
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
<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 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
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: |
NewerOlder