Olenyov Kirill
03/05/2020, 9:46 PMSlackbot
03/05/2020, 11:37 PMgabin
03/06/2020, 10:16 AMKirill Prybylsky
03/06/2020, 12:44 PMOrhan Tozan
03/06/2020, 10:41 PMSlackbot
03/07/2020, 12:14 AMJoshua
03/07/2020, 9:20 PMAbed Murad
03/08/2020, 11:50 AMout
mean in this context ? , thanks.
/**
* A generic class that holds a value with its loading status.
* @param <T>
*/
sealed class Result<out R> {
data class Success<out T>(val data: T) : Result<T>()
data class Error(val exception: Exception) : Result<Nothing>()
object Loading : Result<Nothing>()
override fun toString(): String {
return when (this) {
is Success<*> -> "Success[data=$data]"
is Error -> "Error[exception=$exception]"
Loading -> "Loading"
}
}
}
/**
* `true` if [Result] is of type [Success] & holds non-null [Success.data].
*/
val Result<*>.succeeded get() = this is Success && data != null
bhatnagarm
03/08/2020, 1:20 PMKulwinder Singh
03/09/2020, 7:58 AMFirebaseAuth.getInstance().signInWithCustomToken(token).addOnCompleteListener{}
and other Task like addOnSuccessListener
and addOnFailureListener
using MockK ?jossiwolf
03/09/2020, 11:10 AMjava.lang.NoClassDefFoundError: Failed resolution of: LpackaageName/DealershipId$Creator;
@Parcelize
inline class DealershipId(val value: String): Parcelable
Did anybody encounter this? Kotlin 1.3.70, but wasn't working on 1.3.61 eitherlouiscad
03/09/2020, 11:47 AMNotificationCompat
Kotlin extensions? I personally made some, and I'm looking for folks to discuss API design regarding extensions for these APIs. I'm looking forward exchanging inspiration to get to a DSL that is the lest error-prone and forget-prone possible, and very readable (can't stand these NotificationCompat.PRIORITY_
and similar prefixes).
Right, this is what I have, and I know I can make improvements, but I'd like to bounce off improvement ideas.
val notification = buildNotification(ChannelIds.Something) {
priority = NotificationCompat.PRIORITY_MAX
category = NotificationCompat.CATEGORY_STATUS
visibility = Public
contentText = "Some content text"
smallIcon = R.drawable.ic_some_icon_white_24dp
}
Mickael
03/09/2020, 2:48 PM//Compare 2 json files
val parser = JsonParser()
val o1 = parser.parse("{\"state\":1,\"cmd\":1}")
val o2 = parser.parse("{\"state\":1,\"cmd\":1}")
println(o1 == o2)
This seems to be enough ;-)Ellen Spertus
03/09/2020, 6:48 PMclass MainActivity {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
Metadata.initialize()
}
}
class Metadata {
companion object {
boolean initialized = false
fun initialize(context: Context) {
check(!initialized)
// do stuff (omitted)
initialized = true
}
}
}
Sometimes my app fails because the check
at the beginning of Metadata.initalize()
fails, which implies that the companion object is surviving the destruction of MainActivity
, despite their presumably being in the same process. Could someone help me understand why the companion object stays around even if the activity needs to be re-created?Arseniy
03/10/2020, 12:09 AMNikola Milovic
03/10/2020, 8:27 AMcom.nikolam.nsdkelper public final class com.nikolam.nsdkelper.R
and this is what's happening, the last thing i added was my library module to my app.gradle
dependancies{
implementation project(":nsdkelper")
}
I tried the solutions found online, the cache, the rebuild and so on, but haven't had any luck.Kulwinder Singh
03/10/2020, 12:11 PMMockKException: no answer found for: MyClass(#1).sendMessage(okhttp3.RequestBody$2@4ed4bd33)
,
actually RequestBody's properties are same just instance is different. that's why it did not matches parameters but if i add any()
instead of requestbody it works. is there anything else i can use instead of any()
here ?
every { myClass.sendMessage(MockRequest.createTestBody(value="text")) } answers { something }
....
class SomeObject(myClass:MyClass){
fun doSomething(text: String): Flowable<Result<Boolean>> {
val request = MockRequest.createTestBody(text)
myClass.sendMessage(request)
}
}
....
i have checked documentation of mockk but didn't found anything, that's why asked here:Arslan Mushtaq
03/10/2020, 12:51 PMElyes
03/10/2020, 3:17 PMonDestory
function of a fragment wouldn’t be called when closing the app ?basher
03/10/2020, 4:24 PMMikołaj Kąkol
03/10/2020, 4:58 PMonStop
. I'm thinking of equivalent of: https://github.com/trello/RxLifecycle
So I would like start Flow
in onStart
and have it canceled by onStop
. From what I see LifecycleCoroutineScope
has only option to cancel it on destroyEllen Spertus
03/10/2020, 5:27 PMViewModel
for my state. Could anyone advise me how to adapt the https://developer.android.com/topic/libraries/architecture/viewmodel example to support the case where an argument needs to be passed into getUsers()
and through to loadUsers()
for it to do its job?
class MyViewModel : ViewModel() {
private val users: MutableLiveData<List<User>> by lazy {
MutableLiveData().also {
loadUsers()
}
}
fun getUsers(): LiveData<List<User>> {
return users
}
private fun loadUsers() {
// Do an asynchronous operation to fetch users.
}
}
I could store the information in an instance variable from getUsers()
and retrieve it from loadUsers()
, but that doesn’t seem very nice.
What I need to pass in is a Context
(to access assets and the package manager). I don’t cache the Context.182630g
03/11/2020, 1:42 AMtjohnn
03/11/2020, 12:00 PM1.3.70-eap-42-Studio3.6-1
Cause: org.gradle.tooling.model.kotlin.dsl.KotlinDslScriptsModel can only be requested on the root project, got 'project ':app''
PS: I am not using kotlin dsl for gradle, I am using groovyGavin Ray
03/11/2020, 5:07 PMdekans
03/11/2020, 5:29 PMSergio C.
03/11/2020, 10:07 PMGuy Bieber
03/11/2020, 11:21 PMAlmas Shagdarov
03/12/2020, 4:39 AMOfir Bar
03/12/2020, 8:53 AMfun getCityById(selectedCityId: Int): City {
var city : City? = null
viewModelScope.launch {
city = locationRepository.getSingleCityFromDatabaseById(selectedCityId)
}
return city //Compilation error message: type mismatch, Required:City, found: City?
}
fun getListOfLanguagesByIds(selectedLanguages: List<Int>): List<Language> {
viewModelScope.launch {
return supportedLanguagesRepository.getLanguagesFromDatabaseById(selectedLanguages.toIntArray())
}// Compilation error above message: 'return' is not allowed here
}
fun getExpertiseFieldById(expertiseFieldId: Int): ExpertiseField {
lateinit var expertiseField : ExpertiseField
viewModelScope.launch {
expertiseField = expertiseFieldsRepository.getSingleExpertiseFieldFromDatabaseById(expertiseFieldId)
}
return expertiseField
//Seems to work, but I am afraid expertiseField will be returned uninitialized.
}
Ofir Bar
03/12/2020, 8:53 AMfun getCityById(selectedCityId: Int): City {
var city : City? = null
viewModelScope.launch {
city = locationRepository.getSingleCityFromDatabaseById(selectedCityId)
}
return city //Compilation error message: type mismatch, Required:City, found: City?
}
fun getListOfLanguagesByIds(selectedLanguages: List<Int>): List<Language> {
viewModelScope.launch {
return supportedLanguagesRepository.getLanguagesFromDatabaseById(selectedLanguages.toIntArray())
}// Compilation error above message: 'return' is not allowed here
}
fun getExpertiseFieldById(expertiseFieldId: Int): ExpertiseField {
lateinit var expertiseField : ExpertiseField
viewModelScope.launch {
expertiseField = expertiseFieldsRepository.getSingleExpertiseFieldFromDatabaseById(expertiseFieldId)
}
return expertiseField
//Seems to work, but I am afraid expertiseField will be returned uninitialized.
}
Raul Tunduc
03/13/2020, 7:11 AM