Skip to content

Instantly share code, notes, and snippets.

View ychescale9's full-sized avatar
🏠
Working from home

Yang ychescale9

🏠
Working from home
View GitHub Profile
@staltz
staltz / introrx.md
Last active June 3, 2024 11:21
The introduction to Reactive Programming you've been missing
@kaushikgopal
kaushikgopal / android_lifecycle_recommendations.md
Last active February 2, 2022 07:28
Notes on opportune moments to do "stuff" in the Android Lifecycle
  • In general you want to try and put things in onStart and onStop for logical start and stops.

Activity

onCreate

  • Dagger inject self into graph
  • setContentView(R.layout.xxx)
  • Butterknife.bind(this)
  • RxJava CompositeSubscription.add (if NON UI related work being done)
  • realm = Realm.getDefaultInstance();
@Sorix
Sorix / Package.swift
Last active December 23, 2023 14:26
Example of Package.swift with environment variables support
// swift-tools-version:4.0
import PackageDescription
#if os(Linux)
import Glibc
#else
import Darwin.C
#endif
enum Enviroment: String {
@objcode
objcode / Permissions.kt
Last active February 21, 2023 23:01
Quick demo of compose permissions using activity result API. Uses Flow instead of State to make it reusable outside of Compose.
/*
* Copyright 2020 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
@JorgeCastilloPrz
JorgeCastilloPrz / RatingStars.kt
Last active August 29, 2021 23:43
Composable to show rating stars. Noninteractive.
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.preferredSize
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.ColorFilter
@zach-klippenstein
zach-klippenstein / SegmentedControl.kt
Last active May 28, 2024 09:26
iOS-style segmented control in Compose
import android.annotation.SuppressLint
import androidx.compose.animation.core.animateDpAsState
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.background
import androidx.compose.foundation.gestures.awaitFirstDown
import androidx.compose.foundation.gestures.forEachGesture
import androidx.compose.foundation.gestures.horizontalDrag
import androidx.compose.foundation.layout.Arrangement.spacedBy
import androidx.compose.foundation.layout.Box
@JUSTINMKAUFMAN
JUSTINMKAUFMAN / XCFramework.kts
Created November 3, 2021 18:53
Kotlin Multiplatform Build Gradle Task for iOS/macOS Universal Framework
/**
* Kotlin Multiplatform Universal XCFramework Task
*
* Description:
* If your project needs to target *all* possible
* iOS and macOS variants (including Apple Silicon
* hardware, ARM64 iPhone simulators, and so on),
* this task will build the frameworks, lipo those
* that can be combined into a single binary, and
* place them where Xcode expects to find them in
@AfzalivE
AfzalivE / ComposeLayoutPreviewHelper.kt
Last active February 9, 2023 14:37
AbstractComposeView layout preview helper
package com.yourpackage
import android.os.Bundle
import android.view.View
import androidx.compose.runtime.MonotonicFrameClock
import androidx.compose.runtime.PausableMonotonicFrameClock
import androidx.compose.runtime.Recomposer
import androidx.compose.ui.InternalComposeUiApi
import androidx.compose.ui.platform.AbstractComposeView
import androidx.compose.ui.platform.AndroidUiDispatcher
@c5inco
c5inco / SwipeableCards.kt
Last active April 21, 2024 13:06
Jetpack Compose implementation of inspiration: https://twitter.com/philipcdavis/status/1534192823792128000
package des.c5inco.cardswipecompose
import androidx.compose.animation.core.Animatable
import androidx.compose.animation.core.CubicBezierEasing
import androidx.compose.animation.core.LinearOutSlowInEasing
import androidx.compose.animation.core.animateDpAsState
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.animation.core.calculateTargetValue
import androidx.compose.animation.core.keyframes
import androidx.compose.animation.splineBasedDecay
@AfzalivE
AfzalivE / CustomTestRunner.kt
Last active August 3, 2022 22:30
Disable soft-keyboards for tests
import androidx.test.runner.AndroidJUnitRunner
class CustomJunitRunner : AndroidJUnitRunner() {
private var enabledImes = emptyList<String>()
override fun callApplicationOnCreate(app: Application?) {
super.callApplicationOnCreate(app)
enabledImes = getEnabledImes()
disableSoftKeyboards(enabledImes)