Skip to content

Instantly share code, notes, and snippets.

View Rolf-Smit's full-sized avatar
🐉
Hic sunt dracones

Rolf Smit Rolf-Smit

🐉
Hic sunt dracones
View GitHub Profile
/*
* @author Rolf Smit
* Copyright: © Rolf Smit / NeoTech Software
*/
package org.neotech.library.utilities;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
@Rolf-Smit
Rolf-Smit / WithLockedThreadCoroutineExtension.kt
Last active March 5, 2021 16:25
Modified version of the withTransaction method from https://medium.com/androiddevelopers/threading-models-in-coroutines-and-android-sqlite-api-6cab11f7eb90 that is more generally usable (claiming a thread from the current dispatcher for your own until work is done, suspending on the same thread if needed)
/*
* @author Rolf Smit
* Copyright: © Rolf Smit / NeoTech Software
*/
package org.neotech
import kotlinx.coroutines.ExecutorCoroutineDispatcher
import kotlinx.coroutines.Job
import kotlinx.coroutines.asContextElement
package nl.ah.appie.util
import android.app.Activity
import android.app.Application
import android.os.Bundle
import androidx.annotation.MainThread
import nl.ah.appie.util.ApplicationLifecycle.Listener
import java.util.concurrent.CopyOnWriteArraySet
import java.util.concurrent.atomic.AtomicBoolean
@Rolf-Smit
Rolf-Smit / AllowCrossDomainCookieInterceptor.kt
Created November 7, 2018 14:16
This Interceptor is capable of rewriting cookie domains, basically preventing the RFC 6265 section 4.1.2.3 domain checks, which are implemented in OkHttp's Cookie.parse() method which cannot be configured to be disabled.
package com.knab.android.security;
import com.knab.android.BuildConfig
import okhttp3.Interceptor
import okhttp3.Request
import okhttp3.Response
import java.net.HttpCookie
/**
* This Interceptor is capable of rewriting cookie domains, basically preventing the RFC 6265
package org.neotech.jdeferred;
import org.jdeferred.AlwaysCallback;
import org.jdeferred.DoneCallback;
import org.jdeferred.FailCallback;
import org.jdeferred.ProgressCallback;
import org.jdeferred.impl.DeferredObject;
/**
* DeferredObject swallows exceptions, this version prevents this so that exceptions
@Rolf-Smit
Rolf-Smit / GenericFilter.java
Created May 4, 2017 08:03
A generic version of Androids android.widget.Filter and android.widget.Filter.FilterResults
package org.neotech.snippet.genericfilter;
import android.widget.Filter;
/**
* An implementation of {@link Filter} and {@link android.widget.Filter.FilterResults} which
* supports a filter result as generic type.
*
* Created by Rolf Smit on 04-May-17.
*/