Marko Kovacevic
11/15/2020, 4:14 PMWill Nixon
11/15/2020, 9:03 PMjava.lang.RuntimeException:
at android.os.AsyncTask$4.done (AsyncTask.java:415)
at java.util.concurrent.FutureTask.finishCompletion (FutureTask.java:383)
at java.util.concurrent.FutureTask.setException (FutureTask.java:252)
at java.util.concurrent.FutureTask.run (FutureTask.java:271)
at android.os.AsyncTask$SerialExecutor$1.run (AsyncTask.java:305)
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:641)
at java.lang.Thread.run (Thread.java:923)
Caused by: java.lang.IllegalArgumentException:
at com.google.api.client.repackaged.com.google.common.base.Preconditions.checkArgument (Preconditions.java:5)
at com.google.api.client.util.Preconditions.checkArgument (Preconditions.java:10)
at com.google.api.client.googleapis.auth.oauth2.GoogleClientSecrets.getDetails (GoogleClientSecrets.java:10)
at com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeFlow$Builder.<init> (GoogleAuthorizationCodeFlow.java:10)
at com.jenix.lemmi.ui.splashscreen.SplashScreenActivity.getCredentials (SplashScreenActivity.java:10)
at com.jenix.lemmi.ui.splashscreen.SplashScreenActivity.access$getCredentials (SplashScreenActivity.java:10)
at com.jenix.lemmi.ui.splashscreen.SplashScreenActivity$AsyncGetCredentials.doInBackground (SplashScreenActivity.java:10)
at com.jenix.lemmi.ui.splashscreen.SplashScreenActivity$AsyncGetCredentials.doInBackground (SplashScreenActivity.java:10)
at android.os.AsyncTask$3.call (AsyncTask.java:394)
at java.util.concurrent.FutureTask.run (FutureTask.java:266)
at android.os.AsyncTask$SerialExecutor$1.run (AsyncTask.java:305)
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:641)
at java.lang.Thread.run (Thread.java:923)
From my understanding, it’s possibly due to Oauth credentials not matching - I’m using the SHA-1 signing key from the Play Console, so not sure what else i’m missing, Any ideas?coder
11/16/2020, 8:38 AMspeed_star
11/17/2020, 8:33 AMnull
property is exists in data class. Should I check for each property like as below? Or there is other good way?
data class Book(val name: String?, val author: String?, val price: Int?)
fun isExistNull(): Boolean {
if (name == null || author == null || price == null) {
return true
}
return false
}
waltermcq
11/18/2020, 7:18 PM// send data - asynchronous
producer.send(record, new Callback() {
public void onCompletion(RecordMetadata recordMetadata, Exception e) {
// executes every time a record is successfully sent or an exception is thrown
if (e == null) {
// the record was successfully sent
<http://logger.info|logger.info>("Received new metadata. \n" +
"Topic:" + recordMetadata.topic() + "\n" +
"Partition: " + recordMetadata.partition() + "\n" +
"Offset: " + recordMetadata.offset() + "\n" +
"Timestamp: " + recordMetadata.timestamp());
} else {
logger.error("Error while producing", e);
}
}
});
}
oday
11/19/2020, 9:06 AMprivate fun resetCounterAndGame(counter: Int) {
if (counter == 2) {
gameButtonText.set(resProvider.getString(R.string.try_another_number))
gameStarted = false
counter = 0 <--- val cannot be reassigned of course
}
}
Ifvwm
11/20/2020, 3:28 AMMohamed Daif
11/21/2020, 2:06 PMMarko Kovacevic
11/21/2020, 8:34 PMsuspend fun HackerNewsApi.fetchItem(id: Int): CompletableFuture<HttpResponse<String>> {
return client.sendAsync(
request("${this.domain}/v0/item/$id.json"),
HttpResponse.BodyHandlers.ofString()
)
}
Colton Idle
11/22/2020, 2:59 AMWeakReference
something that's popular? Should I be using it in some typical situations of development? I understand that I won't be using the entire std-lib, but references are everywhere and so it seems like I should have come across a valid use of WeakReference by now (I mostly build android apps if it helps)ursus
11/22/2020, 3:10 AMpoohbar
11/22/2020, 4:00 PM(0..10).map { random.nextDouble() }
?
Basically, I am looking for repeat(n)
where the function can return a value:
newRepeat(10).map { random.nextDouble() }
Colton Idle
11/23/2020, 1:41 AMNikhil
11/23/2020, 3:58 AMRuckus
11/23/2020, 4:22 AMWildOne (Yuri)
11/23/2020, 9:12 AMMateusz Holak
11/23/2020, 3:55 PMLiveData<X>.map {} => transform type MutableLiveData<DomanType> -> LiveData<UiType>
I would like replace LiveData with StateFlow but i need to transform domain type to UI type that i have for each layers. Which one method i should use ? The same method "map" in Flow return Flow<R> but i need StateFlow<T>. I can also do transormation when i have data from useCase and then assign MutableStateFlow to StateFlow by invoking asStateFlow but its a little worse solution than i have with LiveData right now. Thanks for any advice.
I found similar question here:
https://github.com/Kotlin/kotlinx.coroutines/issues/2008Nicolas Mariano Obregon
11/24/2020, 3:33 PMrunCatching
, something like this below, how should I define my interface method signature in order to return whatever the runCatching returns? I hope I was clear enough. Thanks in advanced
interface IMyInterface {
suspend fun myFunction()
}
class MyClass : IMyInterface {
override suspend fun myFunction() = runCatching {
}.onFailure { ... }.getOrThrow()
}
alex cole
11/25/2020, 12:50 AMdef myFunction(a,b,c):
return lambda x: a * x ** 2 + b * x + c
however I am not understanding what is wrong with
fun potentialEnergy(charge1, charge2, k){
val x = {position: Double -> k * charge1 * charge2 / position / position} // creating lambda function
return x
}
What is wrong with this lambda function expression.UnAn
11/25/2020, 5:29 PMruwinmike
11/27/2020, 10:48 AMMaxime Recuerda
11/28/2020, 5:25 PMJoshy Josh
12/04/2020, 11:19 PMfunctionName<ClassName> { …className functions}
? I know it can be done specifically, but I was wondering if there was a way to create a generic approach. in Kotlin.Tony Blundell
12/05/2020, 7:52 PMclass WsClient {
private val url = "<http://example.com>"
private val httpClient = HttpClient { install(WebSockets) }
suspend fun start() {
httpClient.wss(HttpMethod.Get, url) {
send("Hello")
while (true) {
when (val frame = incoming.receive()) {
is Frame.Text -> println(frame.readText())
is Frame.Binary -> println(frame.readBytes())
}
}
}
}
}
fun main() = runBlocking {
WsClient().start()
}
poohbar
12/06/2020, 4:19 PMException
or RuntimeException
in Kotlin? I thought it doesn't but my Exception
extension is getting wrapped in UndeclaredThrowableException
when interacting with a Java library.Michael
12/08/2020, 3:19 PMAndrea Giuliano
12/09/2020, 1:06 PM.toList()
method no problem but then when I check for efficiency the blame graph tells me that tolist() is not that efficient. Anything I’m missing? Any suggestion?Daniele B
12/09/2020, 7:20 PMSteven Wang
12/09/2020, 8:40 PMmickeelm
12/12/2020, 11:54 AMprivate fun <String> HashMap<String, String>.myExt(key: String, incomingValue: String) {
this[key] = incomingValue
}
But not this
private fun <String> HashMap<String, String>.myExt(key: String, incomingValue: String) {
this[key] = "something else"
}
The latter gives me (in IntelliJ):
Type mismatch.
Required: String#1 (type parameter of myExt)
Found: kotlin.String
mickeelm
12/12/2020, 11:54 AMprivate fun <String> HashMap<String, String>.myExt(key: String, incomingValue: String) {
this[key] = incomingValue
}
But not this
private fun <String> HashMap<String, String>.myExt(key: String, incomingValue: String) {
this[key] = "something else"
}
The latter gives me (in IntelliJ):
Type mismatch.
Required: String#1 (type parameter of myExt)
Found: kotlin.String
Joris PZ
12/12/2020, 11:58 AMthis[key] = "something else" as String
fixes the compiler error?String#1
? Seems like a bugmickeelm
12/12/2020, 12:03 PMJoris PZ
12/12/2020, 12:04 PMfun HashMap<String, String>.myExt(key: String, incomingValue: String) {
this[key] = "something else"
}
<String>
makes no sense hereString
as a generic type parameter instead of kotlin.String
?mickeelm
12/12/2020, 12:05 PMJoris PZ
12/12/2020, 12:05 PMmickeelm
12/12/2020, 12:05 PMString
vs kotlin.String
I don't know reallyMilan Hruban
12/12/2020, 1:27 PMString
in the original function is just a name you have given to the generic parameter, it has nothing to do with kotlin.String
. You could replace it with Abcd
(or more often used T
) and the function would work exactly samemickeelm
12/12/2020, 1:31 PMJoris PZ
12/12/2020, 2:15 PMMilan Hruban
12/12/2020, 2:31 PMmickeelm
12/12/2020, 2:32 PMnanodeath
12/13/2020, 5:44 PMMatteo Mirk
12/14/2020, 11:31 AMMessage<REQUEST, RESPONSE>
or in Assertj:
interface Assert<SELF extends Assert<SELF, ACTUAL>, ACTUAL> ...