w_bianrytree
07/11/2017, 5:09 PMskennedy
07/11/2017, 8:06 PMansari
07/11/2017, 10:25 PMkostya1375
07/12/2017, 8:35 AMarnaud.giuliani
07/12/2017, 9:37 AMtschuchort
07/12/2017, 12:47 PMUnit
of course, but are there any disadvantages to using Unit
? Most online resources (in Java) seem to use Void
, which I can't even instantiate to call onNext
in my Observable.create()
bachhuberdesign
07/12/2017, 8:26 PMgildor
07/13/2017, 9:42 AMmessage
, you can replace it with String
gildor
07/13/2017, 9:43 AMfun Fragment.showShortSnackbar(message: String) {
val activity = activity ?: return
Snackbar.make(activity.findViewById(android.R.id.content), message, Snackbar.LENGTH_SHORT).show()
}
damien5314
07/13/2017, 5:13 PMoscarg798
07/14/2017, 1:32 AMgabrielfv
07/14/2017, 9:06 PMkevinmost
07/14/2017, 9:14 PMfun
orangy
07/15/2017, 11:39 PMmorozov
07/16/2017, 3:08 PMleosan
07/17/2017, 9:51 AM@Provides Foo<*>
and then
@Provides Presenter(Foo<Bar>)
But this gives me an error Foo<Bar> cannot be provided without an @Inject or @Provides-annotated method
😞
I've tried this already
@Provides Presenter(Foo<@JvmSupressWildcards Bar>)
but without SuccessPaul Woitaschek
07/18/2017, 10:13 AMnorman784
07/18/2017, 12:34 PMbamdmux
07/19/2017, 8:55 AMmutableListOf<AnimalPlanet>()
if you pretend to add elements latermorozov
07/19/2017, 8:55 AMfor
?bamdmux
07/19/2017, 9:05 AM(1..100).map { i -> AnimalPlanet( __use i here__) }
bamdmux
07/19/2017, 9:42 AMsomevalue.coerceAtLeast(0F)
Paul Woitaschek
07/19/2017, 10:06 AMthubi
07/19/2017, 1:24 PMgregd
07/19/2017, 8:43 PMdiego-gomez-olvera
07/20/2017, 8:24 AMjordan29.04.1197
07/20/2017, 9:12 AMval dialogAvatarSource = DialogAvatarSource(this)
dialogAvatarSource.onAvatarSourceChosenListener = object : DialogAvatarSource.OnAvatarSourceChosenListener {
override fun onCameraClick() {
}
override fun onGalleryClick() {
}
}
dialogAvatarSource.show()
java.lang.IllegalArgumentException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter savedInstanceState on dialogAvatarSource.show()szymen
07/21/2017, 12:01 PMPaul Woitaschek
07/21/2017, 1:22 PMmatt_dziubek
07/24/2017, 8:27 AMinterface RecyclerItem<in T : RecyclerView.ViewHolder> {
fun onBindViewHolder(holder: T?)
}
Generic is defined as in
because clearly RecyclerItem
is a consumer, hence I can only assign this instance to its subtype.
I also have a below implementations of `RecyclerItem`:
class ItemSuncalcData() : RecyclerItem<ItemSuncalcData.ViewHolder>
and:
class SomeOtherItem() : RecyclerItem<SomeOtherItem.ViewHolder>
Long story short I want to store above two instances in a List<RecyclerItem<RecyclerView.ViewHolder>>
, but because of in T
I can’t assign subclasses to its supertypes. What’s my best move here? I’ve written same code in java and only got unchecked cast warning.
The only way I could think of was to remove generics from the interface:
interface RecyclerItem {
fun onBindViewHolder(holder: RecyclerView.ViewHolder?)
}
But before I’ll change 15+ files (because of casting I would have to make) I wanted to ask you first, thanks in advance 😉
Take a look at this github repo I made showcasing my problem above: https://github.com/matdziu/GenericsKotlin. You can switch between two commits - one that uses generic way (compilation error in MainActivity) and the second which is the solution I think I found. Note that on production we’re using multiple different item types and factory pattern to choose a proper view holder (this sample is just a huge simplification).matt_dziubek
07/24/2017, 8:27 AMinterface RecyclerItem<in T : RecyclerView.ViewHolder> {
fun onBindViewHolder(holder: T?)
}
Generic is defined as in
because clearly RecyclerItem
is a consumer, hence I can only assign this instance to its subtype.
I also have a below implementations of `RecyclerItem`:
class ItemSuncalcData() : RecyclerItem<ItemSuncalcData.ViewHolder>
and:
class SomeOtherItem() : RecyclerItem<SomeOtherItem.ViewHolder>
Long story short I want to store above two instances in a List<RecyclerItem<RecyclerView.ViewHolder>>
, but because of in T
I can’t assign subclasses to its supertypes. What’s my best move here? I’ve written same code in java and only got unchecked cast warning.
The only way I could think of was to remove generics from the interface:
interface RecyclerItem {
fun onBindViewHolder(holder: RecyclerView.ViewHolder?)
}
But before I’ll change 15+ files (because of casting I would have to make) I wanted to ask you first, thanks in advance 😉
Take a look at this github repo I made showcasing my problem above: https://github.com/matdziu/GenericsKotlin. You can switch between two commits - one that uses generic way (compilation error in MainActivity) and the second which is the solution I think I found. Note that on production we’re using multiple different item types and factory pattern to choose a proper view holder (this sample is just a huge simplification).mzgreen
07/24/2017, 8:35 AMList<RecyclerItem<*>>
?matt_dziubek
07/24/2017, 8:50 AMmzgreen
07/24/2017, 9:13 AMclass RecyclerView{
interface ViewHolder
}
interface RecyclerItem<in T : RecyclerView.ViewHolder> {
fun onBindViewHolder(holder: T?)
}
class ItemTextView : RecyclerItem<ItemTextView.ViewHolder> {
override fun onBindViewHolder(holder: ViewHolder?) {}
class ViewHolder : RecyclerView.ViewHolder {}
}
fun main(args: Array<String>) {
val list = mutableListOf<RecyclerItem<*>>()
list.add(ItemTextView())
println(list.size) // prints 1
}