Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Jan Rabe kibotu

🎯
Focusing
View GitHub Profile
@surajsau
surajsau / ParallaxScreen.kt
Last active March 29, 2023 02:30
Parallax effect with Jetpack Compose
View ParallaxScreen.kt
@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()
@devadvance
devadvance / .bashrc
Created February 28, 2021 20:31
Convenient ffmpeg shell functions
View .bashrc
#######################################
# 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
@rodrigosambadesaa
rodrigosambadesaa / ConnectivityAndInternetAccess.kt
Last active April 1, 2022 09:21 — forked from str4d/Connectivity.java
Class to check the Connectivity and Internet Access of an Android device.
View ConnectivityAndInternetAccess.kt
/*
* Copyright (c) 2014 str4d
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
@kevinvanmierlo
kevinvanmierlo / CrossFadeDrawable.java
Last active July 9, 2020 21:06
Glide respecting different aspect ratio placeholder and loading image
View CrossFadeDrawable.java
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.
View BaseUpdateCheckActivity.kt
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
View uiModule.kt
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
View MyActivity.java
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 June 14, 2020 20:55
Junit Retries annotation for Android
View CustomizedAndroidRunner.java
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
View realm.kt
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) }
@murdly
murdly / Crossfader.kt
Last active January 19, 2021 08:19
Cross fading images across requests with Glide library.
View Crossfader.kt
import android.content.Context
import android.graphics.drawable.Drawable
import android.util.AttributeSet
import android.view.View
import android.view.ViewGroup
import android.view.animation.AnimationUtils
import android.widget.ImageView
import android.widget.ViewSwitcher
import com.bumptech.glide.load.DataSource
import com.bumptech.glide.load.engine.GlideException