Skip to content

Instantly share code, notes, and snippets.

View androiddevcoding's full-sized avatar
🎯
Что-то ничего не пишется, Жду: а вдруг талант отыщется Или нет — какая разница!

Android Developer androiddevcoding

🎯
Что-то ничего не пишется, Жду: а вдруг талант отыщется Или нет — какая разница!
View GitHub Profile
@yavor87
yavor87 / androidPlayAudio.java
Last active August 3, 2023 21:40
Record, play and visualize raw audio data in Android
ShortBuffer mSamples; // the samples to play
int mNumSamples; // number of samples to play
void playAudio() {
new Thread(new Runnable() {
@Override
public void run() {
int bufferSize = AudioTrack.getMinBufferSize(SAMPLE_RATE, AudioFormat.CHANNEL_OUT_MONO,
AudioFormat.ENCODING_PCM_16BIT);
if (bufferSize == AudioTrack.ERROR || bufferSize == AudioTrack.ERROR_BAD_VALUE) {
@ZacSweers
ZacSweers / BlurrinessDetection.kt
Last active July 6, 2024 16:36
Demo implementation of client-side image blurriness detection on Android using renderscript.
/*
* Copyright (c) 2018. Uber Technologies
*
* 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
@hlayan
hlayan / Event.kt
Last active September 1, 2024 15:35
Single Event Solution for Kotlin Flow and Compose
class Event<out T>(private val _value: T?) {
private val used = AtomicBoolean(false)
val value: T? get() = if (used.compareAndSet(false, true)) _value else null
}
val EmptyEvent get() = Event(null)
typealias FlowEvent<T> = StateFlow<Event<T>>