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 androidx.annotation.WorkerThread | |
import kotlinx.coroutines.runBlocking | |
import okhttp3.Interceptor | |
import okhttp3.Request | |
import okhttp3.Response | |
import timber.log.Timber | |
object Retried | |
/** |
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 React from "react"; | |
import { makeStyles } from "@material-ui/core/styles"; | |
const hexagonColor = (_theme) => "#000"; | |
const strokeColor = (theme) => theme.palette.background.default; | |
const useStyles = makeStyles((theme) => ({ | |
root: { | |
"& svg": { | |
background: hexagonColor(theme), |
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 newMockHttpException( | |
statusCode: Int = 400, | |
message: String = "Default mock error", | |
response: Response<Any>? = mockk<Response<Any>>(relaxed = true) | |
.applyMockDefaults<Any, Any>(statusCode = statusCode) | |
) = mockk<HttpException>().applyMockDefaults(statusCode, message, response) | |
fun HttpException.applyMockDefaults( | |
statusCode: Int = 400, | |
message: String = "Default mock error", |
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
const val CONNECT_TIMEOUT_MS = "CONNECT_TIMEOUT_MS" | |
const val READ_TIMEOUT_MS = "READ_TIMEOUT_MS" | |
const val WRITE_TIMEOUT_MS = "WRITE_TIMEOUT_MS" | |
/** | |
* Allows dynamic setting of timeout headers. | |
* | |
* Usage: | |
* ``` | |
* @Headers("$CONNECT_TIMEOUT:10000", "$READ_TIMEOUT:10000", "$WRITE_TIMEOUT:10000") |
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
data class SemanticVersion(val major: Int, val minor: Int, val patch: Int) { | |
companion object { | |
fun fromString(version: String?): SemanticVersion? = version | |
?.takeIf { it.isNotBlank() } | |
?.split(".") | |
?.let { split -> | |
return SemanticVersion( | |
major = split.getOrNull(0)?.toIntOrNull() ?: 0, | |
minor = split.getOrNull(1)?.toIntOrNull() ?: 0, | |
patch = split.getOrNull(2)?.toIntOrNull() ?: 0 |
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 { useState, useMemo, useCallback, useEffect } from 'react'; | |
const initialState = { | |
isLoading: false, | |
result: null, | |
error: null | |
}; | |
/** | |
* This could probably be done in a much better way. Seems really messy |
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 { useMemo, useEffect, useState } from 'react'; | |
import { useDebounce } from 'use-debounce'; | |
export default function(debounceWaitMs = 500) { | |
const [curWindowHeightPx, setWindowHeight] = useState(window.innerHeight); | |
const [windowHeightPx] = useDebounce(curWindowHeightPx, debounceWaitMs, { | |
leading: true | |
}); | |
useEffect(() => { |
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
sealed class Resource<T> { | |
object Loading: Resource<Nothing>() | |
data class Success<T>(val data: T): Resource<T>() | |
data class Error(val error: AppError): Resource<Nothing>() | |
} |
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.content.Context | |
import android.graphics.* | |
import android.util.AttributeSet | |
import android.view.View | |
import kotlin.math.max | |
import kotlin.math.min | |
class SquareCutoutOverlay( | |
context: Context, |
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
abstract class UiComponent(@LayoutRes val layoutId: Int, | |
val root: ViewGroup, | |
val activity: FragmentActivity) | |
{ | |
val mainView: View = View.inflate(activity, layoutId, root) | |
lateinit protected var unbinder: Unbinder | |
open fun unbind() { |