Skip to content

Instantly share code, notes, and snippets.

View juancoob's full-sized avatar
😄
Learning

Juan Antonio Cobos Obrero juancoob

😄
Learning
View GitHub Profile
@SylpheM
SylpheM / TooltipShape.kt
Last active August 27, 2024 20:08
A tooltip shape (a rounded rectangle with an arrow or a tick), that can be used with a shadow. Preview included
enum class TickOrientation {
TOP, START, END, BOTTOM
}
class TooltipShape(
private val cornerRadiusDp: Dp,
private val tickHeight: Dp,
private val tickOrientation: TickOrientation
) : Shape {
private const val SCROLL_DX = 24f
private const val REQUIRED_CARD_COUNT = 8
private class AutoScrollItem<T>(
val id: String = UUID.randomUUID().toString(),
val data: T
)
@Composable
fun <T : Any> AutoScrollingLazyRow(
@leonardoaramaki
leonardoaramaki / Debouncer.kt
Created November 16, 2021 16:59
Add click debouncing logic to Jetpack Compose
/**
* Wraps an [onClick] lambda with another one that supports debouncing. The default deboucing time
* is 1000ms.
*
* @return debounced onClick
*/
@Composable
inline fun debounced(crossinline onClick: () -> Unit, debounceTime: Long = 1000L): () -> Unit {
var lastTimeClicked by remember { mutableStateOf(0L) }
val onClickLambda: () -> Unit = {
@Oleur
Oleur / ComposeCanvasText.kt
Last active May 13, 2024 17:27
Draw text on Jetpack Compose Canvas
val textPaint = Paint().asFrameworkPaint().apply {
isAntiAlias = true
textSize = 24.sp.toPx()
color = android.graphics.Color.BLUE
typeface = Typeface.create(Typeface.MONOSPACE, Typeface.BOLD)
}
Canvas(
modifier = modifier.fillMaxSize(),
onDraw = {
drawIntoCanvas {
@nanusdad
nanusdad / git_new_local_branch.md
Last active June 16, 2024 06:56
Git - create new local branch push to GitHub
@staltz
staltz / introrx.md
Last active July 18, 2026 04:20
The introduction to Reactive Programming you've been missing
@dominicthomas
dominicthomas / Android - Launch another app
Created November 28, 2013 16:16
Launch another app using an intent with package name if app has a launcher activity or using package name and class name of main activity.
// only works if app has a launcher activity
Intent launchIntent = getPackageManager().getLaunchIntentForPackage("com.example.yourapp");
startActivity(launchIntent);
// works if we know the name of the main activity, even if not a launcher
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setClassName("com.example.yourapp", "com.example.yourapp.MainActivity");
startActivity(intent);