0

Noticeably slow/Jittery AlphabetIndexer on a CursorAdapter

My listview scrolls smoothly but scrolling up and down when holding the alphabetindexer scrollbar is a bit jittery

I am already using a ViewHolder

I have set the following on my list

mListView.setFastScrollEnabled(true);

I have setup my alphabetindexer as follows

public class FeedFragmentAdapter extends CursorAdapter implements SectionIndexer {

            AlphabetIndexer mAlphabetIndexer;

            public FeedFragmentAdapter(Context context, Cursor cursor, int flags) {
                super(context, cursor, flags);
                cursorInflater = (LayoutInflater) context.getSystemService(
                        Context.LAYOUT_INFLATER_SERVICE);
                this.context = context;
            }

    public void setIndexer(Cursor cursor){

        mAlphabetIndexer = new AlphabetIndexer(cursor,
                cursor.getColumnIndex("name_format"),
                "ABCDEFGHIJKLMNOPQRTSUVWXYZ");
        mAlphabetIndexer.setCursor(cursor);//Sets a new cursor as the data set and resets the cache of indices.

    }
            /**
             * Performs a binary search or cache lookup to find the first row that matches a given section's starting letter.
             */
            @Override
            public int getPositionForSection(int sectionIndex)
            {
                return mAlphabetIndexer.getPositionForSection(sectionIndex);
            }

            /**
             * Returns the section index for a given position in the list by querying the item and comparing it with all items
             * in the section array.
             */
            @Override
            public int getSectionForPosition(int position)
            {
                return mAlphabetIndexer.getSectionForPosition(position);
            }

            /**
             * Returns the section array constructed from the alphabet provided in the constructor.
             */
            @Override
            public Object[] getSections()
            {
                return mAlphabetIndexer.getSections();
            }

The below was not suitable as i am already using a viewholder Android Laggy AlphabetIndexer in ListView

Community
  • 1
  • 1
DeveloperDH
  • 443
  • 5
  • 16
  • How many rows cursor contains? What is the size of the row(does it contains blob)? I had same issue when cursor change window(native data under the cursor) – Selvin Oct 14 '15 at 21:50
  • @Selvin, I do not have many rows, around 100 records, no blobs, do not know how to check the size of the row but each row has around 15 columns with very little data in each column, just short strings or integers. The query for the cursor is made up of around five joins but i assume that the query is not rerunning while i am scrolling. Each cursor record is checked via newview method to determine which one of five list row views items the record should bind. The view is simple user contact view with 2 small images from the drawable folder and the contact name. – DeveloperDH Oct 15 '15 at 13:39
  • hmmm does cursor is ordered by the column used in indexer? – Selvin Oct 15 '15 at 13:40
  • no the column used in indexer is not the order by column, the results are ordered by multiple columns. The column used by indexer is a formatted version of the name column to convert null columns to empty string. some of the rows near top of the list are not in alphabetical name order but majority are in alphabetical order – DeveloperDH Oct 15 '15 at 13:48

0 Answers0