Skip to content

Instantly share code, notes, and snippets.

View belinwu's full-sized avatar

吴上阿吉 belinwu

View GitHub Profile
@belinwu
belinwu / JsonRpc.kt
Created April 16, 2025 08:07 — forked from ntoskrnl/JsonRpc.kt
Retrofit-style JSON-RPC client in Kotlin (with gson serialization/deserialization)
fun <T, B> createJsonRpcService(service: Class<T>,
client: JsonRpcClient<B>,
resultDeserializer: Deserializer<B>,
logger: (String) -> Unit = {}): T {
val classLoader = service.classLoader
val interfaces = arrayOf<Class<*>>(service)
val invocationHandler = createInvocationHandler(service, client, resultDeserializer, logger)
@Suppress("UNCHECKED_CAST")
@belinwu
belinwu / README.md
Created December 31, 2024 04:32 — forked from DewaldDeJager/README.md
Easy GitHub workflow for keeping a fork in sync with upstream

Sync Fork

This workflow uses the GitHub CLI to keep a forked repo in sync with the upstream repo. Add it to your repo as .github/workflows/sync-fork.yaml.

It runs daily to sync the default branch and can be triggered manually for any branch.

@belinwu
belinwu / KeyframesWithSpline.kt
Created December 18, 2024 04:27 — forked from riggaroo/KeyframesWithSpline.kt
KeyframesWithSpline Example
import androidx.compose.animation.core.RepeatMode
import androidx.compose.animation.core.VectorConverter
import androidx.compose.animation.core.animateValue
import androidx.compose.animation.core.infiniteRepeatable
import androidx.compose.animation.core.keyframesWithSpline
import androidx.compose.animation.core.rememberInfiniteTransition
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.BoxWithConstraints
@belinwu
belinwu / App.kt
Last active October 11, 2024 04:39 — forked from sergejsha/App.kt
Pure-Compose ViewModel (like Molecule, but without Molecule)
package de.halfbit.seventysix
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.material.Button
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
@belinwu
belinwu / RememberViewModelStoreOwner.kt
Created September 27, 2024 08:07 — forked from joost-klitsie/RememberViewModelStoreOwner.kt
rememberViewModelStoreOwner example implementation
import androidx.compose.runtime.*
import androidx.compose.ui.platform.LocalLifecycleOwner
import androidx.lifecycle.*
import androidx.lifecycle.viewmodel.compose.LocalViewModelStoreOwner
import androidx.lifecycle.viewmodel.compose.viewModel
import kotlinx.coroutines.*
import kotlinx.coroutines.flow.*
@Composable
fun rememberViewModelStoreOwner(
import android.os.Bundle
import androidx.compose.runtime.Composable
import androidx.compose.runtime.RememberObserver
import androidx.compose.runtime.remember
import androidx.lifecycle.*
import androidx.lifecycle.viewmodel.CreationExtras
import androidx.lifecycle.viewmodel.MutableCreationExtras
import androidx.lifecycle.viewmodel.compose.LocalViewModelStoreOwner
import androidx.lifecycle.viewmodel.compose.viewModel
@belinwu
belinwu / LazyListAnimation.kt
Created August 15, 2024 04:31 — forked from darvld/LazyListAnimation.kt
This gist contains a simple implementation of animated item transitions for use with `LazyListScope` (`LazyColumn`/`LazyRow`).
package io.github.darvld.utils
import androidx.compose.animation.*
import androidx.compose.animation.core.ExperimentalTransitionApi
import androidx.compose.animation.core.MutableTransitionState
import androidx.compose.foundation.lazy.LazyListScope
import androidx.compose.foundation.lazy.items
import androidx.compose.runtime.*
import androidx.recyclerview.widget.AsyncListDiffer
import androidx.recyclerview.widget.DiffUtil
@belinwu
belinwu / SweepGradientImage.kt
Created May 27, 2024 09:37 — forked from vishal2376/SweepGradientImage.kt
Sweep Line effect with some rotation and scale animation
@Composable
fun SweepGradientImage(
imgResId: Int,
maxImgSize: Dp = 250.dp,
maxImgRotation: Float = -10f
) {
var animationPlayed by remember { mutableStateOf(false) }
val lineOffset by animateFloatAsState(
@belinwu
belinwu / Place.kt
Created May 20, 2024 04:14 — forked from vishal2376/Place.kt
Image Reflection with cool animation using Jetpack Compose
data class Place(
val name: String,
val resId: Int
)
@belinwu
belinwu / CardSlideAnimation.kt
Created May 15, 2024 13:46 — 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