Skip to content

Instantly share code, notes, and snippets.

View alejandro-rios's full-sized avatar

Alejandro Rios alejandro-rios

  • Medellin, Colombia
View GitHub Profile
@nolanlawson
nolanlawson / how-to-link-two-android-projects.md
Last active January 17, 2024 16:04
How to link an Android app to a local library project
@lopspower
lopspower / README.md
Last active July 11, 2025 21:46
Hexadecimal color code for transparency

Hexadecimal color code for transparency

Twitter

How to set transparency with hex value ?

For example, you want to set 40% alpha transparence to #000000 (black color), you need to add 66 like this #66000000.

Download This sample on Google Play Store

@webserveis
webserveis / material text sizes.md
Last active August 10, 2024 02:29 — forked from passsy/material text sizes.md
Material font sizes

Material text sizes XML for Android

Simple helper file for standard text sizes in material design. The sizes are provided by the material design documentation https://www.google.com/design/spec/style/typography.html#typography-roboto

material typography

Standard Styles

Too many type sizes and styles at once can wreck any layout. A typographic scale is a limited set of type sizes that work well together, along with the layout grid. The basic set of styles are based on a typographic scale of 12, 14, 16, 20, and 34.

@anolivetree
anolivetree / RecyclerViewUtil.kt
Last active August 24, 2021 13:57
Callback to notify the current page is changed on RecyclerView + PagerSnapHelper.
package com.example.util
import android.support.v7.widget.LinearLayoutManager
import android.support.v7.widget.RecyclerView
/**
* Call listener when the current page is changed.
* Use this with LinearLayoutManager and PagerSnapHelper.
*
* Whether the listener is called at first might depend on the version of RecyclerView.
@humblehacker
humblehacker / mutablelivedata.md
Last active October 4, 2024 19:17
Don't expose MutableLiveData
@antonyharfield
antonyharfield / RailwayOP-CompleteExample.kt
Created April 29, 2019 17:51
Railway Oriented Programming in Kotlin (as described here)
// Result is a superpowered enum that can be Success or Failure
// and the basis for a railway junction
sealed class Result<T>
data class Success<T>(val value: T): Result<T>()
data class Failure<T>(val errorMessage: String): Result<T>()
// Composition: apply a function f to Success results
infix fun <T,U> Result<T>.then(f: (T) -> Result<U>) =
when (this) {
is Success -> f(this.value)
@alana-mullen
alana-mullen / ConnectivityExtension.kt
Created January 16, 2020 00:28
Android Kotlin extension to check network connectivity
import android.content.Context
import android.net.ConnectivityManager
import android.net.NetworkCapabilities
import android.os.Build
val Context.isConnected: Boolean
get() {
val connectivityManager = this.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
return when {
Build.VERSION.SDK_INT >= Build.VERSION_CODES.M -> {
@faruktoptas
faruktoptas / debounce.kt
Created March 5, 2020 06:28
Kotlin coroutine debounce for EditText
fun <T> debounce(
waitMs: Long = 300L,
scope: CoroutineScope,
destinationFunction: (T) -> Unit
): (T) -> Unit {
var debounceJob: Job? = null
return { param: T ->
debounceJob?.cancel()
debounceJob = scope.launch {
delay(waitMs)
@BurakDizlek
BurakDizlek / CountryFlags.java
Last active December 31, 2024 00:23
Get to flag unicode as String and use it anywhere.
public class CountryFlags {
private static String A = getEmojiByUnicode(0x1F1E6);
private static String B = getEmojiByUnicode(0x1F1E7);
private static String C = getEmojiByUnicode(0x1F1E8);
private static String D = getEmojiByUnicode(0x1F1E9);
private static String E = getEmojiByUnicode(0x1F1EA);
private static String F = getEmojiByUnicode(0x1F1EB);
private static String G = getEmojiByUnicode(0x1F1EC);
private static String H = getEmojiByUnicode(0x1F1ED);
private static String I = getEmojiByUnicode(0x1F1EE);
/**
* Navigates only if this is safely possible; when this Fragment is still the current destination.
*/
fun Fragment.navigateSafe(
@IdRes resId: Int,
args: Bundle? = null,
navOptions: NavOptions? = null,
navigatorExtras: Navigator.Extras? = null
) {
if (mayNavigate()) findNavController().navigate(