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 AndroidNetworkModule( | |
private val context: Context, | |
private val dispatchers: CoroutineDispatchers, | |
) : NetworkModule { | |
private val connectivityManager: ConnectivityManager | |
get() = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager | |
override fun stream(): Flow<NetworkState> { | |
return callbackFlow { | |
val callback = object : ConnectivityManager.NetworkCallback() { |
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.graphics.Canvas | |
import android.widget.EdgeEffect | |
import androidx.dynamicanimation.animation.SpringAnimation | |
import androidx.dynamicanimation.animation.SpringForce | |
import androidx.recyclerview.widget.RecyclerView | |
/** The magnitude of translation distance while the list is over-scrolled. */ | |
private const val OVERSCROLL_TRANSLATION_MAGNITUDE = 0.5f | |
/** The magnitude of translation distance when the list reaches the edge on fling. */ |
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
<?xml version="1.0" encoding="utf-8"?> | |
<resources> | |
<color name="geist_light_background_color_1">#FFFFFF</color> | |
<color name="geist_light_background_color_2">#FAFAFA</color> | |
<color name="geist_light_gray_100">#F2F2F2</color> | |
<color name="geist_light_gray_200">#EBEBEB</color> | |
<color name="geist_light_gray_300">#E5E5E5</color> | |
<color name="geist_light_gray_400">#EBEBEB</color> | |
<color name="geist_light_gray_500">#C9C9C9</color> | |
<color name="geist_light_gray_600">#A8A8A8</color> |
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
<?xml version="1.0" encoding="utf-8"?> | |
<resources> | |
<color name="white">#ffffff</color> | |
<color name="dark_background_1">#0A0A0A</color> | |
<color name="dark_background_2">#000000</color> | |
<color name="dark_gray_100">#1A1A1A</color> | |
<color name="dark_gray_200">#1F1F1F</color> | |
<color name="dark_gray_300">#292929</color> | |
<color name="dark_gray_400">#2E2E2E</color> |
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 GoogleSignInHandler(fragment: Fragment) { | |
private val oneTapClient = Identity.getSignInClient(fragment.requireContext()) | |
private var callback: ActivityResultCallback<ActivityResult> = ActivityResultCallback { | |
fragment.toast("Hello!") | |
} | |
private val launcher: ActivityResultLauncher<IntentSenderRequest> = | |
fragment.registerForActivityResult( | |
ActivityResultContracts.StartIntentSenderForResult(), | |
callback |
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
sealed class Result<out R> { | |
data class Success<out T>(val data: T) : Result<T>() | |
data class Error(val message: String, val errorCode: ErrorCode = ErrorCode.UNKNOWN) : | |
Result<Nothing>() { | |
companion object { | |
private const val DEFAULT_ERROR_MESSAGE = "An unknown error has occurred" | |
fun fromException(exception: Exception): Error { | |
return Error(exception.message ?: DEFAULT_ERROR_MESSAGE, ErrorCode.UNKNOWN) |
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
sealed interface Option<out A> { | |
data class Some<out B>(val value: B) : Option<B> | |
object None : Option<Nothing> | |
} | |
fun <A> some(value: A): Option<A> { | |
return Option.Some(value) | |
} |
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
typealias QueryPredicate<T> = (String, T) -> Boolean | |
data class QueryableState<T>( | |
private val filteredState: StateFlow<List<T>>, | |
val setQuery: (String) -> Unit | |
) { | |
fun state() = filteredState | |
} | |
fun <T> ViewModel.createQueryableState( |
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
window: | |
dimensions: | |
columns: 100 | |
lines: 30 | |
color: | |
import: | |
- ~/.alacritty-colorscheme/themes/atom_one_light.yaml | |
font: | |
normal: | |
family: Cascadia Code |
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
fun createDialog(context: Context, contentView: View): Dialog { | |
return Dialog(context, R.style.App.Theme.Dialog).apply { | |
requestWindowFeature(Window.FEATURE_NO_TITLE) | |
setContentView(contentView) | |
val layoutParams = WindowManager.LayoutParams() | |
layoutParams.copyFrom(window?.attributes) | |
layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT | |
layoutParams.height = WindowManager.LayoutParams.WRAP_CONTENT |
NewerOlder