Thursday, 5 September 2013

CursorLoader with additional query in CursorAdapter

CursorLoader with additional query in CursorAdapter

I'm using a Loader to fetch rows of a table. To display the rows I have
written a custom CursorAdapter.
Now my problem is that I'm using two additional queries in the
CursorAdapter and this produced bad performance.
In the first approach I simply wrote the queries in the bindView()-Method.
That worked but was slow so I put the queries in two AsyncTask. With the
last solution I got the worst performance. That startled me because I was
using multithreading.
I detected that the UI changes on the onPostExecute()-Method are causing
the lags.
What would you recommenc me to solve this issue? One thing could be to
stop the AsyncTask when the row is not visible anymore or recycled.
Another Idea would be to fetch all Data in the Loader but I don't know how
to do this.
My queries are:
[table1] fetching all records from one table
[table2] fetching one record sorted by date for every row of query 1
[table2] counting all records matching two requirements from query 1
I could merge query 2 and 3 but I think thats not the point.

No comments:

Post a Comment