Skip to content

Instantly share code, notes, and snippets.

@awxkee
awxkee / Gauss.kt
Last active June 10, 2025 02:46
OpenGLES 2/3 Gaussian Blur
package com.example.simpleegl
import android.app.ActivityManager
import android.content.Context
import android.graphics.Bitmap
import android.opengl.EGL14
import android.opengl.EGL15
import android.opengl.EGLConfig
import android.opengl.EGLContext
import android.opengl.EGLDisplay
@hoangchungk53qx1
hoangchungk53qx1 / TestCropImageCompose
Last active February 4, 2025 14:47
TestCropImageCompose
@OptIn(ExperimentalMaterial3Api::class, ExperimentalLayoutApi::class)
@Composable
fun TestCropImage() {
val context = LocalContext.current
val cropView = remember {
CropImageView(context).apply {
isAutoZoomEnabled = false
cropShape = CropImageView.CropShape.RECTANGLE
@stevdza-san
stevdza-san / AnimatedBorderCard.kt
Last active May 18, 2025 20:05
Card with Animated Border built with Jetpack Compose.
@Composable
fun AnimatedBorderCard(
modifier: Modifier = Modifier,
shape: Shape = RoundedCornerShape(size = 0.dp),
borderWidth: Dp = 2.dp,
gradient: Brush = Brush.sweepGradient(listOf(Color.Gray, Color.White)),
animationDuration: Int = 10000,
onCardClick: () -> Unit = {},
content: @Composable () -> Unit
) {
@f2janyway
f2janyway / ScrollBar.kt
Last active June 3, 2025 13:01
ScrollBar for LazyColumn; if there is wrapper to LazyColumn(ex;Column), just use with Box() as direct above wrapper with ScrollBar and LazyColumn
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.lazy.LazyListState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
@nhcodes
nhcodes / Picker.kt
Created May 17, 2023 11:19
Android NumberPicker for Jetpack Compose
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.gestures.snapping.rememberSnapFlingBehavior
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.material3.Divider
import androidx.compose.material3.LocalContentColor
package com.example.myapp.animation
import androidx.compose.animation.core.*
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.size
@electricbolt
electricbolt / FirebaseResourcesWrapper.java
Last active February 5, 2023 01:45
Subclass of android.content.res.Resources that is used to capture Firebase Analytics initialization process to return the "google_app_id" string that we require, programmatically, rather than it being embedded into strings.xml. See https://github.com/firebase/firebase-android-sdk/issues/66
package nz.co.electricbolt.firebase;
import android.content.res.AssetFileDescriptor;
import android.content.res.ColorStateList;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.content.res.XmlResourceParser;
import android.graphics.Movie;
import android.graphics.Typeface;
1. hiltvm (applicable in top-level)
@dagger.hilt.android.lifecycle.HiltViewModel
class $NAME$ @javax.inject.Inject constructor(
$PARAM$
) : androidx.lifecycle.ViewModel() {
$END$
}
2. vmstatefunc (applicable in class)
private val _$NAME$ = androidx.compose.runtime.mutableStateOf<$TYPE$>($INITIAL_VALUE$)
@vganin
vganin / FlexRow.kt
Last active June 30, 2025 05:06
[DEPRECATED, use official FlowRow instead] Jetpack Compose simple flex-wrap container
@Composable
fun FlowRow(
horizontalGap: Dp = 0.dp,
verticalGap: Dp = 0.dp,
alignment: Alignment.Horizontal = Alignment.Start,
content: @Composable () -> Unit,
) = Layout(content = content) { measurables, constraints ->
val horizontalGapPx = horizontalGap.toPx().roundToInt()
val verticalGapPx = verticalGap.toPx().roundToInt()
@fergusonm
fergusonm / gist:88a728eb543c7f6727a7cc473671befc
Last active October 28, 2023 20:01
launchWhenX dropping events
class MainFragment : Fragment(R.layout.main_fragment) {
companion object {
fun newInstance() = MainFragment()
}
private lateinit var viewModel: MainViewModel
override fun onCreate(savedInstanceState: Bundle?) {