Skip to content

Instantly share code, notes, and snippets.

View cgudea's full-sized avatar
🦑
slapping keyboards

cg cgudea

🦑
slapping keyboards
View GitHub Profile
@sagar-viradiya
sagar-viradiya / ThreadLikePathAnimation.kt
Last active June 2, 2024 14:50
An attampt to implement Threads app like path animation on pull to refresh in Jetpack Compose
@OptIn(ExperimentalMaterialApi::class)
@Composable
fun PullToRefreshAnimation() {
val path = remember {
GitHubLogoPath.path.toPath()
}
val lines = remember {
path.asAndroidPath().flatten(error = 0.5f).toList()
}
@riggaroo
riggaroo / GradientAlongPathAnimation.kt
Last active May 29, 2024 19:11
Gradient along a path using path.flatten in Compose, Inspired by William Candillon https://youtu.be/7SCzL-XnfUU, this uses Jetpack Compose to draw a gradient along a path https://github.com/wcandillon/can-it-be-done-in-react-native/tree/master/bonuses/skia-examples/src/PathGradient
package androidx.compose.samples.animationfactory
import androidx.compose.animation.core.Animatable
import androidx.compose.animation.core.infiniteRepeatable
import androidx.compose.animation.core.tween
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.aspectRatio
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
@jamiesanson
jamiesanson / ViewLifecycleLazy.kt
Last active May 29, 2024 10:43
A Kotlin lazy implementation which automatically clears itself at appropriate times in the View Lifecycle, with a Fragment example
import androidx.fragment.app.Fragment
import androidx.lifecycle.DefaultLifecycleObserver
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.Observer
import kotlin.properties.ReadOnlyProperty
import kotlin.reflect.KProperty
fun <T> Fragment.viewLifecycleLazy(initialise: () -> T): ReadOnlyProperty<Fragment, T> =
object : ReadOnlyProperty<Fragment, T>, DefaultLifecycleObserver {
@psteiger
psteiger / android-kotlin-location-extensions.kt
Last active April 14, 2023 12:28
Location-related Kotlin extension functions for Android.
// Location-related Kotlin extension properties for Android.
// They must be implemented in an Activity because Geocoder needs a context.
// Or else, they must be turned from extension properties to extension functions that receive a context as parameter.
// Example of use
// Use case: show the user his locality name on a TextView
val userLocation = Location(someLatitude, someLongitude)
launch(UI) {
aTextView.text = userLocation.localityName.await()
@florina-muntenescu
florina-muntenescu / BaseDao.kt
Last active October 11, 2024 01:20
Use Dao inheritance to reduce the amount of boilerplate code - https://medium.com/google-developers/7-pro-tips-for-room-fbadea4bfbd1
/*
* Copyright (C) 2017 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
#!groovy
import groovy.json.JsonOutput
import java.util.Optional
import hudson.tasks.test.AbstractTestResultAction
import hudson.model.Actionable
import hudson.tasks.junit.CaseResult
def speedUp = '--configure-on-demand --daemon --parallel'
def nebulaReleaseScope = (env.GIT_BRANCH == 'origin/master') ? '' : "-Prelease.scope=patch"
# to run: docker-compose run
#
# Create a .evn file in the same folder as this file and change the variables.
# MOUNT_POINT=/tmp/
# VPN_PROVIDER=changeme
# VPN_CONFIG=changeme
# VPN_USERNAME=changeme
# VPN_PASSWORD=changeme
#
#
import rx.Observable;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;
/**
* Transformer for observables. You can pass it to class that uses subscriptions to have full
* control of schedulers used. Also it is preferable way to mock schedulers in tests.
*
* <p>Usage example:
* <code><pre>
@alpargabos
alpargabos / build.gradle
Created August 14, 2016 17:30
Checkstyle-gradle
apply plugin: 'checkstyle'
// Add checkstyle to the check task.
check.dependsOn 'checkstyle'
task checkstyle(type: Checkstyle) {
configFile file("../config/quality/checkstyle/checkstyle.xml")
configProperties.checkstyleSuppressionsPath = file("../config/quality/checkstyle/suppressions.xml").absolutePath
source 'src'
include '**/*.java'