Skip to content

Instantly share code, notes, and snippets.

View Miha-x64's full-sized avatar
🍵
へ‿(◉‿◉)‿ㄏ

Mike Miha-x64

🍵
へ‿(◉‿◉)‿ㄏ
View GitHub Profile
@Miha-x64
Miha-x64 / EditableAdapter.kt
Last active July 10, 2023 09:24
Another approach to EditTexts inside RecyclerView
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
@Miha-x64
Miha-x64 / FlexibleNumberPicker.java
Last active December 3, 2021 13:45
NumberPicker fork supporting gravity, scale and alpha interpolation, typeface styling, and more.
/*
* Copyright (C) 2008 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@Miha-x64
Miha-x64 / GsonNullValueSkipping.java
Last active June 9, 2022 14:19
Gson has serializeNulls() setting but doesn't have dontDeserializeNulls(). This is useful to avoid assigning nulls to properties keeping their default values assigned in constructor instead.
import com.google.gson.Gson;
import com.google.gson.JsonIOException;
import com.google.gson.TypeAdapter;
import com.google.gson.internal.JsonReaderInternalAccess;
import com.google.gson.reflect.TypeToken;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonToken;
import com.google.gson.stream.JsonWriter;
import com.google.gson.stream.MalformedJsonException;
import okhttp3.MediaType;
@Miha-x64
Miha-x64 / _AsyncVox.md
Last active April 10, 2023 09:29
async-await for VoxImplant VoxEngine

This library provides several awaitable commands to VoxImplant VoxEngine API.

This is unnofficial community-driven software licensed under Apache 2.0 and provided “as is”, without warranty of any kind.

Idea

There's a plenty of event listeners and async callbacks, as always in JS. The idea is to provide a handy way of managing async operations and awaiting their results.

class GradientStrokeDrawable : Drawable() {
var radius: Float = 0f
set(radius) {
if (field != radius) {
check(radius.isFinite() && radius >= 0f)
field = radius
path.rewind()
invalidateSelf()
}
package net.aquadc.util;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.util.Iterator;
import java.util.function.Consumer;
import java.util.stream.Stream;
public final class Iterators {
private Iterators() {}
@Miha-x64
Miha-x64 / relativeLayout.kt
Last active April 26, 2021 18:46
RelativeLayout for Splitties Views DSL
@file:Suppress("NOTHING_TO_INLINE")
package net.aquadc.commonandroid.views
import android.content.Context
import android.view.View
import android.widget.RelativeLayout
import android.widget.RelativeLayout.TRUE
import androidx.annotation.IdRes
import splitties.views.dsl.core.wrapContent
import kotlin.contracts.ExperimentalContracts
import android.graphics.Bitmap;
import androidx.annotation.IntRange;
import androidx.annotation.NonNull;
import java.util.Arrays;
/**
* This is copied from https://stackoverflow.com/a/10028267/3050249
* and optimized for less memory consumption & better locality, and creates less GC pressure.
import android.os.Handler;
import android.os.Looper;
import androidx.annotation.WorkerThread;
import java.io.File;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
@Miha-x64
Miha-x64 / Xml.java
Last active December 22, 2022 14:03
HTML/XML escaping utils, answering https://stackoverflow.com/a/61215915/3050249
import java.io.IOException;
import java.io.UncheckedIOException;
/**
* XML escaping utils.
*
* Source: https://gist.github.com/Miha-x64/4ed50f1d5593e45a452efbf456aa1db4
*/
public final class Xml {