Nikola Milovic
02/24/2020, 1:41 PMMichael Friend
02/24/2020, 3:01 PMLiveData<String>
and LiveData<String?>
? Since all the methods in LiveData are nullable the the types in observe()
are both nullable and it doesn’t prevent you from setting either value as null. Is it just as a reminder not to set it null?iex
02/24/2020, 4:58 PMPublishSubject
for live data? I.E. which emits events without storing them?Andy Gibel
02/24/2020, 8:07 PMAndrew Ambia
02/25/2020, 5:54 AMNikola Milovic
02/25/2020, 11:16 AMOfir Bar
02/25/2020, 12:38 PMwhen
expression using something similar to it
?
In the code below “`it`” gets an error (Unresolved reference: it
)
when(mCurrentUserType){
UserType.HUMAN -> {
setViewForUserType(currentUser, it)
}
UserType.ANIMAL -> {
setViewForUserType(currentUser, it)
}
}
bhatnagarm
02/25/2020, 2:13 PMstantronic
02/25/2020, 3:02 PMKy
02/25/2020, 7:43 PMdata class
and lint seems to be considering the parameters of the data class
as a method.
data class ListViewModel(
private val handle: SavedStateHandle,
private val repository: ListRepository,
private val scheduler: IObservableSchedulerRx2,
private val errorHandler: Mvvm.ErrorHandler
)
So for each method, I am logging the method name and return type, and this is the output when it hits these params
METHOD NAME: component1
FUN RETURN TYPE: PsiType:SavedStateHandle
component2, component3, etc.. for each subsequent parameter.
Any suggestions?tjohnn
02/25/2020, 10:05 PMeason
02/27/2020, 2:56 AMJason
02/27/2020, 4:14 AMbhatnagarm
02/27/2020, 11:34 AMMuhammad Usman
02/28/2020, 5:42 AMprivate val registerViewModel by viewModels<RegisterViewModel> (userDao)
how can i pass object instance to viewModel using by viewModels extentions , like i want to pass userDao to RegisterVIewModelOfir Bar
02/28/2020, 1:47 PMLiveData
.
I wonder, why can’t I call postValue
or setValue
If I subclass a LiveData?
private val someInstanceOfLiveData = object : LiveData<String>(){}
fun test(){
someInstanceOfLiveData.setValue() // Cannot access 'setValue': it is protected/*protected and package*/ in '<no name provided>'
someInstanceOfLiveData.postValue() // Cannot access 'postValue': it is protected/*protected and package*/ in '<no name provided>'
}
from my understanding, object : LiveData<String>(){}
is a subclass of the abstract LiveData
class.
If it is a subclass, why can’t I call postValue()/setValue()
, which are declared as protected
inside the LiveData
?iex
02/28/2020, 4:57 PMactivity
being optional in onCreateDialog
?
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog =
DatePickerDialog(activity!!, this, initDate.year, initDate.month, initDate.day)
Steve
02/28/2020, 6:33 PMubu
02/29/2020, 4:32 PMKtor
client, Retrofit
or DownloadManager
API? Or maybe something else.Saiteja
03/01/2020, 10:15 AMdave08
03/01/2020, 5:53 PM@get:Rule
val instantTaskExecutorRule = InstantTaskExecutorRule()
and
shadowOf(Looper.getMainLooper()).idle()
when I try
someLiveData.asFlow().first()
it just stays stuck with runBlocking and crashes with runBlockingTest...spencer
03/02/2020, 4:20 PMAntoine Gagnon
03/02/2020, 7:44 PMiex
03/02/2020, 8:26 PMOmar Ahmed
03/03/2020, 9:50 AMBruno_
03/03/2020, 6:55 PMA
?
There's no back button on the nav bar when I do so so I assume it's the latter but I just want to make sure that it won't cause any problems in the futureOfir Bar
03/04/2020, 12:50 PMAdvertisement
which contains a few enums.
@Parcelize
data class Advertisement(
@SerializedName("type") val type : AdvertisementType,
@SerializedName("userTypeTarget") val userTypeTarget : UserTypeTarget,
@SerializedName("goal") val advertisementGoal : AdvertisementGoal,
@SerializedName("attachTo") val attachTo : AttachTo,
) : Parcelable
enum class AdvertisementType(private val value : Int) {
REGULAR(0),
SOS(1)
}
enum class AttachTo(private val value : Int){
ME(0),
MY_OFFICE(1)
}
enum class UserTypeTarget(private val value : Int){
LAWYER(0),
SERVICE_PROVIDER(1)
}
enum class AdvertisementGoal(private val value : Int){
COLLABORATION(0),
CASE_TRANSFER(1),
COURT_TRANSFER(2),
FORM_VALIDATION(3)
}
As you can see, my object properties are enums.
However, our backend only accepts Integers.
I need to make all the properties into Integers, but I don’t want any future developer to ever create an instance of`Advertisement` directly with some Int, and use the created enums instead.
How can I force the insertion of enums yet the actual value of created `Advertisement`to be an Int?Almas Shagdarov
03/04/2020, 5:32 PMLarten
03/05/2020, 10:44 AMAdnan Ali
03/05/2020, 11:28 AMdata class Products(id){
packList=ArrayList<Packs>
}
data class Pack(title: string, is_original: Boolean)
val list= productList.map { it.id to it.packlist.map{ if (it.is_original==true} it.title}
Note: ArrayList<Products>
But Products= Arraylist<Pack>
i.e I want a hashmap just like this ["1" , "[item1, item2, item3, item4]" ]