Skip to content

Instantly share code, notes, and snippets.

View nexy791's full-sized avatar
๐ŸŽ“

Olexandr Yasinskyi nexy791

๐ŸŽ“
View GitHub Profile
@Zhuinden
Zhuinden / BasicTextFieldWithCursorAtEnd.kt
Last active January 5, 2026 09:28
A Compose TextField that initializes the cursor position at the end of the text, rather than the start, when focused without tapping the TextField manually.
/*
* 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
import androidx.compose.animation.core.FastOutSlowInEasing
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.animation.core.tween
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material.TextField
import androidx.compose.runtime.*
@Swisyn
Swisyn / EventsQueue.kt
Created May 13, 2020 11:45 — forked from osipxd/EventsQueue.kt
ViewModel and LiveData extensions
import androidx.annotation.MainThread
import androidx.lifecycle.MutableLiveData
import java.util.LinkedList
import java.util.Queue
/**
* ะšะปะฐัั-ะพั‡ะตั€ะตะดัŒ ะดะปั ะพะฑั€ะฐะฑะพั‚ะบะธ ะฒั€ะตะผะตะฝะฝั‹ั… ัะพะฑั‹ั‚ะธะน, ะฝะต ัะฒะปััŽั‰ะธั…ัั ั‡ะฐัั‚ัŒัŽ View
* ะะฐะฟั€ะธะผะตั€, ะฟะพะบะฐะท SnackBar ั ัะพะพะฑั‰ะตะฝะธะตะผ ะธะปะธ ะพัˆะธะฑะบะพะน.
*/
class EventsQueue : MutableLiveData<Queue<Event>>() {
@osipxd
osipxd / EventsQueue.kt
Created March 27, 2020 11:22
ViewModel and LiveData extensions
import androidx.annotation.MainThread
import androidx.lifecycle.MutableLiveData
import java.util.LinkedList
import java.util.Queue
/**
* ะšะปะฐัั-ะพั‡ะตั€ะตะดัŒ ะดะปั ะพะฑั€ะฐะฑะพั‚ะบะธ ะฒั€ะตะผะตะฝะฝั‹ั… ัะพะฑั‹ั‚ะธะน, ะฝะต ัะฒะปััŽั‰ะธั…ัั ั‡ะฐัั‚ัŒัŽ View
* ะะฐะฟั€ะธะผะตั€, ะฟะพะบะฐะท SnackBar ั ัะพะพะฑั‰ะตะฝะธะตะผ ะธะปะธ ะพัˆะธะฑะบะพะน.
*/
class EventsQueue : MutableLiveData<Queue<Event>>() {
@gabrielemariotti
gabrielemariotti / README.MD
Last active September 24, 2024 09:22
How to use the ShapeableImageView.

The Material Components Library introduced with the 1.2.0-alpha03 the new ShapeableImageView.

In your layout you can use:

 <com.google.android.material.imageview.ShapeableImageView
      android:id="@+id/image_view"
      app:srcCompat="@drawable/..." />

Then in your code apply the ShapeAppearanceModel to define your custom corners:

import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Job
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
/*
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
@er-abhishek-luthra
er-abhishek-luthra / LiveDataSharedPreferences.kt
Last active April 4, 2023 11:21
LiveData implementation of SharedPreferences in Android. Get value associated in SharedPreferences corresponding to a particular key with an additional ability to observe changes made to shared preferences using LiveData
package com.chargingwatts.livedata.sharedpref;
import android.content.SharedPreferences
import androidx.lifecycle.LiveData
abstract class SharedPreferenceLiveData<T>(val sharedPrefs: SharedPreferences,
val key: String,
val defValue: T) : LiveData<T>() {
init {
@ch8n
ch8n / AlertDialogAndroidkotlinExtension.kt
Last active February 13, 2025 11:29
Android alert dialog kotlin Extension
//Utils - Declaration
object PromptUtils {
fun alertDialog(context: Context, @StyleRes style: Int, dialogBuilder: AlertDialog.Builder.() -> Unit): Dialog {
val builder = AlertDialog.Builder(context, style).also {
it.setCancelable(false)
it.dialogBuilder()
}
return builder.create()
}
@alwarren
alwarren / RetrofitRepo.kt
Last active March 16, 2023 21:52
Using generics with Retrofit repositories. A work in progress.
package com.example.domain.api
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
open class RetrofitRepo<out S>(clazz: Class<S>) {
val service: S = Api.service(clazz)
<vector ...>
<path android:name="long-shadow"
android:pathData="...">
<aapt:attr name="android:fillColor">
<gradient
android:type="radial"
android:centerX="54"
android:centerY="54"
android:gradientRadius="76.37">
<!-- 15% black from center to 32% stop -->