poohbar
06/14/2019, 3:28 PM(argument as List<String>?)?.orEmpty()
intellij is highlighting the ?.
as "This call is useless"
why is it useless?Mario
06/16/2019, 6:50 PMChi
06/18/2019, 9:02 PMguard
in swiftChi
06/18/2019, 9:11 PMhooliooo
06/19/2019, 10:07 AMFlorian
06/19/2019, 7:57 PMkarelpeeters
06/19/2019, 9:13 PMIfvwm
06/20/2019, 2:52 AMObaid Jatoi
06/20/2019, 7:08 AMelaborate tissue
06/20/2019, 3:09 PMHullaballoonatic
06/20/2019, 6:46 PMclass Foo
from Foo::class
in any way?Florian
06/20/2019, 7:16 PMFlorian
06/20/2019, 9:31 PMmatt tighe
06/20/2019, 10:34 PMinterface foo {
@StringRes val text: Int
}
poohbar
06/21/2019, 3:23 PMMyClass::class.sealedSubclasses
does not return the classes in the order they were defined as opposed to MyEnum.values()
in Java. Bit me!Florian
06/21/2019, 8:08 PMFlorian
06/21/2019, 8:26 PMFlorian
06/22/2019, 10:56 AMam
06/23/2019, 10:58 AMabstract class CardHolder<T:RecyclerView.ViewHolder>{
lateinit var actionListener: CardActionListener
abstract fun onCreateViewHolder(parent: ViewGroup): T
abstract fun onBindViewHolder(holder:T, card: Card, position: Int)
}
which will be extended to do inflationa and other formalities to display data,
class NewCardDelegate:CardViewHolder<NewHolder>{
//Rest of code
}
the reason I was doing this so that I could define a mutableMap<Int,CardHolder> and reduce the Adapter class
val map =mutableMapOf<Int,CardHolder>
map[25] = NewCard() //error
but it seems like its not right way
Please guide me for any other better wayIfvwm
06/24/2019, 5:21 AMIfvwm
06/24/2019, 5:21 AMscottiedog45
06/24/2019, 6:05 PM: Dispatcher = object : Dispatcher()
fun updateErrorCodeForUrl(url: String, errorCode: Int) : Dispatcher = object : Dispatcher() {
@Throws(InterruptedException::class)
override fun dispatch(request: RecordedRequest): MockResponse {
when (request.path) {
url -> return MockResponse()
.setResponseCode(errorCode)
}
return MockResponse().setResponseCode(422)
}
}
JoshK
06/24/2019, 11:55 PMval job = GlobalScope.launch { /* Things here */ }
then job.invokeOnCompletion { /* It's done now */ }
? What's the best way to handle this?Florian
06/25/2019, 10:19 AMspencerwi
06/25/2019, 6:39 PMscottiedog45
06/25/2019, 8:43 PMval intent = Intent(Intent.ACTION_VIEW)
intent.data = Uri.parse(platform.appUrl)
lenqnr
06/26/2019, 2:28 PMfun foo() {
getData()?.let { data ->
doSomething(data)
}
}
Is it equivalent to this?
fun foo() {
val data = getData() ?: return
doSomething(data)
}
I don't like adding more indentations, so came up with the second one. Is it OK?CamilleBC
06/26/2019, 2:31 PMsuspend fun getChapters(chapterIds: List<String>): List<Chapter> =
mutableListOf<Chapter>().apply {
chapterIds.forEach { launch { add(getChapter(it)) } }
}
suspend fun getChapter(chapterId: String): Chapter {
val response = service.getChapter(chapterId)
return if (response.isSuccessful) {
val doc = Jsoup.parse(response.body()?.string())
Chapter(
doc.select(CHAPTER_TITLE_QUERY).text(),
doc.select(CHAPTER_CONTENT_QUERY).html().lines()
)
} else Chapter()
}
Sudhir Singh Khanger
06/26/2019, 5:21 PMval articles: List<ArticlesItem?>? = null
as part of my JSON response. I am trying to pull data off this list using articles[position]
but Android Studio complains that Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type List<ArticlesItem?>?
. Why can I do newsDataSet!![position]
but not newsDataSet?[position]
?
val articlesItem: ArticlesItem? = newsDataSet[position]
full code https://github.com/sudhirkhanger/Samachar/blob/911f934252409e9a726e30a4865518e738042c93/app/src/main/java/com/sudhirkhanger/newsapp/ui/list/NewsListAdapter.kt#L45Nikita
06/26/2019, 5:28 PMenum class Events {
"one",
"two",
"three"
}
And I need to get List<Map> like this:
({name: "one", id: "one"}, {name: "two", id: "two"}, {name: "three", id: "three"})
Is there idiomatic way to do this? No ‘for’ loop.Nikita
06/26/2019, 5:28 PMenum class Events {
"one",
"two",
"three"
}
And I need to get List<Map> like this:
({name: "one", id: "one"}, {name: "two", id: "two"}, {name: "three", id: "three"})
Is there idiomatic way to do this? No ‘for’ loop.RoqueRueda
06/26/2019, 5:30 PMRuckus
06/26/2019, 5:30 PMShawn
06/26/2019, 5:33 PMenum class Events {
ONE,
TWO,
THREE,
}
val mappings = Events.values().map {
mapOf("name" to it.name.toLowerCase(), "id" to it.name.toLowerCase())
}
Nikita
06/26/2019, 6:22 PM