Chris Fillmore
@Preview
java.lang.NullPointerException: Parameter specified as non-null is null
text: String
Text(text = text)
T
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() } }
Daniel Souza Bertoldi
.salive
.kotlin/sessions
Nat Strangerweather
Color
Int
toArgb()
mattinger
Hovhannes
@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) {....}
Shivam Kanodia
ursus
iosX64()
David Kubecka
maven-compiler-plugin
Farhazul Mullick
A modern programming language that makes developers happier.