android.widget.AlphabetIndexer Java Examples

The following examples show how to use android.widget.AlphabetIndexer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ContactsAdapter.java    From tindroid with Apache License 2.0 6 votes vote down vote up
ContactsAdapter(Context context, ImageLoader imageLoader, ClickListener clickListener) {

        mClickListener = clickListener;
        mImageLoader = imageLoader;
        mSelected = new HashMap<>();

        setHasStableIds(true);
        mCursor = null;

        // Loads a string containing the English alphabet. To fully localize the app, provide a
        // strings.xml file in res/values-<x> directories, where <x> is a locale. In the file,
        // define a string with android:name="alphabet" and contents set to all of the
        // alphabetic characters in the language in their proper sort order, in upper case if
        // applicable.
        final String alphabet = context.getString(R.string.alphabet);

        // Instantiates a new AlphabetIndexer bound to the column used to sort contact names.
        // The cursor is left null, because it has not yet been retrieved.
        mAlphabetIndexer = new AlphabetIndexer(null, ContactsLoaderCallback.ContactsQuery.SORT_KEY, alphabet);

        // Defines a span for highlighting the part of a display name that matches the search
        // string
        mHighlightTextSpan = new TextAppearanceSpan(context, R.style.searchTextHighlight);
    }
 
Example #2
Source File: ChannelFragment.java    From Applozic-Android-SDK with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Instantiates a new Contacts Adapter.
 *
 * @param context A context that has access to the app's layout.
 */
public ChannelAdapter(Context context) {
    super(context, null, 0);
    this.context = context;
    // Stores inflater for use later
    mInflater = LayoutInflater.from(context);
    final String alphabet = context.getString(R.string.alphabet);

    // Instantiates a new AlphabetIndexer bound to the column used to sort contact names.
    // The cursor is left null, because it has not yet been retrieved.
    mAlphabetIndexer = new AlphabetIndexer(null, 1, alphabet);

    // Defines a span for highlighting the part of a display name that matches the search
    // string
    highlightTextSpan = new TextAppearanceSpan(getActivity(), R.style.searchTextHiglight);
}
 
Example #3
Source File: ContactSelectionFragment.java    From Applozic-Android-SDK with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Instantiates a new Contacts Adapter.
 *
 * @param context A context that has access to the app's layout.
 */
public ContactsAdapter(Context context) {
    super(context, null, 0);
    this.context = context;
    userIdList = new ArrayList<String>();
    // Stores inflater for use later
    mInflater = LayoutInflater.from(context);
    // Loads a string containing the English alphabet. To fully localize the app, provide a
    // strings.xml file in res/values-<x> directories, where <x> is a locale. In the file,
    // define a string with android:name="alphabet" and contents set to all of the
    // alphabetic characters in the language in their proper sort order, in upper case if
    // applicable.
    final String alphabet = context.getString(R.string.alphabet);

    // Instantiates a new AlphabetIndexer bound to the column used to sort contact names.
    // The cursor is left null, because it has not yet been retrieved.
    mAlphabetIndexer = new AlphabetIndexer(null, 1, alphabet);

    // Defines a span for highlighting the part of a display name that matches the search
    // string
    highlightTextSpan = new TextAppearanceSpan(context, R.style.searchTextHiglight);
}
 
Example #4
Source File: AppContactFragment.java    From Applozic-Android-SDK with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Instantiates a new Contacts Adapter.
 *
 * @param context A context that has access to the app's layout.
 */
public ContactsAdapter(Context context) {
    super(context, null, 0);
    this.context = context;
    // Stores inflater for use later
    mInflater = LayoutInflater.from(context);
    // Loads a string containing the English alphabet. To fully localize the app, provide a
    // strings.xml file in res/values-<x> directories, where <x> is a locale. In the file,
    // define a string with android:name="alphabet" and contents set to all of the
    // alphabetic characters in the language in their proper sort order, in upper case if
    // applicable.
    final String alphabet = context.getString(R.string.alphabet);

    // Instantiates a new AlphabetIndexer bound to the column used to sort contact names.
    // The cursor is left null, because it has not yet been retrieved.
    mAlphabetIndexer = new AlphabetIndexer(null, 1, alphabet);

    // Defines a span for highlighting the part of a display name that matches the search
    // string
    highlightTextSpan = new TextAppearanceSpan(getActivity(), R.style.searchTextHiglight);
}
 
