Skip to content

Instantly share code, notes, and snippets.

View kibotu's full-sized avatar
🎯
Focusing

Jan Rabe kibotu

🎯
Focusing
View GitHub Profile
@JolandaVerhoef
JolandaVerhoef / Compose-PhotoGrid.kt
Created June 30, 2023 12:14
Photogrid with multi-select and zoomable images
/*
* Copyright 2023 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
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@surajsau
surajsau / ParallaxScreen.kt
Last active April 16, 2024 13:53
Parallax effect with Jetpack Compose
@Composable
fun ParallaxScreen(modifier: Modifier = Modifier) {
val context = LocalContext.current
val scope = rememberCoroutineScope()
var data by remember { mutableStateOf<SensorData?>(null) }
DisposableEffect(Unit) {
val dataManager = SensorDataManager(context)
dataManager.init()
@darvld
darvld / CircularReveal.kt
Created October 3, 2021 23:03
A circular reveal effect modifier for Jetpack Compose.
package cu.spin.catalog.ui.components
import android.annotation.SuppressLint
import androidx.compose.animation.core.animateFloat
import androidx.compose.animation.core.updateTransition
import androidx.compose.runtime.State
import androidx.compose.ui.Modifier
import androidx.compose.ui.composed
import androidx.compose.ui.draw.drawWithCache
import androidx.compose.ui.geometry.Offset
@devadvance
devadvance / .bashrc
Created February 28, 2021 20:31
Convenient ffmpeg shell functions
#######################################
# Displays a yes/no prompt to continue that repeats until input matches.
# Arguments:
# $1 - (optional) a string representing the yes/no question to ask
# $2 - (optional) a string representing the prompt style.
# Returns:
# 0 to proceed further (indicates "yes"), 1 to stop (indicates "no").
#######################################
continue_prompt() {
local prompt default reply
@kevinvanmierlo
kevinvanmierlo / CrossFadeDrawable.java
Last active July 9, 2020 21:06
Glide respecting different aspect ratio placeholder and loading image
package nl.kevinvanmierlo.testtransitiondrawable;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.SystemClock;
import androidx.annotation.NonNull;
@saikiran91
saikiran91 / BaseUpdateCheckActivity.kt
Last active May 12, 2022 17:13
Android officially announced the in-app updates. https://developer.android.com/guide/app-bundle/in-app-updates. This is the code sample for handling both IMMEDIATE and FLEXIBLE updates in a single activity; Kotlin way.
import android.app.Activity
import android.content.Intent
import android.content.IntentSender
import android.os.Bundle
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat
import com.google.android.material.snackbar.Snackbar
import com.google.android.play.core.appupdate.AppUpdateManager
import com.google.android.play.core.appupdate.AppUpdateManagerFactory
@kibotu
kibotu / uiModule.kt
Created March 6, 2019 12:34
koin ui module
val uiModule = module(definition = {
factory { get<NavHostFragment>().navController }
factory { ContextHelper.getAppCompatActivity()!!.supportFragmentManager.findFragmentById(R.id.navHost) as NavHostFragment }
})
inline fun <reified T : Any> Any.inject(
name: String = "",
scope: Scope? = null,
noinline parameters: ParameterDefinition = emptyParameterDefinition()
) = lazy { getKoin().koinContext.get<T>(name, scope, parameters) }
@Shahbazsultan
Shahbazsultan / MyActivity.java
Created January 24, 2019 17:21
Keystore android encryption and decryption
public class MyActivity extends AppCompatActivity{
@Override
public void onCreate(Bundle savedInstanceState) {
setcontentView(R.layout.myview);
//To set the encrypted string to keystore
SharedPrefUtils.put(MyActivity.this , "My Key" ,"My keys value");
//To get the decrypted string from keystore
@patrickjh
patrickjh / CustomizedAndroidRunner.java
Last active April 2, 2023 21:08
Junit Retries annotation for Android
package whatever;
import android.app.Instrumentation;
import android.os.Bundle;
import android.support.test.internal.runner.junit4.AndroidJUnit4ClassRunner;
import android.support.test.internal.util.AndroidRunnerParams;
import org.junit.rules.TestRule;
import org.junit.runners.model.InitializationError;
@michaelbukachi
michaelbukachi / realm.kt
Last active May 24, 2022 04:31
Realm Coroutines
import io.realm.*
import io.realm.kotlin.where
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import kotlinx.coroutines.suspendCancellableCoroutine
import kotlin.coroutines.resume
import kotlin.coroutines.resumeWithException
private suspend fun <T: RealmObject, S: RealmQuery<T>> findAllAwait(query: S): RealmResults<T> = suspendCancellableCoroutine { continuation ->
val listener = RealmChangeListener<RealmResults<T>> { t -> continuation.resume(t) }