kotlin

Setting global variable with Cloud Firestore on Kotlin

别说谁变了你拦得住时间么 提交于 2021-02-11 17:44:47
问题 again :) I got a question about Cloud Firestore and Kotlin. I need to get data from firestore with some code like this: { val comments = mutableListOf<Comment>() val firestore = FirebaseFirestore.getInstance() firestore.collection(collection).document(documentID).collection("comments") .addSnapshotListener { querySnapshot, firebaseFirestoreException -> comments = querySnapshot?.toObjects(Comment::class.java)!! // do something with 'comments'. Works: comments is populated } // do something

How to transfer plain text via Android NFC?

烂漫一生 提交于 2021-02-11 17:40:53
问题 I am new to Android NFC and developing NFC application in android. My idea is Device A need to send a plain text to Device B. Is it possible in Android NFC? I just tried with Tag Dispatcher (enableForegroundDispatch , disableForegroundDispatch) on both Reader and Writer. My Reader side code is : nfcAdapter.enableForegroundDispatch(this, pendingIntent, intentFilters, techList) override fun onNewIntent(intent: Intent?) { intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES)?.also {

Theme.MaterialComponents style ruins Firebase AuthUI layout

不想你离开。 提交于 2021-02-11 17:36:05
问题 I am writing my first app in kotlin and am using FirebaseAuth & AuthUI for authentication. My login screen works perfectly, and looked like: Now I am trying to change my AppTheme's parent to "Theme.MaterialComponents.NoActionBar" (from "Theme.AppCompat.NoActionBar") but the login screen changed to: I call the login screen like so: startActivityForResult( authUI.createSignInIntentBuilder() .setAvailableProviders(providers) .build(), RC_SIGN_IN ) I tried to add .setTheme(R.style.FirebaseUI)

I need to update a certain array entry of my Map in Firestore

烂漫一生 提交于 2021-02-11 15:40:55
问题 I want to update a product of my products array. I have an array of products in a collection products[{ - 0 productPrice: 123 - 1 productPrice: 432 }] In my code I have passed the position of the element I want to update in that array of products suspend fun updateProductPrice(position:Int,shopId: String,price: Int): Resource<Unit> { FirebaseFirestore.getInstance().collection("shops").document(shopId).update("products"[position]) //here I need to get productPrice and update its value to the

I need to update a certain array entry of my Map in Firestore

烈酒焚心 提交于 2021-02-11 15:40:46
问题 I want to update a product of my products array. I have an array of products in a collection products[{ - 0 productPrice: 123 - 1 productPrice: 432 }] In my code I have passed the position of the element I want to update in that array of products suspend fun updateProductPrice(position:Int,shopId: String,price: Int): Resource<Unit> { FirebaseFirestore.getInstance().collection("shops").document(shopId).update("products"[position]) //here I need to get productPrice and update its value to the

How can I check if an array contains a value of another array?

荒凉一梦 提交于 2021-02-11 15:40:37
问题 I would like to check to see if an array contains a value from another array. For example, I would like to check if the array A contains a value from an array B. I'm looking for any value not one specific value. 回答1: If you're wanting to see if there is any overlap at all between two arrays, you can do this: fun Array<*>.intersects(other: Array<*>) = any { it in other } As mentioned in the comments below, this is O(n^2) so with large arrays, prefer: fun Array<*>.intersects(other: Array<*>) =

Connect Operation timed out while running mvn test

感情迁移 提交于 2021-02-11 15:27:21
问题 I have created a new quarkus project using online tool with kotlin extenstion. I am able to execute ./mvnw compile quarkus:dev and curl on http://localhost:8080. However I am getting following exception while executing ./mvnw test . [INFO] ------------------------------------------------------- [INFO] T E S T S [INFO] ------------------------------------------------------- [INFO] Running dev.sanket.ExampleResourceTest 2020-02-20 14:06:27,010 INFO [io.quarkus] (main) Quarkus 1.2.1.Final

Connect Operation timed out while running mvn test

百般思念 提交于 2021-02-11 15:26:26
问题 I have created a new quarkus project using online tool with kotlin extenstion. I am able to execute ./mvnw compile quarkus:dev and curl on http://localhost:8080. However I am getting following exception while executing ./mvnw test . [INFO] ------------------------------------------------------- [INFO] T E S T S [INFO] ------------------------------------------------------- [INFO] Running dev.sanket.ExampleResourceTest 2020-02-20 14:06:27,010 INFO [io.quarkus] (main) Quarkus 1.2.1.Final

How to fix NSInternalInconsistencyException in TornadoFX when running on macOS 10.14?

两盒软妹~` 提交于 2021-02-11 15:19:33
问题 I'm using TornadoFX and I've recently upgraded to macOS 10.14. The problem is that I get this error whenever I open a dialog and focus another application window: 2019-01-23 13:32:31.270 java[9369:78410] *** Assertion failure in -[NSEvent _initWithCGEvent:eventRef:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/AppKit/AppKit-1671.20.108/AppKit.subproj/NSEvent.m:1969 2019-01-23 13:32:46.218 java[9369:78410] unrecognized type is 4294967295 2019-01-23 13:32:46.218 java[9369:78410] ***

Recursively finding all partitions of a set of n objects into k non-empty subsets

爱⌒轻易说出口 提交于 2021-02-11 15:01:20
问题 I want to find all partitions of a n elements into k subsets, this is my algorithm based on recursive formula for finding all Stirling second numbers fun main(args: Array<String>) { val s = mutableSetOf(1, 2, 3, 4, 5) val partitions = 3 val res = mutableSetOf<MutableSet<MutableSet<Int>>>() partition(s, partitions, res) //println(res) println("Second kind stirling number ${res.size}") } fun partition(inputSet: MutableSet<Int>, numOfPartitions: Int, result: MutableSet<MutableSet<MutableSet<Int>