Slackbot
02/17/2020, 2:33 AMOfir Bar
02/17/2020, 9:46 AMElvis operator always returns the left operand of non-nullable String
for the 2nd attempt (marked yellow):
condition currentUser?.office?.name.toString() is always 'true'
Why is that not possible to be null?Ofir Bar
02/17/2020, 11:59 AMgetString()
is null.
Can I use this with elvis?
I couldn’t find a way (unless using if/else,etc, just exploring something more clean)Maurice Jouvet
02/17/2020, 3:30 PMDoru N.
02/17/2020, 5:05 PMGeert
02/18/2020, 8:22 AMCause: only whitespace content allowed before start tag and not \u0 (position: START_DOCUMENT seen \u0... @1:1)
while using `apply plugin: "androidx.navigation.safeargs"`` iSaket Poddar
02/18/2020, 1:42 PMVishvendu
02/18/2020, 2:22 PMVishvendu
02/18/2020, 2:26 PMOfir Bar
02/18/2020, 7:07 PMT
to 2 different objects?
For example, here we limit to type Cat
or Dog
something like(this is pseudocode):
private fun<T : Cat or Dog> convertToIntArray(objects: List<T>) : IntArray {
val objectIds = arrayListOf<Int>()
objects.forEach {
objectIds.add(it.id)
}
return objectIds.toIntArray()
}
// Then pass something like this:
val cats = convertToIntArray(oldListOfCats)
val dogs = convertToIntArray(oldListOfDogs)
Ofir Bar
02/18/2020, 7:28 PMdata class Dog(val id: Int, val name: String)
val dogs = arrayListOf(Dog(0, "jack"), Dog(1,"Jacky"), Dog(2, "Chan"))
val listOfDogsId = dogs.somecoolmethodhere(it.id) // listOfDogsId = arrayListOf<Int>(0,1,2)
voben
02/18/2020, 8:33 PMval viewDataBinding: T = DataBindingUtil.bind(itemView)
iex
02/19/2020, 6:38 AMclass Foo<T> {
fun <T> foo(a: T, b: T) = a == b // compiles
}
class MyCallback<T> : DiffUtil.ItemCallback<T>() {
override fun areItemsTheSame(oldItem: T, newItem: T): Boolean =
throw Error("TODO")
override fun areContentsTheSame(oldItem: T, newItem: T): Boolean =
oldItem == newItem // Doesn't compile - "equals in not implemented on T"
}
Ofir Bar
02/19/2020, 12:40 PMProfession
that we send to our backend using Retrofit.
data class Profession (
@SerializedName("activeSince") var activeSince : Long?,
@SerializedName("name") var businessName : String?,
@SerializedName("description") var businessDescription : String?,
@SerializedName("licenseImageUrl") var licenseImageUrl : String?
)
Sometimes we send the entire object, but other times, I prefer to only send specific fields (for example, only the businessDescription
and businessName
).
Is it possible to tell retrofit to not include the other 2 fields in the network request? (activeSince
and licenseImageUrl
).
Note: I can’t send activeSince
and licenseImageUrl
as null. Our backend will send me back errors if I attempt to do that (edited)Ofir Bar
02/19/2020, 4:28 PMreturnedExpertiseFields
inside a ViewModel.
I want to initialize this list using a query to Room.
returnedExpertiseFields
gets returned before it is initialized with values from Room, as in the code below:
fun getExpertiseFieldsById(expertiseFieldsIds: IntArray) : List<ExpertiseField>{
var returnedExpertiseFields = listOf<ExpertiseField>()
viewModelScope.launch {
returnedExpertiseFields = mExpertiseFieldFieldsRepository.getExpertiseFieldsFromDatabaseById(expertiseFieldsIds)
}
return returnedExpertiseFields
}
returnedExpertiseFields
will return an empty list of ExpertiseField
.
What can I do to make sure I always wait to Room query to be returned? I thought calling launch is synchronous?
(If you need my repository code I will post it, I just thought it might not be necessary)
Also, If any of you have any tips for debugging when using coroutines I will be glad to hear. I initially tought my Room query is broken. After long debugging I realized I am jumping between breakpoints rather them skipping them.Shreyas Patil
02/19/2020, 5:51 PMDr.jacky
02/20/2020, 10:35 AM@Parcelize
works on Pair type as well?
Or in the other hand, does it work on classes that implement Serializable
. ?
I tried on a sample app and it worked. But I have a crash in Crashlytics:
Fatal Exception: java.lang.RuntimeException
Parcelable encountered IOException writing serializable object (name = kotlin.Pair)
keyboard_arrow_up
Brendan Weinstein
02/20/2020, 6:14 PMshaktiman_droid
02/21/2020, 2:49 AMsimulator
vs physical
based on some checks on Build
class values
But there is no way for SDK to know about beta testing
vs production
unless the developer of the app using the SDK provides that information via a public API
Could someone confirm this ? OR if there is a way to do this then provide some insights.
Reason is to route API calls and data to a particular endpoint so various data doesn’t end up skewing production data.
I can do that via different API Keys for all for cases, but that’s off the limits right now.
Bruno_
02/21/2020, 2:41 PMholder.rootView.setOnClickListener {
it.findNavController().navigate(R.id.numberDetailsScreen, bundleOf("numberName" to item.name))
}
the thing is that (from what I know) convention tells you to create Navigator interface
but doing so would require passing the event up somehow
so I could call this
interface NumbersListNavigator {
fun openNumberDetailsActivity(numberName: String)
}
Harun Artın
02/21/2020, 8:50 PMBruno_
02/21/2020, 8:56 PMCody Engel
02/22/2020, 2:34 PMtirgei
02/23/2020, 7:30 AMOfir Bar
02/23/2020, 11:31 AMUser
object from the Shared Preferences.
Here is the line of code I use:
private val mCurrentUser = Defaults[PrefsKeys.user]!!
So Defaults[PrefsKeys.user]!!
returns the current User
object stored in Shared Preference.
The issue is when I change the value in the Shared Preference, mCurrentUser
is still the same User
object.
Can I replace mCurrentUser
to be an actual call to the SharedPreference? I guess I am trying to make something like an alias. Because calling Defaults[PrefKeys.user]!! everytime is not very readable.Arslan Mushtaq
02/23/2020, 7:21 PM@Query("SELECT * FROM cart_table")
fun getAllItemsFromCart(): LiveData<List<Cart>>
@Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun insert(cart: Cart)
@Query("DELETE FROM cart_table")
suspend fun deleteAllItemsFromCart()
@Delete
suspend fun deleteItemFromCart(cart: Cart)
@Query("SELECT COUNT(*) FROM cart_table")
suspend fun itemCount(): Int
@Query("SELECT SUM(total) FROM cart_table")
fun getGrandTotal(): LiveData<Double>
@Query("UPDATE cart_table SET quantity = quantity + 1 WHERE id = :id")
suspend fun increaseQuantity(id: Int)
@Query("UPDATE cart_table SET quantity = quantity - 1 WHERE id = :id")
suspend fun decreaseQuantity(id: Int)
Slackbot
02/24/2020, 6:36 AMOfir Bar
02/24/2020, 9:08 AMUserFragment
, the fragment display data of a User, the data is fetched from the SharedPreferences.
EditUserActivity
:Edits the data of the user, and once editing is done, this activity calls finish()
and we go back to MainActivity
, which displays UserFragment
When returning to UserFragment
, the data displayed is the old data for the user (the unedited data)
I can think of 2 ways to make the fragment display fresh data, can anyone think of a smarter way, or explain which way below is better in terms of design?
1. Make UserFragment
start EditUserActivity
with startActivityForResult
, and return a success or failure code, if success we do some data refresh.
2. Make UserFragment
terminate itself once we navigate to EditUserActivity
, and make EditUserActivity
launch MainActivity
with UserFragment
on a backpress or successful save.
Even if there is a way that is tricky and should not be in production i would like to know as I want to expand my skills please, thank you! 🙂jmfayard
02/24/2020, 10:43 AMOfir Bar
02/24/2020, 1:22 PMuploadFileToFirebase
function?
What am I doing wrong?
(part in red says):
return is not allowed here