Skip to content

Instantly share code, notes, and snippets.

@halilozercan
halilozercan / TypingAnimation.kt
Last active November 13, 2024 12:04
TextField Typing Animation
package com.example.textfieldtypinganimation
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.animation.core.Animatable
import androidx.compose.animation.core.AnimationVector1D
import androidx.compose.animation.core.Spring
import androidx.compose.animation.core.spring
@OptIn(ExperimentalLayoutApi::class)
@Composable
fun AnimateCharTextField(
value: String,
onValueChange: (String) -> Unit,
modifier: Modifier = Modifier,
textStyle: TextStyle = TextStyle(fontSize = 50.sp)
) {
val scope = rememberCoroutineScope()
val animatables = remember { mutableStateMapOf<Int, Animatable<Float, AnimationVector1D>>() }
@Andrew0000
Andrew0000 / ComposeShadow.kt
Last active November 16, 2024 23:22
Jetpack Compose custom shadow with dx, dy and radius
import android.graphics.BlurMaskFilter
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.requiredSize
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.composed
@tfcporciuncula
tfcporciuncula / PdfAdapter.kt
Last active March 19, 2024 11:50
PDF rendering the easy way
class PdfAdapter(
// this would come from the ViewModel so we don't need to recreate it on config change
// and the VM can close it within onCleared()
private val renderer: PdfRenderer,
// this would come from the Activity/Fragment based on the display metrics
private val pageWidth: Int
) : RecyclerView.Adapter<PdfAdapter.ViewHolder>() {
class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
@manuelvicnt
manuelvicnt / AnAndroidApp.kt
Last active January 1, 2023 17:05
Hilt and AssistedInject working together in Hilt v2.28-alpha times - ViewModel version
// IMPORTANT! READ THIS FIRST
// Assisted Injection doesn't work with @HiltViewModel or @ViewModelInject
// Read more about the issue here: https://github.com/google/dagger/issues/2287
//
//
// AssistedInject and Hilt working together in v2.28-alpha times
// Example of a ViewModel using AssistedInject injected in a Fragment by Hilt
// As AssistedInject isn't part of Dagger yet, we cannot use in
// conjuction with @ViewModelInject
@filipkowicz
filipkowicz / HeaderItemDecoration.kt
Last active February 26, 2025 18:20
Item Decorator for sticky headers in Kotlin
package com.filipkowicz.headeritemdecorator
/*
solution based on - based on Sevastyan answer on StackOverflow
changes:
- take to account views offsets
- transformed to Kotlin
- now works on viewHolders
@parthdave93
parthdave93 / BindingAdapter.java
Created May 11, 2017 04:59
Date Picker Using Databinding
@BindingAdapter(value = {"bind:datePick", "bind:maxDate", "bind:minDate"}, requireAll = false)
public static void bindTextViewDateClicks(final TextView textView, final ObservableField<Date> date, final ObservableField<Date> maxDate, final ObservableField<Date> minDate) {
textView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
selectDate(textView.getContext(), date, maxDate, minDate);
}
});
}