This file contains 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 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.* |
This file contains 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
// 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 file contains 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
// 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() |