/* * Copyright (C) 2009 Apps Organizer * * This file is part of Apps Organizer * * Apps Organizer is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Apps Organizer is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Apps Organizer. If not, see <http://www.gnu.org/licenses/>. */ package com.google.code.appsorganizer; import android.content.Context; import android.database.Cursor; import android.widget.AlphabetIndexer; import android.widget.SectionIndexer; import android.widget.SimpleCursorAdapter; public final class AppCursorAdapter extends SimpleCursorAdapter implements SectionIndexer { private final AlphabetIndexer alphaIndexer; public AppCursorAdapter(Context context, int layout, Cursor c, String[] from, int[] to) { super(context, layout, c, from, to); alphaIndexer = new AlphabetIndexer(c, 1, " ABCDEFGHIJKLMNOPQRSTUVWXYZ"); } public int getPositionForSection(int section) { return alphaIndexer.getPositionForSection(section); } public int getSectionForPosition(int position) { return alphaIndexer.getSectionForPosition(position); } public Object[] getSections() { return alphaIndexer.getSections(); } }