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
@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 -> {
@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)
@humblehacker
humblehacker / mutablelivedata.md
Last active October 4, 2024 19:17
Don't expose MutableLiveData
@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.
@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.

@lopspower
lopspower / README.md
Last active October 13, 2025 08:43
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

@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