Lilly
07/23/2021, 12:21 PMHovhannes
07/23/2021, 1:59 PMDanish Ansari
07/24/2021, 9:21 PMSudhir Singh Khanger
07/25/2021, 2:53 AMView
is in GONE
state and LiveData
is supposed to set value on it? Does LiveData
do anything or skip setting value or does it set it but since the view is gone we won't be able to see changes?ritesh
07/25/2021, 6:31 AMkotin stdlib
dependency is added in the Gradle files. I also observed kotlin
and kotlin-android
plugin also adds it by default.
I am assuming adding it manually can be avoided? Or is there a downside to it?
org.jetbrains.kotlin:kotlin-stdlib:${versions.kotlin}
ritesh
07/25/2021, 6:37 AMandroid {
...
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
}
compileOptions
can be safely dropped from 100% kotlin application.
Using kotlinOptions.jvmTarget="11"
is there a downside to it, in terms of byte-code generation and byte-code compatibility with other jdk versions.Danish Ansari
07/25/2021, 11:47 AMandylamax
07/26/2021, 2:48 AMlintOptions {
isAbortOnError = false
}
In AGP 7.0.0-alpha01 using kotlin-dsl?
The above snipet works with AGP 4.1.3, it fails when upgraded to 7.0.0Loredana Petrea
07/26/2021, 6:55 AMjava.lang.NoSuchMethodError: No static method getSeconds(I)D in class Lkotlin/time/DurationKt; or its super classes (declaration of 'kotlin.time.DurationKt'
I removed the kotlin-stdlib
explicit declaration but the error is still here. I appreciate any helpjuliocbcotta
07/26/2021, 9:00 AMjava
plugin , do we have something similar to
java {
toolchain {
languageVersion = JavaLanguageVersion.of(11)
vendor = JvmVendorSpec.ADOPTOPENJDK
}
}
In the AGP or kotlin plugin ?Scott Kruse
07/26/2021, 5:15 PMalex.tavella
07/27/2021, 4:41 PM[Jetpack Proto DataStore]
Is there any option to generate kotlin instead of Java-lite on the gradle plugin? The java option does not use nullable annotation so I find it a bit error-prone to consume from kotlin for new devs.
protobuf {
protoc {
artifact = 'com.google.protobuf:protoc:3.8.0'
}
generateProtoTasks {
all().each { task ->
task.builtins {
java {
option "lite"
}
}
}
}
}
Rooparsh
07/28/2021, 3:52 AMstartActivityForResult
and overrides onActivityResult
.
I am using Google Pay Wallet SDK and it has a function which simply accepts request code and internally calls startActivityForResult
. Can I do something at my end to make the code more modular using ActivityContracts?
Attaching sample code in thread.gabriel dean
07/28/2021, 8:33 AMBlaceShell
07/29/2021, 6:52 AMPeter Mandeljc
07/29/2021, 7:14 PMDoni Winata
07/30/2021, 2:34 AMkotlinOptions {
freeCompilerArgs += [
'-Xsam-conversions=class',
]
}
Any one have clue how i can achieve it ? Thank you in advanceVivek Modi
07/30/2021, 9:56 AMprivate fun cmToFeet(value: String): String {
var text = ""
val cm = value.toDouble()
val feet = floor((cm / 2.54) / 12)
val inches = round((cm / 2.54) - (feet * 12))
if (feet > 0 && feet < 10) {
text = "${feet.toInt()}'"
if (inches > 0) {
text += "${inches.toInt()}\""
}
}
return text
}
BlaceShell
07/30/2021, 10:35 AMNoushad Chullian
07/31/2021, 2:16 PMLaw Gimenez
07/31/2021, 3:16 PMChristopher Elías
07/31/2021, 4:47 PMP
07/31/2021, 11:22 PMArpan Sarkar
08/01/2021, 6:06 PMLiveData
to how can i convert the MediatorLiveData
part to StateFlow
import androidx.lifecycle.LiveData
import androidx.lifecycle.MediatorLiveData
import androidx.lifecycle.MutableLiveData
abstract class InputFrom {
private val _isFromValid = MediatorLiveData<Boolean>()
val isFromValid: LiveData<Boolean>
get() = _isFromValid
abstract val fields: List<LiveInputField<*>>
fun init() {
fields.forEach { inputField ->
_isFromValid.addSource(inputField.value) { changedValue ->
inputField.validate(changedValue)
_isFromValid.value = fields.all {
it.isValid
}
}
}
}
inner class LiveInputField<T>(
private val errorMessage: String? = null,
private val predicate: (T?) -> Boolean
) {
val value = MutableLiveData<T>()
private val _error = MutableLiveData<String>()
val errorText: LiveData<String>
get() = _error
var isValid: Boolean = false
fun validate(value: Any?) {
@Suppress("UNCHECKED_CAST")
return if (predicate(value as? T)) {
_error.value = null
isValid = true
} else {
_error.value = errorMessage
isValid = false
}
}
}
}
Example Usages:
class LoginFrom : InputFrom() {
val username =
LiveInputField<String>("At least 4 characters, only letters, numbers, ., _ allowed.") {
!it.isNullOrBlank() &&
Pattern.compile("[a-zA-Z0-9_.]{4,}")
.matcher(it)
.matches()
}
val password =
LiveInputField<String>(
"8 characters or more, at least one number, one uppercase, one lowercase."
) {
!it.isNullOrBlank()/* &&
Pattern.compile("((?=.*\\d)(?=.*[a-z])(?=.*[A-Z]).{8,})")
.matcher(it)
.matches()*/
}
override val fields: List<LiveInputField<*>>
get() = listOf(
username,
password
)
}
Hovhannes
08/02/2021, 1:08 PMViral Thakker
08/02/2021, 2:33 PMritesh
08/02/2021, 6:06 PMpollux-
08/02/2021, 10:41 PMViewCompat.setOnApplyWindowInsetsListener(this) { _, windowInsets ->
val statusBarInsets = windowInsets.getInsets(WindowInsetsCompat.Type.statusBars())
val statusBarHeight: Int = <http://statusBarInsets.top|statusBarInsets.top>
}
Does anyone knows, why I’m I getting statusBar height as zero, this will be called multiple times, sometimes I see the actual height of the status bar but sometimes it does reset to zero.
Appreciate your helpAlan Yin
08/03/2021, 5:54 AMYaniv Sosnovsky
08/03/2021, 11:17 AMpublishing {
repositories {
maven {
name = "GithubPackages"
url = uri("<https://maven.pkg.github.com/>...")
credentials {
username = "..."
password = "..."
}
}
}
}