Skip to content

Instantly share code, notes, and snippets.

View mayojava's full-sized avatar

Mayowa Adegeye mayojava

View GitHub Profile
package com.example.kormics
import androidx.compose.animation.core.LinearEasing
import androidx.compose.animation.core.LinearOutSlowInEasing
import androidx.compose.animation.core.animateDpAsState
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.animation.core.tween
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
@mayojava
mayojava / CardSlideAnimation.kt
Created May 18, 2024 19:20 — forked from vishal2376/CardSlideAnimation.kt
Beautiful Card Sliding Animation
package com.vishal2376.animations
import androidx.compose.animation.Crossfade
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.animation.core.tween
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
package dev.efemoney.orchestra.ui
import androidx.compose.animation.asDisposableClock
import androidx.compose.animation.core.AnimationClockObservable
import androidx.compose.animation.core.TargetAnimation
import androidx.compose.animation.core.tween
import androidx.compose.foundation.animation.AndroidFlingDecaySpec
import androidx.compose.foundation.animation.FlingConfig
import androidx.compose.foundation.gestures.ScrollableController
import androidx.compose.foundation.gestures.scrollable
@mayojava
mayojava / flow_merge.kt
Created April 12, 2019 15:05
What a mergeWith Flow operator might look like
@FlowPreview
fun <T> Flow<T>.mergeWith(other: Flow<T>): Flow<T> = flow {
coroutineScope {
launch {
other.collect {
emit(it)
}
}
launch {
@mayojava
mayojava / competitions.xml
Last active December 4, 2018 07:17
home_fragment
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="320dp"
xmlns:app="http://schemas.android.com/apk/res-auto">
<androidx.constraintlayout.widget.Guideline android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="@+id/left_guide"
@mayojava
mayojava / sample_presenter_fetch.kt
Created November 17, 2018 14:33
coroutine demonstration
class CoroutinesPresenter(private val dispatcherProvider: DispatchersProvider,
private val repository: Reviewsrepository) {
private val job = Job()
private val uiScope = CoroutineContext(dispatcherProvider.main + job) //runs on main thread
fun fetchData(count: Int, page: Int) {
try {
uiScope.launch {
arbitraryView.setLoading(true)
@mayojava
mayojava / actor.kt
Created November 7, 2018 18:57
actor coroutine builder
public fun <E> CoroutineScope.actor(
context: CoroutineContext = EmptyCoroutineContext,
capacity: Int = 0,
start: CoroutineStart = CoroutineStart.DEFAULT,
onCompletion: CompletionHandler? = null,
block: suspend ActorScope<E>.() -> Unit
): SendChannel<E>
@mayojava
mayojava / produce_sample.kt
Last active November 7, 2018 18:56
Produce builder sample
fun main() = runBlocking {
val multiplesOfThree = produce {
(1..10).filter {
it % 3 == 0
}.forEach {
send(it) //send can only be called inside the ProducerScope
}
}
@mayojava
mayojava / produce.kt
Created November 7, 2018 18:54
Produce Coroutine Builder
public fun <E> CoroutineScope.produce(
context: CoroutineContext = EmptyCoroutineContext,
capacity: Int = 0,
block: suspend ProducerScope<E>.() -> Unit
): ReceiveChannel<E>
@mayojava
mayojava / broadcastChannel.kt
Created November 7, 2018 18:54
BroadcastChannel does not suspend
fun main() = runBlocking {
val channel = BroadcastChannel<Int>(1)
repeat(10) {
channel.send(it)
}
}