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
kotlin { | |
android() | |
ios { | |
binaries.all { | |
freeCompilerArgs += "-Xobjc-generics" | |
} | |
} | |
tvos { |
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
actual suspend fun customDelay(timeMillis: Long) { | |
suspendCancellableCoroutine<Unit> { cont -> | |
val ntime = dispatch_time(DISPATCH_TIME_NOW, timeMillis * NSEC_PER_MSEC.toLong()) | |
dispatch_after(ntime, dispatch_get_main_queue()) { | |
cont.resume(Unit) | |
} | |
} | |
} |
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
class InternetChecker @Inject constructor() { | |
fun hasInternet(): Single<Boolean> { | |
return Single.fromCallable { | |
try { | |
// Connect to Google DNS to check for connection | |
val timeoutMs = 1500 | |
val socket = Socket() | |
val socketAddress = InetSocketAddress("8.8.8.8", 53) | |
socket.connect(socketAddress, timeoutMs) |
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 android.content.Context | |
import android.graphics.Bitmap | |
import android.graphics.ImageFormat | |
import android.graphics.Matrix | |
import android.media.Image | |
import android.renderscript.* | |
class ImageConverter(private val context: Context) { | |
class ImageConvertFailed : Exception("Image converting failed") |
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 android.Manifest | |
import android.content.Context | |
import android.content.pm.PackageManager | |
import android.content.res.Configuration | |
import android.graphics.* | |
import android.hardware.camera2.* | |
import android.media.ImageReader | |
import android.os.Bundle | |
import android.os.Handler |