M.Onirban
09/09/2021, 5:09 PMPhongBM
09/10/2021, 2:26 AMSlackbot
09/10/2021, 6:09 AMKulwinder Dhanjal
09/10/2021, 8:18 AMfun Float.round(decimals: Int = 2): Float = "%.${decimals}f".format(this).toFloat()
Slackbot
09/10/2021, 4:36 PMChandan Kumar Pradhan
09/11/2021, 4:29 PMJay
09/12/2021, 5:25 PMval x: String by lazy{...}
When I decompile the Kotlin code into Java code, I see that the getX() method is not ultimately called this method
public inline operator fun <T> Lazy<T>.getValue(thisRef: Any?, property: KProperty<*>): T = value
It is the getter method of value, which is getValue()
instead of getValue(thisRef: Any?, property: KProperty<*>)
So, I don’t understand how the method getValue(thisRef: Any?, property: KProperty<*>)
is called during the execution of lazyJeff
09/13/2021, 7:34 AMChat
which holds another class with a list of Message
can you order a list of chats with a variable in message like createdAt
Remon Shehata
09/13/2021, 12:09 PMsuspend fun foo(){
runBlocking(<http://Dispatchers.IO|Dispatchers.IO>) {
// do some operation and return only after it's completed
}
}
How ever adding the suspend modifier gave me the following warning (posted in reply).Tyler Turnbull
09/13/2021, 3:10 PMlintOptions {
checkReleaseBuilds false
warningsAsErrors true
abortOnError true
lintConfig file('lint.xml')
baseline(file("lint-baseline.xml"))
}
I added a new lint violation which is a warning, but should be treated as an error and abort.. yet the build succeeds every timeLilly
09/13/2021, 10:25 PMList<Map<String, String>>.
I would like to add a pair to a specific map in the list which I determine with
myList.find { it["myKey"] == "keyValue" }
What is the best approach to achieve this. The first option that comes in mind is to remove the map and add the map with the new pair. Any better ideas?Rafiul Islam
09/14/2021, 2:58 PMBrian Donovan
09/14/2021, 5:23 PMBill
09/14/2021, 10:55 PMTrevor Stone
09/15/2021, 1:03 AMharis mehmood
09/15/2021, 6:36 AMSlackbot
09/15/2021, 8:24 AMLoredana Petrea
09/15/2021, 12:04 PMv[0..9]
e.g:
<https://baseurl.test/v1/example/{id}>
the result should be only <https://baseurl.test/>
Where the version number can be 1,2....9
Is there a way to do this?maxmello
09/15/2021, 2:52 PMoverride fun onCreate(…) {
…
scope.launch /* on Dispatchers.Main */ {
viewModel.flow.collect { it ->
uiElement.text = it
}
}
}
Is is better to do launch(Dispatchers.Default)
and then wrap the UI operation in withContext(Dispatchers.Main)
, or is there no practical difference since the collect is suspending and not blocking? If I would do more operations except setting the UI element, I would always do the approach with launch on Dispatchers.Default + withContext(Main), but here I really only update the UI on collectHien Nguyen
09/15/2021, 9:19 PMLilly
09/15/2021, 9:30 PMmyString
.map { it.split(";") }
gives me a List<List<String>>
where the last items are empty strings because split
interperets ";" as empty string -> ""
. I would like to have null
instead of ""
. How can I achieve this? Output should be List<List<String?>>
nilTheDev
09/16/2021, 6:25 AMHovhannes
09/16/2021, 1:42 PMoverride fun onBindViewHolder(holder: DataViewHolder, position: Int) {
holder.bind(users[position])
holder.itemView.textViewUserName.setOnClickListener(View.OnClickListener {
Toast.makeText(it.context, "Pos:$position", Toast.LENGTH_LONG).show()
MyCustomDialog().show((it.context as MainActivity).supportFragmentManager, "MyCustomFragment")
it.tv_name.text = users[position].name //Error
})
}
Napa Ram
09/17/2021, 9:47 AMHovhannes
09/17/2021, 11:45 AMDan Peluso
09/17/2021, 6:51 PMcontext.display?.getRealMetrics(displayMetrics)
but that seems to return a much larger value than I'm looking for. I know for Pixel 2 the height is ~730, but I get 1920 when using displayMetrics.heightPixels
. In other words, I'd like to see programmatically which devices will use values
and which will use values-h700dp
Ali.F
09/19/2021, 12:11 PMSergio C.
09/19/2021, 12:17 PMKulwinder Dhanjal
09/20/2021, 4:52 AMlistItems.forEach { widgetData->
if(widgetData.title.contains(keyword, true)){
searchedList.add(widgetData)
}else{
val filteredWidgets = item.widgets.filter { widget ->
widget.title.contains(keyword, true)
}
if (filteredWidgets.isNotEmpty()) {
val newItem = WidgetData(
id = widgetData.id,
title = widgetData.title,
isFree = widgetData.isFree,
theme = widgetData.theme,
thumbnail = widgetData.thumbnail,
widgets = filteredWidgets
)
searchedList.add(newItem)
}
}
}
here is my data classes
data class WidgetData(
val id: Int,
val isFree: Boolean,
val theme: Any,
val thumbnail: String,
val title: String,
var widgets: List<Widget>
)
data class Widget(
val image: String,
val title: String,
val type: String
)
i am sure there will be a better option in kotlin to write this, i am searching for that..Slackbot
09/21/2021, 6:14 AMSlackbot
09/21/2021, 6:14 AMgildor
09/21/2021, 7:29 AMcodeslubber
09/21/2021, 9:18 PM