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
class SimpleService : Service() { | |
companion object { | |
@JvmStatic fun launchService(context: Context) { | |
context.startService(Intent(context, SimpleService::class.java)) | |
} | |
} | |
override fun onBind(intent: Intent?): IBinder { | |
return Binder() | |
} |
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
private void subscribeToData() { | |
Flowable<List<Data>> dataLists = Flowable | |
.interval(0, 3, TimeUnit.SECONDS, Schedulers.computation()) | |
.map(val -> { | |
Log.d(TAG, "Shuffling original list..."); | |
return Data.shuffle(originalList).subList(0, (int) (0.8 * originalList.size())); | |
}) | |
.share(); | |
Flowable<List<Data>> startWith = dataLists |
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 se.hellsoft.demo.codesnippetdemo; | |
import android.app.Activity; | |
import android.net.Uri; | |
import android.os.Bundle; | |
import android.os.Handler; | |
import android.os.HandlerThread; | |
import android.os.Message; | |
import android.os.SystemClock; | |
import android.view.View; |
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 se.hellsoft.handlerthreadingdemo; | |
import android.content.ComponentName; | |
import android.content.Intent; | |
import android.content.ServiceConnection; | |
import android.os.Handler; | |
import android.os.HandlerThread; | |
import android.os.IBinder; | |
import android.os.Looper; | |
import android.os.Message; |
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
// Create a path to an element of the form 2/1/1/34 (index of each child) | |
function getDomPath(el) { | |
const stack = []; | |
while (el.parentNode != null) { | |
console.log(el.nodeName); | |
let sibCount = 0; | |
let sibIndex = 0; | |
for (let i = 0; i < el.parentNode.childNodes.length; i++) { | |
const sib = el.parentNode.childNodes[i]; | |
if (sib === el) { |
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
@file:Suppress("unused") | |
package se.hellsoft.webviewserver | |
import android.content.res.AssetManager | |
import android.net.Uri | |
import android.webkit.WebResourceRequest | |
import android.webkit.WebResourceResponse | |
import java.io.ByteArrayInputStream | |
import java.io.File |
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
fun imageFormatName(format: Int): String = when (format) { | |
ImageFormat.DEPTH16 -> "DEPTH16" | |
ImageFormat.DEPTH_JPEG -> "DEPTH_JPEG" | |
ImageFormat.DEPTH_POINT_CLOUD -> "DEPTH_POINT_CLOUD" | |
ImageFormat.FLEX_RGBA_8888 -> "FLEX_RGBA_8888" | |
ImageFormat.FLEX_RGB_888 -> "FLEX_RGB_888" | |
ImageFormat.HEIC -> "HEIC" | |
ImageFormat.JPEG -> "JPEG" | |
ImageFormat.NV16 -> "NV16" | |
ImageFormat.NV21 -> "NV21" |
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 se.hellsoft.simpleservicecallbackdemo; | |
import android.app.Activity; | |
import android.content.ComponentName; | |
import android.content.Intent; | |
import android.content.ServiceConnection; | |
import android.graphics.Color; | |
import android.os.Bundle; | |
import android.os.Handler; | |
import android.os.IBinder; |
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
@file:Suppress("unused") | |
package se.hellsoft.coroutineantipatterns | |
import android.util.Log | |
internal const val TAG = "KittyLog" | |
fun logi(message: String, throwable: Throwable? = null) { | |
try { |
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
internal class CoroutineLifecycleListener(private val deferred: Deferred<*>) : LifecycleObserver { | |
@OnLifecycleEvent(Lifecycle.Event.ON_STOP) | |
fun cancelCoroutine() { | |
deferred.cancel() | |
} | |
} | |
internal var POOL = newFixedThreadPoolContext(2, "loader") | |
fun <T> LifecycleOwner.load(loader: () -> T): Deferred<T> { |