Example #5
Source File: PatientListFragment.java    From sana.mobile with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public Cursor index(Cursor cursor) {
    if (cursor != null) {
        mRowStates = new int[cursor.getCount()];
        mAlphaIndexer = new AlphabetIndexer(cursor,
                1,
                mAlphabet);
        mAlphaIndexer.setCursor(cursor);
        Arrays.fill(mRowStates, STATE_UNKNOWN);
    } else {
        mRowStates = new int[0];
        mAlphaIndexer = null;
    }
    if (mRowStates.length > 0)
        mRowStates[0] = STATE_LABELED;
    return cursor;
}
 
Example #6
Source File: AlphabetIndexerCursorAdapter.java    From MultiChoiceAdapter with Apache License 2.0 5 votes vote down vote up
public AlphabetIndexerCursorAdapter(Bundle savedInstanceState, Context context, Cursor cursor) {
    super(savedInstanceState, context, R.layout.mca__simple_list_item_checkable_1, cursor, FROM, TO, 0);

    // Sets a new cursor as the data set and resets the cache of indices.
    int columnIndex = cursor.getColumnIndex(BuildingsContract.NAME);
    alphabetIndexer = new AlphabetIndexer(cursor, columnIndex, " ABCDEFGHIJKLMNOPQRTSUVWXYZ");
    alphabetIndexer.setCursor(cursor);
}
 
Example #7
Source File: UserDictionarySettings.java    From openboard with GNU General Public License v3.0 5 votes vote down vote up
public MyAdapter(final Context context, final int layout, final Cursor c,
        final String[] from, final int[] to) {
    super(context, layout, c, from, to, 0 /* flags */);

    if (null != c) {
        final String alphabet = context.getString(R.string.user_dict_fast_scroll_alphabet);
        final int wordColIndex = c.getColumnIndexOrThrow(UserDictionary.Words.WORD);
        mIndexer = new AlphabetIndexer(c, wordColIndex, alphabet);
    }
    setViewBinder(mViewBinder);
}
 
Example #8
Source File: AlphabetIndexerCursorAdapter.java    From MultiChoiceAdapter with Apache License 2.0 5 votes vote down vote up
public AlphabetIndexerCursorAdapter(Bundle savedInstanceState, Context context, Cursor cursor) {
    super(savedInstanceState, context, R.layout.mca__simple_list_item_checkable_1, cursor, FROM, TO, 0);

    // Sets a new cursor as the data set and resets the cache of indices.
    int columnIndex = cursor.getColumnIndex(BuildingsContract.NAME);
    alphabetIndexer = new AlphabetIndexer(cursor, columnIndex, " ABCDEFGHIJKLMNOPQRTSUVWXYZ");
    alphabetIndexer.setCursor(cursor);
}
 
Example #9
Source File: AlphabetIndexerCursorAdapter.java    From MultiChoiceAdapter with Apache License 2.0 5 votes vote down vote up
public AlphabetIndexerCursorAdapter(Bundle savedInstanceState, Context context, Cursor cursor) {
    super(savedInstanceState, context, R.layout.mca__simple_list_item_checkable_1, cursor, FROM, TO, 0);

    // Sets a new cursor as the data set and resets the cache of indices.
    int columnIndex = cursor.getColumnIndex(BuildingsContract.NAME);
    alphabetIndexer = new AlphabetIndexer(cursor, columnIndex, " ABCDEFGHIJKLMNOPQRTSUVWXYZ");
    alphabetIndexer.setCursor(cursor);
}
 
Example #10
Source File: ContactListFragment.java    From haxsync with GNU General Public License v2.0 5 votes vote down vote up
public Cursor swapCursor(Cursor c) {
    // Create our indexer
    if (c != null) {
        mAlphaIndexer = new AlphabetIndexer(c, c.getColumnIndex(RawContacts.DISPLAY_NAME_PRIMARY),
            " ABCDEFGHIJKLMNOPQRSTUVWXYZ");
    }
    return super.swapCursor(c);
}
 
