denis.st
04/01/2016, 11:33 PMclass View {
void setNestedScrollingEnabled(boolean enabled)
}
interface NestedScrollingView {
void setNestedScrollingEnabled(boolean enabled)
}
class RecyclerView extends View implements NestedScrollingView {
@Override
void setNestedScrollingEnabled(boolean enabled)
}
and my code:
val list: View = view.findViewById(R.id.list)
if (list is RecyclerView) {
list.setNestedScrollingEnabled(false)
}
And here, when I'm calling the method, on some platforms I'm getting NoSuchMethod exception.
The answer is simple: View.setNestedScrollingEnabled
is implemented only for newer versions of the system framework. But RecyclerView.setNestedScrollingEnabled
is always available. When I write list.setNestedScrollingEnabled
I'm expecting a call to RecyclerView's method, via smart-casting, but a call to View's method is generated.
I've searched, but didn't find anything about this smart-cast's behavior in the language documentation 🙁