-
Roll-your-own lazy singleton
public final class Single { private static Single INSTANCE; private Single() {}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package bruhcollective.itaysonlab.libvibrancy | |
import android.graphics.Bitmap | |
import androidx.compose.ui.graphics.Color | |
import androidx.compose.ui.graphics.Paint | |
import androidx.core.graphics.applyCanvas | |
import bruhcollective.itaysonlab.libvibrancy.VibrancyMaterial | |
import coil3.size.Size | |
import coil3.transform.Transformation | |
import com.google.android.renderscript.Toolkit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/zsh | |
function get_devices() { | |
all_devices=$(command adb devices) | |
# Drop the title | |
all_devices=${all_devices#"List of devices attached"} | |
# Drop any unauthorised devices (i.e. USB debugging disabled or authorisations revoked) | |
valid_devices=$(echo $all_devices | grep -v "([[:alnum:]-]+[[:space:]]+unauthorized$)" | grep -oE "([[:alnum:]-]+[[:space:]]+device$)") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.text.Editable | |
import android.text.SpannableStringBuilder | |
import android.view.ViewGroup | |
import android.view.ViewGroup.LayoutParams.MATCH_PARENT | |
import android.view.ViewGroup.LayoutParams.WRAP_CONTENT | |
import android.widget.EditText | |
import androidx.recyclerview.widget.DiffUtil | |
import androidx.recyclerview.widget.RecyclerView |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public enum MyPermission { | |
// declare runtime permissions specific to your app here (don't keep unused ones) | |
READ_PHONE_STATE(Manifest.permission.READ_PHONE_STATE), | |
FINE_LOCATION(Manifest.permission.ACCESS_FINE_LOCATION); | |
public static MyPermission fromAndroidPermission(String androidPermission) { | |
for (MyPermission permission : MyPermission.values()) { | |
if (permission.getAndroidPermission().equals(androidPermission)) { | |
return permission; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Traced<E, S : Trace.Stage> { | |
val trace: Trace<E, S> | |
} | |
data class EffectTracer<E : Traced<E, Trace.Stage.Out>, M : Traced<E, Trace.Stage.In>> internal constructor( | |
private val state: State, | |
private val factory: (Trace<E, Trace.Stage.Out>) -> E | |
) { | |
fun launch(): Pair<EffectTracer<E, M>, Set<E>> { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ... | |
private val identityMap: (String) -> String = { it } | |
sealed class LocalizedString | |
data class ResourceString( | |
val id: Int, | |
val quantity: Int? = null, | |
val args: List<Any> = emptyList(), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package net.aquadc.recycler; | |
import android.content.Context; | |
import android.graphics.Rect; | |
import android.support.v7.widget.LinearLayoutManager; | |
import android.support.v7.widget.RecyclerView; | |
import android.util.AttributeSet; | |
import android.view.View; | |
/** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# preverify is useful only for J2ME | |
# R8 doesn't preverify by default | |
#-dontpreverify | |
-optimizationpasses 5 | |
# this seems to be enough | |
# remove indirection | |
-allowaccessmodification |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface LitePresenter<T : Any> { | |
fun attachView(view: LiteView<T>) | |
fun detachView() | |
} | |
open class BaseLitePresenter<T : Any> : LitePresenter<T> { | |
private val buffer = ArrayList<T>() | |
private var view: LiteView<T>? = null | |
private var firstAttached = false |
NewerOlder