Example #11
Source File: ApplicationsAdapter.java    From LiveBlurListView with Apache License 2.0 5 votes vote down vote up
public ApplicationsAdapter(Context context, ArrayList<AppInfo> apps) {
	super(context, 0, apps);
	mInflater = LayoutInflater.from(context);
	//mSectionString = context.getResources().getString(R.string.fast_scroll_alphabet);
	alphabetIndexer = new AlphabetIndexer(new IndexCursor(this), 0, "#ABCDEFGHIJKLMNOPQRSTUVWXYZ");
	final int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024);  
	final int cacheSize = maxMemory / 8;  
	  
	mMemoryCache = new LruCache<String, Bitmap>(cacheSize) {  
		@Override  
		protected int sizeOf(String key, Bitmap bitmap) {  
			return bitmap.getByteCount()/1024;
		}  
	};
}
 
Example #12
Source File: PatientListFragment.java    From sana.mobile with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void init(Cursor c) {
    if (c == null) {
        return;
    }
    //mWrapper = new PatientWrapper(c);
    //c.setNotificationUri(context.getContentResolver(), Patients.CONTENT_URI);
    mRowStates = new int[c.getCount()];
    Arrays.fill(mRowStates, STATE_UNKNOWN);
    if (mRowStates.length > 0)
        mRowStates[0] = STATE_LABELED;
    mAlphaIndexer = new AlphabetIndexer(c,
            1,
            mAlphabet);
    mAlphaIndexer.setCursor(c);
}
 
Example #13
Source File: UserDictionarySettings.java    From Indic-Keyboard with Apache License 2.0 5 votes vote down vote up
public MyAdapter(final Context context, final int layout, final Cursor c,
        final String[] from, final int[] to) {
    super(context, layout, c, from, to, 0 /* flags */);

    if (null != c) {
        final String alphabet = context.getString(R.string.user_dict_fast_scroll_alphabet);
        final int wordColIndex = c.getColumnIndexOrThrow(UserDictionary.Words.WORD);
        mIndexer = new AlphabetIndexer(c, wordColIndex, alphabet);
    }
    setViewBinder(mViewBinder);
}
 
Example #14
Source File: UserDictionarySettings.java    From AOSP-Kayboard-7.1.2 with Apache License 2.0 5 votes vote down vote up
public MyAdapter(final Context context, final int layout, final Cursor c,
        final String[] from, final int[] to) {
    super(context, layout, c, from, to, 0 /* flags */);

    if (null != c) {
        final String alphabet = context.getString(R.string.user_dict_fast_scroll_alphabet);
        final int wordColIndex = c.getColumnIndexOrThrow(UserDictionary.Words.WORD);
        mIndexer = new AlphabetIndexer(c, wordColIndex, alphabet);
    }
    setViewBinder(mViewBinder);
}
 
Example #15
Source File: ContactsFragment.java    From TestChat with Apache License 2.0 5 votes vote down vote up
public void updateContactsData(String belongId) {
        mIndexer = new AlphabetIndexer(ChatDB.create().getSortedKeyCursor(), 0, alphabet);
        adapter.setSectionIndexer(mIndexer);
        User user=UserCacheManager.getInstance().getUser(belongId);
        LogUtil.e("这里添加的好友星星如下");
        LogUtil.e(user);
        adapter.addData(user);
}
 
Example #16
Source File: UserDictionarySettings.java    From Android-Keyboard with Apache License 2.0 5 votes vote down vote up
public MyAdapter(final Context context, final int layout, final Cursor c,
        final String[] from, final int[] to) {
    super(context, layout, c, from, to, 0 /* flags */);

    if (null != c) {
        final String alphabet = context.getString(R.string.user_dict_fast_scroll_alphabet);
        final int wordColIndex = c.getColumnIndexOrThrow(UserDictionary.Words.WORD);
        mIndexer = new AlphabetIndexer(c, wordColIndex, alphabet);
    }
    setViewBinder(mViewBinder);
}
 
Example #17
Source File: SelectedFriendsActivity.java    From TestChat with Apache License 2.0 4 votes vote down vote up
@Override
public void initData() {
        mLinearLayoutManager = new LinearLayoutManager(this);
        display.setLayoutManager(mLinearLayoutManager);
        display.addItemDecoration(new ListViewDecoration(this));
        display.setItemAnimator(new DefaultItemAnimator());
        mMyLetterView.setTextView(middle);
        adapter = new ContactsAdapter(UserCacheManager.getInstance().getAllContacts(),R.layout.fragment_contacts_list_item);
        adapter.setOnCheckedChangeListener(this);
        mIndexer = new AlphabetIndexer(ChatDB.create().getSortedKeyCursor(), 0, alphabet);
        adapter.setSectionIndexer(mIndexer);
        display.setAdapter(adapter);
        initActionBar();
}