Skip to content

Instantly share code, notes, and snippets.

View Puneet1796's full-sized avatar
🏠
Working from home

Puneet Verma Puneet1796

🏠
Working from home
View GitHub Profile
// This is the Java equivalent function for GetLiveDataValue.kt gist.
// Refer to link below
// https://gist.github.com/Puneet1796/ac1803b96735c61cbe1a8c86f473681f
@SuppressWarnings("unchecked")
@Nullable
public static <T> T getBlockingValue(@NotNull final LiveData<T> liveData) throws InterruptedException {
final Object[] value = new Object[1];
final CountDownLatch latch = new CountDownLatch(1);
Observer<T> innerObserver = new Observer<T>() {
@Override
// This extension function will get the value from LiveData.
// It should be used in testing.
// For Queries returning values wrapped around LiveData.
@Throws(InterruptedException::class)
fun <T> LiveData<T>.getValueBlocking(): T? {
var value: T? = null
val latch = CountDownLatch(1)
val innerObserver = Observer<T> {
value = it
latch.countDown()
@Puneet1796
Puneet1796 / NumberLockView.kt
Last active November 24, 2022 23:04
Pin Unlock View
package com.datavault.compose.components
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.grid.GridCells
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material.*