https://kotlinlang.org
Join Slack
I’m having an issue with Compose `@Preview` rendering. This shows up as “Render problem” in the prev...
c

Chris Fillmore

over 3 years ago
I’m having an issue with Compose
@Preview
rendering. This shows up as “Render problem” in the preview pane:
java.lang.NullPointerException: Parameter specified as non-null is null
The parameter referenced in the message is just a
text: String
which gets passed to a text composable
Text(text = text)
c
m
+2
  • 4
  • 11
  • 1180
I want to extract the array data from the json response and store the data in my custom data class. ...
t

T

over 5 years ago
I want to extract the array data from the json response and store the data in my custom data class.
data class NewsData (

    val author: String, val title: String,
    val url: String, val publishedAt: String
)
class NewsViewModel : ViewModel() {

    // The internal MutableLiveData String that stores the most recent response
    private val _response = MutableLiveData<String>()

    // The external immutable LiveData for the response String
    val response: LiveData<String>
        get() = _response

    /**
     * Call getNewsData() on init so we can display status immediately.
     */
    init {
        getNewsData()
    }

    /**
     * Sets the value of the status LiveData to the News API status.
     */
    private fun getNewsData() {

        _response.value = NewsApi.retrofitService.getProperties().enqueue(
            object : Callback<ResponseBody> {
                override fun onFailure(call: Call<ResponseBody>, t: Throwable) {
                    _response.value = "Failure: " + t.message
                    //Log.i("response", t.message)
                }

                override fun onResponse(call: Call<ResponseBody>, response: Response<ResponseBody>) {
                    val root = JSONObject(response.body().toString())
                    val jsonArr = root.getJSONArray("articles")
                    val ob = jsonArr.getJSONObject(0)
                    val name = ob.getString("author")
                    _response.value = name
                }
            }).toString()
    }
}
This is the format of the json response.
t
o
  • 2
  • 19
  • 1179
After upgrading our project to K2 (Gradle 8.8) we've noticed that some `.salive` files are being cre...
d

Daniel Souza Bertoldi

about 1 year ago
After upgrading our project to K2 (Gradle 8.8) we've noticed that some
.salive
files are being created under
.kotlin/sessions
for some developers. Even after removal, after a few builds they keep coming back. Curiously, all files created are empty. I couldn't find more info on these files, are they important or just act like a log of some sorts? Is there a way to stop Kotlin from creating them?
d
d
+2
  • 4
  • 4
  • 1178
If I convert a `Color` value to `Int` (using `toArgb()`) so I can save it in Datastore, how would I ...
n

Nat Strangerweather

over 3 years ago
If I convert a
Color
value to
Int
(using
toArgb()
) so I can save it in Datastore, how would I then convert the
Int
back to Jetpack Compose
Color
?
n
s
+2
  • 4
  • 7
  • 1177
Does anyone know if there’s a way to disable the swipe away gesture on a ModalBottomSheetLayout? I ...
m

mattinger

about 3 years ago
Does anyone know if there’s a way to disable the swipe away gesture on a ModalBottomSheetLayout? I can veto the change so that the sheet stays up, but id rather the user not be able to drag the content away in that case. why let them drag to dismiss if we’re just going to veto it anyway? A related question is that if i decide to allow a click outside or for them to swipe it away, is there a way to react that that?
m
c
j
  • 3
  • 10
  • 1174
Hello, I get this error. What is the reason? " error: @Binds methods' parameter type must be assign...
h

Hovhannes

about 4 years ago
Hello, I get this error. What is the reason? " error: @Binds methods' parameter type must be assignable to the return type public abstract com.example.data.network.AuthApi " in AppModule
@Module
@InstallIn(SingletonComponent::class)
abstract class AppModule {


    companion object {
        @Singleton
        @Provides
        fun provideRemoteDataSource(): RemoteDataSource {
            return RemoteDataSource()
        }



        @Singleton
        @Provides
        fun provideUserApi(
            remoteDataSource: RemoteDataSource,
      
        ): UserApi {
            return remoteDataSource.buildTokenApi()
        }

        @Provides
        fun provideAuthRepository(authApi: AuthApi): AuthRepository {
            return AuthRepository(authApi)
        }


        @Provides
        fun provideUserRepository(userApi: UserApi): UserRepository {
            return UserRepository(userApi)
        }
    }



        @Binds
        @Singleton
        abstract fun bindsRemoteDataSource(authRepository: AuthRepository): AuthApi
}
class AuthRepository @Inject constructor(private val api: AuthApi) : BaseRepository(api) {....}
h
a
  • 2
  • 8
  • 1174
Hi Team , Is it possible to use ConstraintLayout in Compose Multiplatofrm , i want to use for ios <@...
s

Shivam Kanodia

over 2 years ago
Hi Team , Is it possible to use ConstraintLayout in Compose Multiplatofrm , i want to use for ios @etolstoy?
s
n
+2
  • 4
  • 5
  • 1171
What is `iosX64()` for? Are there some x64 ios devices? I though it was all arm always?
u

ursus

over 2 years ago
What is
iosX64()
for? Are there some x64 ios devices? I though it was all arm always?
u
a
+3
  • 5
  • 17
  • 1171
I'm trying to use kapt in my project and it is working well when I compile manually using maven. How...
d

David Kubecka

over 2 years ago
I'm trying to use kapt in my project and it is working well when I compile manually using maven. However, the Intellij IDEA integrated builder has trouble when compiling the generated sources. I've filed a bug to IDEA directly as I think the issue might be there (there's a simple reproducer project if anyone would be glad to look at it). To understand the issue more, I would like to know the reasoning behind and perhaps more details of this Maven/Kotlin guide that I followed. I noticed that when I don't "disable" the
maven-compiler-plugin
I get the same error during manual maven compilation ("package does not exist") as I get in IDEA when the pom is set up correctly. Can anyone shed more light into this issue?
d
a
  • 2
  • 17
  • 1171
Can we use lottie animations in compose KMM.
f

Farhazul Mullick

almost 2 years ago
Can we use lottie animations in compose KMM.
f
h
a
  • 3
  • 4
  • 1169
Previous303132Next

kotlinlang

A modern programming language that makes developers happier.

Powered by