Skip to content

Instantly share code, notes, and snippets.

Avatar

Tim Rijckaert timrijckaert

View GitHub Profile
@Aidanvii7
Aidanvii7 / NavGraph.kt
Last active Oct 17, 2021
Navigate with Parcelable arguments in Jetpack Compose
View NavGraph.kt
composable(route = "screen_1") {
Button(
onClick = {
navController.navigate(
route = "screen_2",
args = parcelableArgs {
arg { MyParcelableArgument() }
arg("named") { MyParcelableArgument() }
},
)
@nomisRev
nomisRev / Example.kt
Last active Sep 13, 2021
Kotlin DI with receivers & interface delegation
View Example.kt
import arrow.core.*
import memeid.UUID
data class User(val email: String, val name: String) {
companion object
}
data class ProcessedUser(val id: UUID, val email: String, val name: String) {
companion object
}
@raulraja
raulraja / di.kt
Last active Mar 21, 2021
Simple Kotlin DI
View di.kt
package com.fortyseven.fptraining
import arrow.core.Either
import arrow.core.right
import arrow.effects.IO
import arrow.effects.extensions.io.fx.fx
data class Account(val balance: Int)
data class AccountEntity(val balance: Int)
@gildor
gildor / OkHttpDownloader.kt
Last active Jun 19, 2021
Simple non-blocking extension function for OkHttp Call that wraps request to Kotlin Coroutine and saves response to File
View OkHttpDownloader.kt
import kotlinx.coroutines.experimental.*
import okhttp3.*
import okio.Buffer
import okio.Okio
import java.io.File
import java.io.IOException
/**
* Custom coroutine dispatcher for blocking calls
*/
@LouisCAD
LouisCAD / LifecycleCoroutines.kt
Last active May 9, 2021
CoroutineScope and Job integration with Lifecycle for Android. Meant to be used for your coroutines in lifecycle aware components. OUTDATED. See up to date implementation here: https://github.com/LouisCAD/Splitties/tree/master/modules/lifecycle-coroutines
View LifecycleCoroutines.kt
import android.arch.lifecycle.GenericLifecycleObserver
import android.arch.lifecycle.Lifecycle
import android.arch.lifecycle.Lifecycle.Event.ON_DESTROY
import android.arch.lifecycle.LifecycleOwner
import kotlinx.coroutines.experimental.CoroutineScope
import kotlinx.coroutines.experimental.Dispatchers
import kotlinx.coroutines.experimental.Job
import kotlinx.coroutines.experimental.android.Main
fun Lifecycle.createJob(cancelEvent: Lifecycle.Event = ON_DESTROY): Job {
View home_page.dart
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'dart:convert';
import 'package:url_launcher/url_launcher.dart';
import 'package:intl/intl.dart';
import 'dart:async';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:share/share.dart' as sharing;
import 'package:transparent_image/transparent_image.dart';
@yanngx
yanngx / FragmentArgumentDelegate.kt
Last active Sep 26, 2021
Fragment arguments without hassle !
View FragmentArgumentDelegate.kt
package be.brol
import android.os.Binder
import android.os.Bundle
import android.support.v4.app.BundleCompat
import android.support.v4.app.Fragment
/**
* Eases the Fragment.newInstance ceremony by marking the fragment's args with this delegate
* Just write the property in newInstance and read it like any other property after the fragment has been created
View 0-bridging-react-native-cheatsheet.md
@EarlOfEgo
EarlOfEgo / Rx2SchedulersOverrideRule.kt
Created Jan 31, 2017
A test rule for unit test to override all schedulers with trampoline
View Rx2SchedulersOverrideRule.kt
import io.reactivex.android.plugins.RxAndroidPlugins
import io.reactivex.plugins.RxJavaPlugins
import io.reactivex.schedulers.Schedulers
import org.junit.rules.TestRule
import org.junit.runner.Description
import org.junit.runners.model.Statement
/**
* Test rule that overrides all schedulers with the trampoline scheduler.
* This means everything runs on the same thread, when using this rule
@jaredsburrows
jaredsburrows / Rx1TestBase.java
Last active Jul 28, 2019
RxAndroid overriding schedulers
View Rx1TestBase.java
import org.junit.After;
import org.junit.Before;
import rx.Scheduler;
import rx.android.plugins.RxAndroidPlugins;
import rx.android.plugins.RxAndroidSchedulersHook;
import rx.schedulers.Schedulers;
/**
* JUnit Tests.
*