mohsenoid
10/29/2021, 9:05 AMSlackbot
10/29/2021, 2:04 PMAmrJyniat
10/29/2021, 6:54 PMEmanuel Frost
10/29/2021, 7:24 PMSam
10/30/2021, 7:52 PMshaarawy
10/31/2021, 4:26 PMtheapache64
10/31/2021, 7:46 PMZoltan Demant
11/01/2021, 7:19 AMACTION_SENDTO
in Android 12? The code is identical to the official documentation and has worked flawlessly before Android 12.Orhan Tozan
11/02/2021, 10:32 AM// Listen to multiple flows
lifecycleScope.launch {
lifecycle.repeatOnLifecycle(Lifecycle.State.STARTED) {
// As collect is a suspend function, if you want to collect
// multiple flows in parallel, you need to do so in
// different coroutines
launch {
flow1.collect { /* Do something */ }
}
launch {
flow2.collect { /* Do something */ }
}
}
}
Is there anything wrong with doing this instead? :
// Listen to multiple flows
lifecycleScope.launch {
lifecycle.repeatOnLifecycle(Lifecycle.State.STARTED) {
// As collect is a suspend function, if you want to collect
// multiple flows in parallel, you need to do so in
// different coroutines
launch {
flow1.collect { /* Do something */ }
}
}
}
lifecycleScope.launch {
lifecycle.repeatOnLifecycle(Lifecycle.State.STARTED) {
launch {
flow2.collect { /* Do something */ }
}
}
}
Sam Smallman
11/02/2021, 3:49 PMSergio C.
11/02/2021, 5:59 PMPhilip Dukhov
11/03/2021, 12:59 PMval onAction: () -> Unit = { ... }
) as blocks. Is this naming clear to android developers? The word lambda in my head does not sound very nice in this context.Orhan Tozan
11/03/2021, 1:45 PM_shtomar
11/03/2021, 10:02 PMIlya Gazman
11/04/2021, 10:57 AMSergio C.
11/04/2021, 2:04 PMFedora
11/04/2021, 2:45 PMMutableStateFlow
in 2 fragments of a viewpager?Maya Gorel
11/05/2021, 8:16 AMRuben Quadros
11/05/2021, 1:58 PMI keep getting java.lang.IllegalArgumentException: Key was already used. If you are using LazyColumn/Row please make sure you provide a unique key for each item.
I am sure all the keys are unique and I even logged them to be sure. Also this happens when items are rapidly added to lazy column.
Here is my sample code:
@Composable
fun UiComponent() {
LazyColumn(
verticalArrangement = Arrangement.spacedBy(12.dp),
state = scrollState,
reverseLayout = true
) {
items(
items = viewmodel.messages,
key = { item -> item.hashcode() },
itemContent = { item: Entity ->
if (item.isDeleted) {
//show deleted ui
} else {
//show messages
}
})
}
}
}
VM {
init {
observeDataFromDB()
}
private val _messages: MutableList<Entity> = mutableStateListOf()
val messages: List<Entity> = _messages
fun observeDataFromDB() {
viewModelScope.launch {
repo.getData().collect {
_messages.apply {
addNewItem(it)
}
}
}
}
}
//extensions
fun MutableList<Entity>.addNewItem(entity: Entity) {
if (this.size >= MAX_SIZE) {
removeLast()
}
Log("existing ${this.toList().map { "${it.hashCode()}" }}")
Log("adding new ${entity.hashCode()}")
this.add(0, entity)
}
//id is primary key
data class Entity(val id: String, val isDeleted: Boolean, val message: String)
Any help would be great! Have been stuck with this for sometime now and not sure how to proceed 😭
Have tried using id
as the key and I still get the same error.Vaios Tsitsonis
11/05/2021, 10:52 PMGus
11/06/2021, 12:53 PMandrew
11/06/2021, 9:40 PMAyden
11/07/2021, 8:09 AMgoogle-service.json
being exposed when someone is doing reverse-engineer?Iqbal Ahmed
11/07/2021, 1:48 PMTarunY
11/08/2021, 8:57 AMziv kesten
11/08/2021, 1:35 PMDoru N.
11/08/2021, 4:29 PMSkc
11/08/2021, 11:16 PMext {
compose_version = '1.0.1'
kotlin_version = '1.5.21'
agp_version = '4.2.2'
}
dependencies {
classpath "com.android.tools.build:gradle:$agp_version"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
compose dependencies
implementation "androidx.compose.ui:ui:$compose_version"
implementation "androidx.compose.material:material:$compose_version"
implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
implementation "androidx.compose.compiler:compiler:$compose_version"
implementation 'androidx.activity:activity-compose:1.3.1'
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
It fails while compiling saying
`this version (1.0.1) of the Compose Compiler requires Kotlin version 1.5.21 but you appear to be using Kotlin version 1.4.31 which is not known to be compatible. Please fix your configuration (or suppressKotlinVersionCompatibilityCheck
but don't say I didn't warn you!).`
Any hints where Kotlin 1.4.31
might be coming from?My Nguyen
11/09/2021, 8:28 AM