Skip to content

Instantly share code, notes, and snippets.

View arrazyfathan's full-sized avatar
🗒️
Daily journal

Ar Razy Fathan Rabbani arrazyfathan

🗒️
Daily journal
View GitHub Profile
@jmadaminov
jmadaminov / BackgroundShader
Created April 20, 2023 10:43
Liquid like AGSL shader effect
import android.graphics.Bitmap
import android.graphics.BitmapShader
import android.graphics.RuntimeShader
import android.graphics.Shader
import android.os.Build
import androidx.compose.animation.core.withInfiniteAnimationFrameMillis
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.runtime.getValue
import androidx.compose.runtime.produceState
import androidx.compose.ui.Modifier
@n0m0r3pa1n
n0m0r3pa1n / BottomSheetExtensions.kt
Last active August 29, 2024 09:33
Bottom sheet dialog with expanding and fullscreen display
fun Fragment.showBottomSheetDialog(
@LayoutRes layout: Int,
@IdRes textViewToSet: Int? = null,
textToSet: String? = null,
fullScreen: Boolean = true,
expand: Boolean = true
) {
val dialog = BottomSheetDialog(context!!)
dialog.setOnShowListener {
val bottomSheet: FrameLayout = dialog.findViewById(com.google.android.material.R.id.design_bottom_sheet) ?: return@setOnShowListener
@DakotaLMartinez
DakotaLMartinez / instructions.md
Last active April 8, 2025 13:16
Adding an SSH key to GitHub (Mac OS X or Linux)
@gmk57
gmk57 / 1 ViewBindingDelegates.kt
Last active February 24, 2025 19:38
Kotlin delegates for Android View Binding with usage examples
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.DialogFragment
import androidx.fragment.app.Fragment
import androidx.lifecycle.DefaultLifecycleObserver
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleOwner
import androidx.viewbinding.ViewBinding
@dyazincahya
dyazincahya / TAKE-A-PHOTO-WITH-CAMERA-IN-KOTLIN.md
Last active December 10, 2024 00:58
ANDROID - TAKE A PHOTO WITH CAMERA IN KOTLIN (https://kang-cahya.com)

TAKE A PHOTO WITH CAMERA IN KOTLIN

SETTING

Step-1

Create provider_paths.xml in res/xml folder and write below code in it.

<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
@Jaosrikate
Jaosrikate / ApiHelper.kt
Created October 1, 2019 05:52
Retrofit2/OkHttp3 CookieJar Interceptor [kotlin]
// Retrofit2/OkHttp3 CookieJar Interceptor kotlin
// JaoSrikate
import android.util.Log
import android.webkit.CookieManager
import io.reactivex.Observable
import okhttp3.*
import okhttp3.logging.HttpLoggingInterceptor
import retrofit2.Call
import retrofit2.Response
@reuniware
reuniware / AESEncryptDecrypt.kt
Last active December 8, 2024 17:06
(Android/Kotlin) Encrypt and Decrypt with AES algorithm, and save/restore Secret Key and Inizialization Vector in SharedPreferences
fun encrypt(context:Context, strToEncrypt: String): ByteArray {
val plainText = strToEncrypt.toByteArray(Charsets.UTF_8)
val keygen = KeyGenerator.getInstance("AES")
keygen.init(256)
val key = keygen.generateKey()
saveSecretKey(context, key)
val cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING")
cipher.init(Cipher.ENCRYPT_MODE, key)
val cipherText = cipher.doFinal(plainText)
@CallumCoombes
CallumCoombes / FingerPaintImageView.java
Created June 26, 2018 09:10
ImageView to allow users to paint on image with their finger and add a cross image on a painted area.
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.RectF;
import android.graphics.drawable.BitmapDrawable;
@radoyankov
radoyankov / Example.kt
Last active January 27, 2023 08:59
Easy Spannable on Kotlin
val spanned = spannable{ bold("some") + italic(" formatted") + color(Color.RED, " text") }
val nested = spannable{ bold(italic("nested ")) + url("www.google.com", "text") }
val noWrapping = bold("no ") + sub("wrapping ) + sup("also ") + "works"
text_view.text = spanned + nested + noWrapping
@onyxmueller
onyxmueller / DownloadProgressUpdater.kt
Last active February 27, 2025 04:12
An Android Kotlin class to track and update download progress by the DownloadManager.
/**
* Tracks download of a DownloadManager job and reports progress.
*/
internal class DownloadProgressUpdater(private val manager: DownloadManager, private val downloadId: Long, private var downloadProgressListener: DownloadProgressListener?) : Thread() {
private val query: DownloadManager.Query = DownloadManager.Query()
private var totalBytes: Int = 0
interface DownloadProgressListener {
fun updateProgress(progress: Long)
}