danielgomezrico
07/18/2016, 8:50 PMdanielgomezrico
07/18/2016, 8:51 PMmarco.eig
07/18/2016, 9:17 PMmarco.eig
07/18/2016, 9:23 PMlike
) you could also create a data class called VideoLikeRequest
, VideoLikeContext
, etc. . In case you have to add parameters you don’t have to change the interface (which is often cumbersome). This could silently break clients, but if you use data classes it won’t compile anyway, since the constructor changes.debug
07/19/2016, 11:12 AMclass FilterView(context: Context?, private val viewItem: ViewItem = ViewItem()) : SimpleDraweeView(context), Item by viewItem {
init {
viewItem.view = this
}
}
ViewItem
needs the current View
so this is the workaround that I've come up with. However, lint complains that "CustomView is missing ... constructor used by tools". So, is there a better way to do this? I also doubt that this might cause issues for the Android framework.debug
07/19/2016, 11:29 AMlateinit
voddan
07/19/2016, 12:55 PMthis
?debug
07/19/2016, 1:16 PMView
and makes some modifications to it. It doesn't seem to be possible to refer to the View
during construction so had to do it this way. I'm worried if it would cause issues during View
recreation.Dave Leeds
07/21/2016, 9:02 PMFor creating maps in a not performance-critical code a simple idiom may be used:What would be the preferred way to create a map in performance-critical code?mapOf(a to b, c to d)
sargunv
07/21/2016, 9:06 PMDave Leeds
07/21/2016, 10:21 PMDave Leeds
07/21/2016, 10:21 PMval readOnlyMap: Map<String, String> = with(HashMap<String, String>()) {
put("first", "john")
put("last", "doe")
this
}
Dave Leeds
07/21/2016, 10:22 PMPair
for each entry via to
.debug
07/22/2016, 1:55 AMval readOnlyMap: Map<String, String> = HashMap<String, String>().apply {
put("first", "john")
put("last", "doe")
}
Use apply
rather than with
here. 🙂jkbbwr
07/22/2016, 12:30 PMval readOnlyMap = mapOf(
"first" to "john",
"last" to "doe"
)
voddan
07/22/2016, 12:32 PMjkbbwr
07/22/2016, 12:33 PMjkbbwr
07/22/2016, 12:33 PMjkbbwr
07/22/2016, 12:38 PM0.002
milliseconds your bottleneck?jkbbwr
07/22/2016, 12:38 PMdstarcev
07/27/2016, 1:01 PMdstarcev
07/27/2016, 1:02 PMval html = URL("<http://mysite.com>")
.openConnection()
.inputStream.use {
InputStreamReader(it).use {
it.readText()
}
}
return object {
val html = html
}
christophsturm
07/27/2016, 1:06 PMdstarcev
07/27/2016, 1:09 PM@RestController
class LookupPropertyHandler {
@RequestMapping("/api/lookup", method = arrayOf(RequestMethod.GET))
fun handle(@RequestParam address: String): Any {
val html = URL("<http://mysite.com>")
.openConnection()
.inputStream.use {
InputStreamReader(it).use {
it.readText()
}
}
return object {
val html = html
}
}
}
mbickel
07/27/2016, 1:13 PMURL.openStream
mbickel
07/27/2016, 1:13 PMURL.readText
fun. 🙂mbickel
07/27/2016, 1:14 PMreturn object { val html = URL("blabla").readText() }
. Tho you probably want to use some caching/retry/blabla layer?dstarcev
07/27/2016, 1:16 PMmbickel
07/27/2016, 1:16 PMdstarcev
07/27/2016, 1:16 PM