Ryan Zidago
01/14/2022, 5:46 PMfun someFunction() = runBlocking {
greet()
}
suspend fun greet() = coroutineScope {
launch {
delay(1_000)
println("world!")
}
println("hello")
}
I will see both "hello" and "world!" printed, but the code is blocked until greet
is done.
However if Iaunch greet
inside a coroutine:
fun someFunction() = runBlocking {
launch {
greet()
}
}
suspend fun greet() = coroutineScope {
launch {
delay(1_000)
println("world!")
}
println("hello")
}
the code is non blocking anymore but I can't see any messages printed to the console 🤔Ryan Zidago
01/15/2022, 4:55 PM.gradle/
.idea/
bin/
build/
gradle/
gradlew
gradlew.bat
Lucas León
01/15/2022, 6:40 PMItish Srivastava
01/16/2022, 5:08 PMAyfri
01/16/2022, 7:48 PMClock.System.now()
+ the period as an Instant, how do I do this ?umitems
01/17/2022, 12:43 AMPavle Joksovic
01/17/2022, 1:41 PMprivate val _toneMap = MutableStateFlow(hashMapOf(0 to listOf<Tone>()))
and I update the value like this
toneMap[index] = tones
val toneMapCopy = HashMap(toneMap)
_toneMap.value = toneMapCopy
there is an issue when the toneMap[index] already contains a list, the value is not updated. Any idea how to fix this?Jason5lee
01/18/2022, 7:28 AMvar
property that only its get
is PublishedApi
?Kebbin
01/18/2022, 11:59 AMatan2
function.
As soon as I begin the rotation, the object jumps to point at the mouse location (rotation angle follows mouse angle), but I want to be able to rotate the object relative to the mouse angle.
I can measure the difference between the current rotation, and the mouse angle when the rotation begins, but I cant make the diff
value remain constant during the rotation!
I need to learn how you set a value once from other variables without it then constantly updating itself.
Can someone show me how? Thanks!acoconut
01/19/2022, 2:58 PMMarkRS
01/19/2022, 4:06 PMclass childClass(child: childClass?) : parentClass(child) {
constructor() : this( null)
but this breaks when calling it as childClass().
The parent class I'm trying to inherit from is a Java class, "Path" from android.graphics, but I assume that doesn't matter. I've checked that code and it claims to accept a null.Adam Firen
01/20/2022, 2:51 PMLokik Soni
01/20/2022, 3:07 PMglenkpeterson
01/20/2022, 4:12 PMRajkumar Singh
01/20/2022, 10:55 PMval exitProcessing: Boolean? = func2call(tId, fId)
if (exitProcessing == null || exitProcessing == true) return
Colton Idle
01/21/2022, 6:29 AMlist.indexOfFirst
and
list.first
but is there some way to get both?althaf
01/21/2022, 6:38 AMif (currencyInfo == null) {
val assetData =
JsonParser.getJsonDataFromAsset(context, "country_currency.json").orEmpty()
currencyInfo = Gson().fromJson(assetData, CurrencyInfoResponse::class.java)
}
holgerbrandl
01/21/2022, 1:47 PMequals
synonyms in kotlin?
data class Foo(val value: Double)
Foo(3.0) == 3.0 // fails to compile with "Operator '==' cannot be applied to 'Foo' and 'Double'"
Foo(3.0).equals(3) // compiles
Javier
01/21/2022, 2:10 PMLokik Soni
01/21/2022, 4:59 PMv79
01/21/2022, 9:20 PMget()
method? I have two different objects with the same values, and an overridden equals method which returns true. But as a key to hashmap, they don't match.Shalom Halbert
01/22/2022, 9:41 PMInt.MAX_VALUE
to a Double
? I’ve tried toDouble()
, but that outputs 2.147483647E9Umar Ata
01/23/2022, 9:26 AMloke
01/23/2022, 1:26 PMPhilip Hagen
01/24/2022, 8:52 AMdave08
01/24/2022, 3:11 PM@ExperimentalStdlibApi
inline fun <reified T> Data.getValue(obj: Any?, prop: KProperty<*>): T {
return when(T::class) {
String::class -> getString(prop.name) as T
Int::class -> getInt(prop.name, -1) as T
Boolean::class -> getBoolean(prop.name, false) as T
Enum::class -> getString(prop.name)?.let { enumValueOf<T>(it) } // This doesn't compile...
else -> error("Trying to retrieve invalid type in Data for ${prop.name}: ${T::class}")
}
}
acoconut
01/25/2022, 6:21 PMdata class WorkOrderCommentFilter constructor(
val pagination: WorkOrderCommentPaginationFilter? = null,
val id: Int? = null,
val workOrderId: Int? = null,
val comment: String? = null,
val checkpointTypeName: String? = null,
val createdAt: LocalDateTime? = null,
)
and this POJO:
@Introspected
data class WorkOrderCommentFilterDto constructor(
@field:[QueryValue Parameter(description = "Pagination object")]
val pagination: WorkOrderCommentPaginationFilter? = null,
@field:[QueryValue Parameter(description = "Comment Id", example = "1")]
val id: Int? = null,
@field:[QueryValue Parameter(description = "WorkOrder Id", example = "1")]
val workOrderId: Int? = null,
@field:[QueryValue Parameter(description = "Comment message")]
val comment: String? = null,
@field:[QueryValue Parameter(description = "CheckpointType name")]
val checkpointTypeName: String? = null,
@field:[QueryValue Parameter(description = "Comment creation date")]
val createdAt: Long? = null,
)
when I use a mapper like this:
@Mapper(componentModel = "jsr330", uses = [LocalDateTimeLongMapper::class])
interface WorkOrderCommentMapper {
fun toDao(workOrderCommentFilterDto: WorkOrderCommentFilterDto): WorkOrderCommentFilter
}
The implementation is not right:
@Override
public WorkOrderCommentFilter toDao(WorkOrderCommentFilterDto workOrderCommentFilterDto) {
if ( workOrderCommentFilterDto == null ) {
return null;
}
WorkOrderCommentFilter workOrderCommentFilter = new WorkOrderCommentFilter();
return workOrderCommentFilter;
}
I feel like I must be missing something, right? Thanks for any help in advance!Greg Rynkowski
01/26/2022, 10:16 AM// all T - java classes implementing ViewDataBinding, each providing a static `bind` method
// ViewDataBinding - a Java abstract class (with no declaration of `bind`)
interface BindingAware<T : ViewDataBinding> {
var f: T
fun bind(v: View) {
// f = T.bind(a) // <= how to call static method provided by class behind T?
}
}
How to call static method of T, having only T?Arun Joseph
01/26/2022, 12:22 PMdata class SomeState(
val property1: String,
val property2: String
) {
override fun toString(): String {
return "property XX updated"
}
}
Jasin Colegrove
01/26/2022, 2:15 PMJasin Colegrove
01/26/2022, 2:15 PMLeon W
01/26/2022, 2:21 PMclass CompanionTest {
companion object {
private val defaultName = "name"
}
var name = defaultName
}
We can assign the private member defaultName
, which is located in the companion object, to the class member name
.