Slackbot
01/20/2021, 7:25 AMpaulex
01/20/2021, 12:18 PMVladimir Vasic
01/20/2021, 12:53 PM@Polymorphic
@Serializable
abstract class Base {
@SerialName("property_1")
abstract val property1: String
@SerialName("property_2")
abstract val property2: String
}
private const val DISCRIMINATORA = "5"
@Serializable
@SerialName(DISCRIMINATORA)
data class A(
@SerialName("property_1")
override val property1: String,
@SerialName("property_2")
override val property2: String,
@SerialName("propertyA")
val propertyA: String,
) : Base()
private const val DISCRIMINATORB = "4"
@Serializable
@SerialName(DISCRIMINATORB)
data class B(
@SerialName("property_1")
override val property1: String,
@SerialName("property_2")
override val property2: String,
@SerialName("propertyB")
val propertyB: String,
) : Base()
My koin definition is
single {
APIClient(baseUrl, get())
}
val polymorphicBaseRequestModule = SerializersModule {
polymorphic(Any::class) {
subclass(A::class)
subclass(B::class)
}
polymorphic(Base::class) {
subclass(A::class)
subclass(B::class)
}
}
single {
HttpClient(OkHttp) {
install(JsonFeature) {
serializer = KotlinxSerializer(kotlinx.serialization.json.Json {
isLenient = true
ignoreUnknownKeys = true
classDiscriminator = "hello"
serializersModule = polymorphicBaseRequestModule
})
}
}
My Request class is
abstract class APIRequest<ReturnType : Any>(
open val httpMethod: APIHTTPMethod = APIHTTPMethod.Get,
open val contentType: String? = null,
open val resourcePath: String = "/",
open val urlParameters: HashMap<String, Any?>? = null,
@Polymorphic
open val httpBody: Any? = null
)
My API client is
suspend inline fun <reified ReturnType : Any> send(apiRequest: APIRequest<ReturnType>): Result<ReturnType> {
val builder = HttpRequestBuilder()
builder.url.protocol = URLProtocol.HTTP
builder.url.host = baseUrl
builder.url.encodedPath = apiRequest.resourcePath
builder.method = HttpMethod.parse(apiRequest.httpMethod.value)
// Add headers
apiRequest.contentType?.let {
builder.headers.append("Content-Type", it)
}
// Add request body
apiRequest.httpBody?.let { httpBody ->
builder.body = httpBody
}
Sentry.addBreadcrumb("Resource path: " + apiRequest.resourcePath)
return withContext(<http://Dispatchers.IO|Dispatchers.IO>) {
try {
Result.success(client.request<ReturnType>(builder))
}catch(e) {
Log.d("error", e.response.content)
}
}
What am I doing wrong?Andrew Ebling
01/20/2021, 4:33 PMvar array = SparseArray<ByteArray>(1)
...array ends up being empty (it shows as “null”
in the debugger, and if I do this:
array.setValueAt(0, byteArrayOf(byte)
val value = array.get(0)
...then value
is null.
Sulav Timsina
01/22/2021, 3:44 AMJason Ankers
01/22/2021, 6:32 AMShawn Tucker
01/22/2021, 8:30 AMImany
01/22/2021, 8:41 AMsettings.gradle.kts
like this:
pluginManagement {
repositories {
gradlePluginPortal()
google()
}
plugins {
id(GradlePluginId.GRADLE_PLUGIN) version GradlePluginsVersion.GRADLE_PLUGIN
}
}
that GradlePluginId
and GradlePluginVersion
are Kotlin objects, but the problem is they don't resolve with just this message:
_*Unresolved reference: GradlePluginId
Unresolved reference: GradlePluginVersion*_
however I can go to declaration and back to usage through the IDE.
my project settings:
implementation("com.android.tools.build:gradle:4.1.1")
distributionUrl=<https://services.gradle.org/distributions/gradle-6.5-bin.zip|https://services.gradle.org/distributions/gradle-6.5-bin.zip>
thank you.Junior leoncio
01/22/2021, 4:48 PMRemy Benza
01/23/2021, 3:50 PMtheimpulson
01/23/2021, 4:38 PMbinding.button2.setOnClickListener {
activity?.supportFragmentManager?.popBackStack()
}
On going back to A, if I use A to B button again, app will crash with this message:
java.lang.IllegalArgumentException: navigation destination dev.theimpulson.myapplication:id/action_firstFragment_to_secondFragment is unknown to this NavController
However, if I use this in B to A button:
binding.button2.setOnClickListener {
activity?.onBackPressed()
}
App doesn't crashes anymore. Any ideas why?dimsuz
01/25/2021, 12:08 PMclass StringSrcParceler : Parceler<StringSrc?>
Which I use like this:
@Parcelize
@TypeParceler<StringSrc?, StringSrcParceler>
data class PermissionRequestFlowParams(
val allowPostpone: Boolean,
val forbidDismissWithMessage: StringSrc?,
) : Parcelable
At runtime this gives me an exception:
java.lang.NoSuchFieldError: No static field INSTANCE of type Lru/kode/base/ui/core/resources
/StringSrcParceler; in class Lru/kode/base/ui/core/resources/StringSrcParceler
Full: https://pastebin.com/NYBEcgE1
What am I doing wrong?Eirik Vale Aase
01/25/2021, 5:48 PMsbeve
01/26/2021, 9:23 AMJrichards1408
01/26/2021, 8:57 PMFunkyMuse
01/26/2021, 11:20 PMTony Kazanjian
01/27/2021, 8:34 PMorg.koin:koin-androidx-viewmodel:$koin_version
versus just the basic org.koin:koin-android-viewmodel:$koin_version
. I have been using the latter with ViewModels from the AndroidX lifecycle package and everything is working just fine. What would I need the AndroidX Koin dependency for?Big Chungus
01/28/2021, 11:05 AMdeviant
01/28/2021, 1:20 PMval getContent = registerForActivityResult(GetContent()) { uri: Uri? ->
// Handle the returned Uri
}
getContent.launch("image/*")
we could use something like
val getContent = registerForActivityResult(GetContent(), suspendableContract)
val result = getContent.launchSuspendable("image/*")
darkmoon_uk
01/29/2021, 6:51 AMcom.android.tools.build:gradle:7.0.0-alpha05
- switching to this version from alpha04
on my project produces the error lateinit property variantName has not been initialized
. I'm running a 'standard' Kotlin Multiplatform / Mobile gradle setup.Jawid
01/29/2021, 7:57 AM0.9.1
) it is not being imported in the shared module. Instead, if I change the version to 0.6.0
I can import it but I get this error Cannot access 'dev.icerock.moko.mvvm.viewmodel.ViewModel' which is a supertype of 'com.example.vmdemo.shared.GreetingViewModel'. Check your module classpath for missing or conflicting dependencies
. I really appreciated it if someone could help me to solve this issue, thanks in advance.Hannan Shaikh
01/29/2021, 9:44 AMdarkmoon_uk
01/29/2021, 1:43 PM7.0.0-alpha05
, here:
https://issuetracker.google.com/issues/178715706
Please consider voting for this issue to encourage a hotfix; thanks to @Sean Keane and @magnumrocha for the investigation.ursus
01/31/2021, 7:22 AMDhanya S Pillai
02/01/2021, 9:34 AMmurdock
02/01/2021, 9:46 AMEllen Spertus
02/01/2021, 10:07 PMrollButton.text = "Let's roll!"
rollButton.setOnClickListener {
Toast.makeText(this, "button clicked", Toast.LENGTH_SHORT).show()
}
I know the first line would be: rollButton.setText("Let's roll!");
in Java. Why doesn't the next statement become the following in Kotlin:
rollButton.onClickListener = ...;
Aness Iqbal
02/02/2021, 7:25 AMD Tam
02/02/2021, 9:17 AMSlackbot
02/02/2021, 1:35 PM