dmitriy.m
09/19/2017, 6:30 PMResourceBounded<T>
is ugly as for me
Thankswasyl
09/06/2019, 2:03 PMexternal libraries
sectionAkbar
09/09/2019, 1:01 PMChristiano
09/09/2019, 1:46 PM<https://stackoverflow.com/questions/57809046/is-there-an-api-or-sdk-to-create-a-remote-control-application-on-smartphone-for>
.
Any thoughts would be helpful and very much obliged!!rkeazor
09/09/2019, 11:54 PMrkeazor
09/09/2019, 11:54 PMMohamed Ibrahim
09/10/2019, 9:59 AMfun String.applySpans(vararg pairs: Pair<String, Any>): Spannable {
val spannable = SpannableStringBuilder(this)
pairs.forEach {
val start = this.indexOf(it.first)
val end = start + it.first.length
spannable.setSpan(it.second, start, end, Spannable.SPAN_INCLUSIVE_INCLUSIVE)
}
return spannable
}
this is the working version in the test sample
val bold = StyleSpan(Typeface.BOLD)
val italic = StyleSpan(Typeface.BOLD_ITALIC)
val string = getString(R.string.hello_message, "John", "Wick")
testTextView.text = string.applySpans(
"John" to bold,
"Wick" to italic
)
this is the code with the problem
is AlternateSearchError.NotDeliveringToArea -> {
searchErrorView.errorAction.visible()
val message = getString(R.string.not_delivery_to_this_area, searchError.restaurant, searchError.area)
searchErrorView.errorMessage.text = message.applySpans(
searchError.restaurant to bold,
searchError.area to bold
)
}
dave
09/10/2019, 12:22 PMSteve
09/10/2019, 8:44 PMSergio C.
09/10/2019, 8:44 PMSteve
09/10/2019, 8:48 PMSergio C.
09/10/2019, 8:51 PMrkeazor
09/10/2019, 11:43 PMSam
09/11/2019, 4:58 AMrun
block to wrap some logical code ?
Thanks
compositeDisposable.add(
repo.getAll()
.subscribeOn(<http://schedulerProvider.io|schedulerProvider.io>())
.observeOn(schedulerProvider.ui())
.subscribe({ data ->
run {
output?.onResultCategories(BlockToday(TodayType.CATEGORIES, data.data))
}
}, { throwable ->
run {
throwable.printStackTrace()
}
})
DALDEI
09/11/2019, 5:12 AMSam
09/11/2019, 5:21 AMDALDEI
09/11/2019, 5:22 AM"hi".if( this == "bye" ) println( "BYE" ) else println( this )
But you can do this
"hi".run {
if( this == "bye" ) println( "BYE" ) else println( this )
}
Another common use case for run is as the body of a function that is more then 1 expressions so you can 'avoid' using return ..
fun printAndAdd( a: Int ) : Int {
println(a)
return a+1
}
vs
fun printAndAdd( a: Int ) = run {
println(a)
a+1
}
Note: the later case allows the compiler to infer the return type as well as eliminate the return statement
fairly minor difference in the above case but can be more useful as the body gets more complex.DALDEI
09/11/2019, 5:23 AMMahendran
09/11/2019, 5:47 AMSam
09/11/2019, 7:03 AMrobjperez
09/11/2019, 9:55 AMrobjperez
09/11/2019, 9:56 AMJOHSE
09/11/2019, 5:27 PMBruno Garcia
09/12/2019, 12:03 AMmingkangpan
09/12/2019, 11:06 AM@parcelize
on classes which inherit from abtract classes with constrcutor member variables?Mahendran
09/12/2019, 12:26 PMAlejandro Rios
09/12/2019, 12:33 PMSam
09/12/2019, 12:56 PMSam
09/12/2019, 12:56 PMDeprecated
this library.