Reputation: 1332
I'm porting an Android app from java to Kotlin. I have a cursor loader to populate a RecyclerView, Everything is fine in Java, but when I try "translate" the code from java to Kotlin I got the message from android studio that you can see in the image below.
My code in java is:
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args){
return new CursorLoader(getContext(), Contrato.URI_CONTENIDO_BASE, null,null,null,null);
}
@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data){
adaptador.swapCursor(data);
layoutManager.scrollToPosition(adaptador.getItemCount() -1);
}
@Override
public void onLoaderReset(Loader<Cursor> loader){
}
And the code in Kotlin is:
override fun onCreateLoader(id: Int, args: Bundle?): Loader<Cursor> {
return CursorLoader(context,MMDContract.columnas.CONTENT_BASE_URI, null, null, null, null)
}
override fun onLoadFinished(loader: Loader<Cursor>?, data: Cursor?) {
adapter.swapCursor(data)
}
override fun onLoaderReset(loader: Loader<Cursor>?) {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
I haven´t finded official documentation in Kotlin, only in Java. https://developer.android.com/guide/components/loaders
Any idea of how can I solve this?
Upvotes: 1
Views: 658
Reputation: 6579
Change
return CursorLoader(context,
MMDContract.columnas.CONTENT_BASE_URI, null, null, null, null)
into
return CursorLoader(context,
MMDContract.columnas.CONTENT_BASE_URI, null, null, null, null) as Loader<Cursor>
should resolve this.
This error looks like a IDE bug. If you can always see the same error message you may report it on https://youtrack.jetbrains.com/.
Upvotes: 3