Skip to content

Instantly share code, notes, and snippets.

View alan-rodriguez's full-sized avatar
🔪
​thou shalt .not()

Alan Rodriguez alan-rodriguez

🔪
​thou shalt .not()
View GitHub Profile

Build "Sources for Android 29" so you can comfortably browse the Android API source in Android Studio.

  1. Collect source files
mkdir android-sdk-source-build
cd android-sdk-source-build

mkdir -p frameworks/base
@kibotu
kibotu / GoogleMaps+Extensions.kt
Last active February 11, 2021 17:34
GoogleMap workaround to keep bearing:
/**
* map.animateCamera(CameraUpdateFactory.newLatLngBounds()) will lose ignore current bearing and rotate the camera
*/
fun GoogleMap.animateToBounds(bounds: LatLngBounds, width: Int, height: Int) = animateCamera(boundsToCameraUpdate(bounds, width, height))
/**
* map.moveCamera(CameraUpdateFactory.newLatLngBounds()) will lose ignore current bearing and rotate the camera
*/
fun GoogleMap.moveCameraToBounds(bounds: LatLngBounds, width: Int, height: Int) = moveCamera(boundsToCameraUpdate(bounds, width, height))
@alexjlockwood
alexjlockwood / WaveSquare.kt
Created March 11, 2019 02:30
Kotlin implementation of a wave square animation, inspired by https://twitter.com/beesandbombs/status/1101169015299420163
import android.content.Context
import android.graphics.Canvas
import android.graphics.Paint
import android.graphics.Path
import android.util.AttributeSet
import android.view.View
import kotlin.math.atan2
import kotlin.math.cos
import kotlin.math.sin
import kotlin.math.sqrt
@ZacSweers
ZacSweers / GuardTest.kt
Last active September 14, 2018 23:05
Demo of how the Nothing type in Kotlin can allow a Swift-style guard function
import com.google.common.truth.Truth.assertThat
import org.junit.Test
inline fun <T> guard(receiver: T?, block: () -> Nothing): T {
if (receiver == null) {
block()
}
return receiver
}
@Alanaktion
Alanaktion / Celeste Dark.sublime-color-scheme
Last active April 11, 2025 23:41
Celeste Dark Sublime Text Theme
{
// Rough modified version of Celeste to darken it up
"name": "Celeste Dark",
"author": "Sublime HQ Pty Ltd",
"variables":
{
// These colors are part of the hashed range
// and should only be used in non-source
"purple": "hsla(260, 50%, 70%, 1)",
"blue": "hsla(200, 70%, 55%, 1)",
@NikolaDespotoski
NikolaDespotoski / ViewModelParameterizedProvider.kt
Last active August 12, 2019 08:11
ViewModelProvider that instantiates ViewModel with parameterized constructor
import android.arch.lifecycle.ViewModel
import android.arch.lifecycle.ViewModelProvider
import android.arch.lifecycle.ViewModelStore
import android.arch.lifecycle.ViewModelStores
import android.support.v4.app.Fragment
import android.support.v4.app.FragmentActivity
import java.util.concurrent.atomic.AtomicBoolean
/**
* Created by Nikola on 7/19/2017.
@adavis
adavis / CommonExtensions.kt
Last active April 2, 2024 20:51
Common Android Extensions in Kotlin
fun View.visible() {
visibility = View.VISIBLE
}
fun View.invisible() {
visibility = View.INVISIBLE
}
fun View.gone() {
visibility = View.GONE
@lisawray
lisawray / MainActivity.java
Last active March 26, 2023 11:57
Vector drawables from XML with the Android support library 23.3.0
package com.xwray.vectorbinding;
import android.databinding.BindingAdapter;
import android.databinding.DataBindingUtil;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.graphics.drawable.VectorDrawableCompat;
import android.support.v7.app.AppCompatActivity;
import android.widget.TextView;
@danielgomezrico
danielgomezrico / MyClass.kt
Last active August 14, 2018 11:18
Android / Kotlin - Typedef Annotations example
import android.support.annotation.IntDef
import kotlin.annotation.AnnotationRetention
class MyClass {
companion object {
const val ITEM_SERVICES = 0L
const val ITEM_PORTFOLIO = 1L
}
@karthikrg
karthikrg / gist:0948bf5d7864c0376bcd
Created February 20, 2016 01:24
Coordinator layout that supports nesting of other coordinator layouts within
package android.support.design.widget;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.view.NestedScrollingChildHelper;
import android.util.AttributeSet;
import android.view.View;
/**