I had this weird issue where I used Anko and Android's content provider together, I implemented my fragment using LoaderCallbacks<Cursor>
and at the first time data got loaded and my fun onLoadFinished(loader: Loader<Cursor>?, data: Cursor?) {}
got called and data loaded into the RecyclerView, But when I tried to update the record everything was OK until the point that the onLoadFinished() was not called!
Asked
Active
Viewed 239 times
0

Rez
- 4,501
- 1
- 30
- 27
1 Answers
0
It took my day to figure out that using the Anko's Parser that maps a cursor into an object was the issue:
fun <T: Any> Cursor.parseList(parser: RowParser<T>): List<T> = AnkoInternals.useCursor(this) {
val list = ArrayList<T>(count)
moveToFirst()
while (!isAfterLast) {
list.add(parser.parseRow(readColumnsArray(this)))
moveToNext()
}
return list
}
Long story short: when the user clicks on the Recyclerview item, I'd use the cursor from the adapter and moved it to current position then I tried to map the cursor to my model using:
val cursor = mAdapter?.cursor
cursor?.moveToPosition(it)
Observable.defer {
val uploadingItem = cursor?.parseList(UploadParser())
if (uploadingItem == null) {
Exceptions.propagate(IllegalArgumentException())
}
Observable.just(UploadInfoArgs.parseUploading(uploadingItem?.get(it)!!))
}.subscribeOn(Schedulers.immediate()).observeOn(AndroidSchedulers.mainThread())
which the line cursor?.parseList(UploadParser()) was the issue that my list wouldn't get updated after changes!

Rez
- 4,501
- 1
- 30
- 27