ormlite-android-extras icon indicating copy to clipboard operation
ormlite-android-extras copied to clipboard

Improving performance for Cursor

Open PerfectCarl opened this issue 12 years ago • 0 comments

Hello,

I noticed that performance is improved in cursor by using caching AndroidResult in CursorAdapter

public abstract class OrmliteCursorAdapter<T> extends CursorAdapter
{
     // Stripped code...
    private AndroidDatabaseResults results;

    @Override
    public void bindView(View itemView, Context context, Cursor cursor)
    {
        try
        {
        if (results == null)
        results = new AndroidDatabaseResults(cursor, null);
        T item = mQuery.mapRow(results);
            bindView(itemView, context, item);
        }
        catch(SQLException e)
        {
            e.printStackTrace();
        }

    }

I have some tests on my hand and it seems that it does not introduce regression.

Cheers.

PerfectCarl avatar Jan 22 '13 18:01 PerfectCarl