Skip to content

Instantly share code, notes, and snippets.

View MazyNoc's full-sized avatar

Mikael Alfredsson MazyNoc

View GitHub Profile
@MazyNoc
MazyNoc / WindowBrightness.kt
Created April 19, 2022 12:21
Helper function to set brightness of the current window in Android
var Window.screenBrightness: Float
set(value) {
val a = this.attributes
a.screenBrightness = value
this.attributes = a
}
get() = this.attributes.screenBrightness
@MazyNoc
MazyNoc / colors.xml
Last active May 20, 2022 05:17
All material design colors in Android XML
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Red -->
<color name="red">#FFF44336</color>
<color name="red_50">#FFFFEBEE</color>
<color name="red_100">#FFFFCDD2</color>
<color name="red_200">#FFEF9A9A</color>
<color name="red_300">#FFE57373</color>
<color name="red_400">#FFEF5350</color>
@MazyNoc
MazyNoc / colors.kt
Last active January 17, 2024 23:42
All material colors, defined in kotlin, compose
package material.colors.all
import androidx.compose.ui.graphics.Color
/* Red */
val Red = Color( 0xfff44336)
val Red50 = Color( 0xffffebee)
val Red100 = Color( 0xffffcdd2)
val Red200 = Color( 0xffef9a9a)
val Red300 = Color( 0xffe57373)
@MazyNoc
MazyNoc / LifecycleAwareAdapter.kt
Last active February 4, 2022 21:58
A RecyclerView adapter that respects both the RecyclerViews attach and detach view, and an external LifecycleOwner.
import android.util.Log
import android.view.View
import androidx.lifecycle.DefaultLifecycleObserver
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.LifecycleRegistry
import androidx.recyclerview.widget.RecyclerView
import app.BuildConfig