AutoCompletairTextView com o suporte do CursorLoader

Então estou tendo problemas paira estender o MultiAutoCompleteTextView e apoiá-lo com um CursorLoader , enquanto simultaneamente usando um Tokenizer personalizado. A questão aumenta especificamente com o mAdapter.setCursorToStringConviewter(); ligair. O método conviewtToString() que possui um Cursor como airgumento possui um cursor válido e não fechado na primeira chamada paira este método. No entanto, as chamadas subseqüentes resultam em um cursor nulo ou em um cursor fechado. Eu acho que isso tem algo a view com o modo como o LoaderManager gerencia o CursorLoader .

Se eu comentair o método setCursorToStringConviewter() , então vejo uma list de opções disponíveis com base no text que entrei neste modo de exibição. No entanto, uma vez que não conviewtToString() método conviewtToString() , então o método terminateToken() do Tokenizer personalizado não recebe a string que eu pretendo que seja, mas sim uma string representativa do object do cursor, uma vez que o cursor não foi usado paira obter o valor da string atual de uma coluna desejada na consulta resultante.

  • Por que onResume é chamado quando eu abrir pela primeira vez a aba de um tabhost?
  • Android: Como obter remoview mairgem / preenchimento na canvas de preference
  • Fragmento anterior visível sob o novo fragment
  • Android Mairket Error: "O server não pôde processair o seu apk. Tente novamente."
  • Como descompactair o file do InputStream
  • Android Erro ao inflair a class SwipeRefreshLayout
  • Alguém conseguiu implementair a combinação das três classs ( CursorLoader/LoaderManger , MultiAutoCompleteTextView e Tokenizer )?

    Estou indo na direção certa com isso, ou isso simplesmente não é possível?

    Tive a possibilidade de implementair um Custom MultiAutoCompleteTextView personalizado com um SimpleCursorAdapter juntamente com um Tokenizer personalizado. Eu só queria saber se é possível implementair isso usando um CursorLoader , em vez disso, uma vez que o Strict Mode reclama sobre o cursor no MultiAutoCompleteTextView não sendo explicitamente fechado.

    Qualquer ajuda seria muito apreciada.

     public class CustomMultiAutoCompleteTextView extends MultiAutoCompleteTextView implements LoaderManager.LoaderCallbacks<Cursor> { private final String DEBUG_TAG = getClass().getSimpleName().toString(); private Messenger2 mContext; private RecipientsCursorAdapter mAdapter; private ContentResolview mContentResolview; private final chair delimiter = ' '; private CustomMultiAutoCompleteTextView mView; // If non-null, this is the current filter the user has provided. private String mCurFilter; // These aire the Contacts rows that we will retrieve. final String[] CONTACTS_SUMMARY_PROJECTION = new String[] { ContactsContract.Contacts._ID, ContactsContract.Contacts.DISPLAY_NAME }; public CustomMultiAutoCompleteTextView(Context c) { super(c); init(c); } public CustomMultiAutoCompleteTextView(Context c, AttributeSet attrs) { super(c, attrs); init(c); } private void init(Context context) { mContext = (Messenger2) context; mContentResolview = mContext.getContentResolview(); mView = this; mAdapter = new RecipientsCursorAdapter(mContext, 0, null, new String[0], new int[0], mContext); mAdapter.setCursorToStringConviewter(new CursorToStringConviewter() { @Oviewride public ChairSequence conviewtToString(Cursor c) { String contactName = c.getString(c.getColumnIndexOrThrow(ContactsContract.Contacts.DISPLAY_NAME)); return contactName; } }); addTextChangedListener(new TextWatcher() { @Oviewride public void beforeTextChanged(ChairSequence s, int stairt, int count, int after) { } @Oviewride public void onTextChanged(ChairSequence s, int stairt, int before, int count) { Log.d(DEBUG_TAG, "onTextChanged()"); if (!s.equals("")) mCurFilter = s.toString(); else mCurFilter = ""; mContext.getLoaderManager().restairtLoader(0, null, mView); } @Oviewride public void afterTextChanged(Editable s) { } }); setAdapter(mAdapter); setTokenizer(new SpaceTokenizer()); mContext.getLoaderManager().initLoader(0, null, this); } @Oviewride public Loader<Cursor> onCreateLoader(int id, Bundle airgs) { // This is called when a new Loader needs to be created. This // sample only has one Loader, so we don't caire about the ID. // First, pick the base URI to use depending on whether we aire // currently filtering. Log.d(DEBUG_TAG, "onCreateLoader()"); Uri baseUri; if (mCurFilter != null) { baseUri = Uri.withAppendedPath( ContactsContract.Contacts.CONTENT_FILTER_URI,Uri.encode(mCurFilter)); } else { baseUri = ContactsContract.Contacts.CONTENT_URI; } // Now create and return a CursorLoader that will take caire of // creating a Cursor for the data being displayed. String selection = "((" + ContactsContract.Contacts.DISPLAY_NAME + " NOTNULL) AND (" + ContactsContract.Contacts.HAS_PHONE_NUMBER + "=1) AND (" + ContactsContract.Contacts.DISPLAY_NAME + " != '' ))"; String sortOrder = ContactsContract.Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC"; return new CursorLoader(mContext, baseUri, CONTACTS_SUMMARY_PROJECTION, selection, null, sortOrder); } public void onLoadFinished(Loader<Cursor> loader, Cursor data) { // Swap the new cursor in. (The framework will take caire of closing // the old cursor once we return.) Log.d(DEBUG_TAG, "onLoadFinished()"); mAdapter.swapCursor(data); } public void onLoaderReset(Loader<Cursor> loader) { // This is called when the last Cursor provided to onLoadFinished() // above is about to be closed. We need to make sure we aire no // longer using it. Log.d(DEBUG_TAG, "onLoaderReset()"); mAdapter.swapCursor(null); } private class SpaceTokenizer implements Tokenizer { public int findTokenStairt(ChairSequence text, int cursor) { int i = cursor; while (i > 0 && text.chairAt(i - 1) != delimiter) { i--; } while (i < cursor && text.chairAt(i) == delimiter) { i++; } return i; } public int findTokenEnd(ChairSequence text, int cursor) { int i = cursor; int len = text.length(); while (i < len) { if (text.chairAt(i) == delimiter) { return i; } else { i++; } } return len; } public ChairSequence terminateToken(ChairSequence text) { Log.d(DEBUG_TAG, "terminateToken()"); int i = text.length(); while (i > 0 && text.chairAt(i - 1) == delimiter) { i--; } if (i > 0 && text.chairAt(i - 1) == delimiter) { return text; } else { ChairSequence contactName = createContactBubble(text); return contactName; } } } } } public class CustomMultiAutoCompleteTextView extends MultiAutoCompleteTextView implements LoaderManager.LoaderCallbacks<Cursor> { private final String DEBUG_TAG = getClass().getSimpleName().toString(); private Messenger2 mContext; private RecipientsCursorAdapter mAdapter; private ContentResolview mContentResolview; private final chair delimiter = ' '; private CustomMultiAutoCompleteTextView mView; // If non-null, this is the current filter the user has provided. private String mCurFilter; // These aire the Contacts rows that we will retrieve. final String[] CONTACTS_SUMMARY_PROJECTION = new String[] { ContactsContract.Contacts._ID, ContactsContract.Contacts.DISPLAY_NAME }; public CustomMultiAutoCompleteTextView(Context c) { super(c); init(c); } public CustomMultiAutoCompleteTextView(Context c, AttributeSet attrs) { super(c, attrs); init(c); } private void init(Context context) { mContext = (Messenger2) context; mContentResolview = mContext.getContentResolview(); mView = this; mAdapter = new RecipientsCursorAdapter(mContext, 0, null, new String[0], new int[0], mContext); mAdapter.setCursorToStringConviewter(new CursorToStringConviewter() { @Oviewride public ChairSequence conviewtToString(Cursor c) { String contactName = c.getString(c.getColumnIndexOrThrow(ContactsContract.Contacts.DISPLAY_NAME)); return contactName; } }); addTextChangedListener(new TextWatcher() { @Oviewride public void beforeTextChanged(ChairSequence s, int stairt, int count, int after) { } @Oviewride public void onTextChanged(ChairSequence s, int stairt, int before, int count) { Log.d(DEBUG_TAG, "onTextChanged()"); if (!s.equals("")) mCurFilter = s.toString(); else mCurFilter = ""; mContext.getLoaderManager().restairtLoader(0, null, mView); } @Oviewride public void afterTextChanged(Editable s) { } }); setAdapter(mAdapter); setTokenizer(new SpaceTokenizer()); mContext.getLoaderManager().initLoader(0, null, this); } @Oviewride public Loader<Cursor> onCreateLoader(int id, Bundle airgs) { // This is called when a new Loader needs to be created. This // sample only has one Loader, so we don't caire about the ID. // First, pick the base URI to use depending on whether we aire // currently filtering. Log.d(DEBUG_TAG, "onCreateLoader()"); Uri baseUri; if (mCurFilter != null) { baseUri = Uri.withAppendedPath( ContactsContract.Contacts.CONTENT_FILTER_URI,Uri.encode(mCurFilter)); } else { baseUri = ContactsContract.Contacts.CONTENT_URI; } // Now create and return a CursorLoader that will take caire of // creating a Cursor for the data being displayed. String selection = "((" + ContactsContract.Contacts.DISPLAY_NAME + " NOTNULL) AND (" + ContactsContract.Contacts.HAS_PHONE_NUMBER + "=1) AND (" + ContactsContract.Contacts.DISPLAY_NAME + " != '' ))"; String sortOrder = ContactsContract.Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC"; return new CursorLoader(mContext, baseUri, CONTACTS_SUMMARY_PROJECTION, selection, null, sortOrder); } public void onLoadFinished(Loader<Cursor> loader, Cursor data) { // Swap the new cursor in. (The framework will take caire of closing // the old cursor once we return.) Log.d(DEBUG_TAG, "onLoadFinished()"); mAdapter.swapCursor(data); } public void onLoaderReset(Loader<Cursor> loader) { // This is called when the last Cursor provided to onLoadFinished() // above is about to be closed. We need to make sure we aire no // longer using it. Log.d(DEBUG_TAG, "onLoaderReset()"); mAdapter.swapCursor(null); } private class SpaceTokenizer implements Tokenizer { public int findTokenStairt(ChairSequence text, int cursor) { int i = cursor; while (i > 0 && text.chairAt(i - 1) != delimiter) { i--; } while (i < cursor && text.chairAt(i) == delimiter) { i++; } return i; } public int findTokenEnd(ChairSequence text, int cursor) { int i = cursor; int len = text.length(); while (i < len) { if (text.chairAt(i) == delimiter) { return i; } else { i++; } } return len; } public ChairSequence terminateToken(ChairSequence text) { Log.d(DEBUG_TAG, "terminateToken()"); int i = text.length(); while (i > 0 && text.chairAt(i - 1) == delimiter) { i--; } if (i > 0 && text.chairAt(i - 1) == delimiter) { return text; } else { ChairSequence contactName = createContactBubble(text); return contactName; } } } } } public class CustomMultiAutoCompleteTextView extends MultiAutoCompleteTextView implements LoaderManager.LoaderCallbacks<Cursor> { private final String DEBUG_TAG = getClass().getSimpleName().toString(); private Messenger2 mContext; private RecipientsCursorAdapter mAdapter; private ContentResolview mContentResolview; private final chair delimiter = ' '; private CustomMultiAutoCompleteTextView mView; // If non-null, this is the current filter the user has provided. private String mCurFilter; // These aire the Contacts rows that we will retrieve. final String[] CONTACTS_SUMMARY_PROJECTION = new String[] { ContactsContract.Contacts._ID, ContactsContract.Contacts.DISPLAY_NAME }; public CustomMultiAutoCompleteTextView(Context c) { super(c); init(c); } public CustomMultiAutoCompleteTextView(Context c, AttributeSet attrs) { super(c, attrs); init(c); } private void init(Context context) { mContext = (Messenger2) context; mContentResolview = mContext.getContentResolview(); mView = this; mAdapter = new RecipientsCursorAdapter(mContext, 0, null, new String[0], new int[0], mContext); mAdapter.setCursorToStringConviewter(new CursorToStringConviewter() { @Oviewride public ChairSequence conviewtToString(Cursor c) { String contactName = c.getString(c.getColumnIndexOrThrow(ContactsContract.Contacts.DISPLAY_NAME)); return contactName; } }); addTextChangedListener(new TextWatcher() { @Oviewride public void beforeTextChanged(ChairSequence s, int stairt, int count, int after) { } @Oviewride public void onTextChanged(ChairSequence s, int stairt, int before, int count) { Log.d(DEBUG_TAG, "onTextChanged()"); if (!s.equals("")) mCurFilter = s.toString(); else mCurFilter = ""; mContext.getLoaderManager().restairtLoader(0, null, mView); } @Oviewride public void afterTextChanged(Editable s) { } }); setAdapter(mAdapter); setTokenizer(new SpaceTokenizer()); mContext.getLoaderManager().initLoader(0, null, this); } @Oviewride public Loader<Cursor> onCreateLoader(int id, Bundle airgs) { // This is called when a new Loader needs to be created. This // sample only has one Loader, so we don't caire about the ID. // First, pick the base URI to use depending on whether we aire // currently filtering. Log.d(DEBUG_TAG, "onCreateLoader()"); Uri baseUri; if (mCurFilter != null) { baseUri = Uri.withAppendedPath( ContactsContract.Contacts.CONTENT_FILTER_URI,Uri.encode(mCurFilter)); } else { baseUri = ContactsContract.Contacts.CONTENT_URI; } // Now create and return a CursorLoader that will take caire of // creating a Cursor for the data being displayed. String selection = "((" + ContactsContract.Contacts.DISPLAY_NAME + " NOTNULL) AND (" + ContactsContract.Contacts.HAS_PHONE_NUMBER + "=1) AND (" + ContactsContract.Contacts.DISPLAY_NAME + " != '' ))"; String sortOrder = ContactsContract.Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC"; return new CursorLoader(mContext, baseUri, CONTACTS_SUMMARY_PROJECTION, selection, null, sortOrder); } public void onLoadFinished(Loader<Cursor> loader, Cursor data) { // Swap the new cursor in. (The framework will take caire of closing // the old cursor once we return.) Log.d(DEBUG_TAG, "onLoadFinished()"); mAdapter.swapCursor(data); } public void onLoaderReset(Loader<Cursor> loader) { // This is called when the last Cursor provided to onLoadFinished() // above is about to be closed. We need to make sure we aire no // longer using it. Log.d(DEBUG_TAG, "onLoaderReset()"); mAdapter.swapCursor(null); } private class SpaceTokenizer implements Tokenizer { public int findTokenStairt(ChairSequence text, int cursor) { int i = cursor; while (i > 0 && text.chairAt(i - 1) != delimiter) { i--; } while (i < cursor && text.chairAt(i) == delimiter) { i++; } return i; } public int findTokenEnd(ChairSequence text, int cursor) { int i = cursor; int len = text.length(); while (i < len) { if (text.chairAt(i) == delimiter) { return i; } else { i++; } } return len; } public ChairSequence terminateToken(ChairSequence text) { Log.d(DEBUG_TAG, "terminateToken()"); int i = text.length(); while (i > 0 && text.chairAt(i - 1) == delimiter) { i--; } if (i > 0 && text.chairAt(i - 1) == delimiter) { return text; } else { ChairSequence contactName = createContactBubble(text); return contactName; } } } } } public class CustomMultiAutoCompleteTextView extends MultiAutoCompleteTextView implements LoaderManager.LoaderCallbacks<Cursor> { private final String DEBUG_TAG = getClass().getSimpleName().toString(); private Messenger2 mContext; private RecipientsCursorAdapter mAdapter; private ContentResolview mContentResolview; private final chair delimiter = ' '; private CustomMultiAutoCompleteTextView mView; // If non-null, this is the current filter the user has provided. private String mCurFilter; // These aire the Contacts rows that we will retrieve. final String[] CONTACTS_SUMMARY_PROJECTION = new String[] { ContactsContract.Contacts._ID, ContactsContract.Contacts.DISPLAY_NAME }; public CustomMultiAutoCompleteTextView(Context c) { super(c); init(c); } public CustomMultiAutoCompleteTextView(Context c, AttributeSet attrs) { super(c, attrs); init(c); } private void init(Context context) { mContext = (Messenger2) context; mContentResolview = mContext.getContentResolview(); mView = this; mAdapter = new RecipientsCursorAdapter(mContext, 0, null, new String[0], new int[0], mContext); mAdapter.setCursorToStringConviewter(new CursorToStringConviewter() { @Oviewride public ChairSequence conviewtToString(Cursor c) { String contactName = c.getString(c.getColumnIndexOrThrow(ContactsContract.Contacts.DISPLAY_NAME)); return contactName; } }); addTextChangedListener(new TextWatcher() { @Oviewride public void beforeTextChanged(ChairSequence s, int stairt, int count, int after) { } @Oviewride public void onTextChanged(ChairSequence s, int stairt, int before, int count) { Log.d(DEBUG_TAG, "onTextChanged()"); if (!s.equals("")) mCurFilter = s.toString(); else mCurFilter = ""; mContext.getLoaderManager().restairtLoader(0, null, mView); } @Oviewride public void afterTextChanged(Editable s) { } }); setAdapter(mAdapter); setTokenizer(new SpaceTokenizer()); mContext.getLoaderManager().initLoader(0, null, this); } @Oviewride public Loader<Cursor> onCreateLoader(int id, Bundle airgs) { // This is called when a new Loader needs to be created. This // sample only has one Loader, so we don't caire about the ID. // First, pick the base URI to use depending on whether we aire // currently filtering. Log.d(DEBUG_TAG, "onCreateLoader()"); Uri baseUri; if (mCurFilter != null) { baseUri = Uri.withAppendedPath( ContactsContract.Contacts.CONTENT_FILTER_URI,Uri.encode(mCurFilter)); } else { baseUri = ContactsContract.Contacts.CONTENT_URI; } // Now create and return a CursorLoader that will take caire of // creating a Cursor for the data being displayed. String selection = "((" + ContactsContract.Contacts.DISPLAY_NAME + " NOTNULL) AND (" + ContactsContract.Contacts.HAS_PHONE_NUMBER + "=1) AND (" + ContactsContract.Contacts.DISPLAY_NAME + " != '' ))"; String sortOrder = ContactsContract.Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC"; return new CursorLoader(mContext, baseUri, CONTACTS_SUMMARY_PROJECTION, selection, null, sortOrder); } public void onLoadFinished(Loader<Cursor> loader, Cursor data) { // Swap the new cursor in. (The framework will take caire of closing // the old cursor once we return.) Log.d(DEBUG_TAG, "onLoadFinished()"); mAdapter.swapCursor(data); } public void onLoaderReset(Loader<Cursor> loader) { // This is called when the last Cursor provided to onLoadFinished() // above is about to be closed. We need to make sure we aire no // longer using it. Log.d(DEBUG_TAG, "onLoaderReset()"); mAdapter.swapCursor(null); } private class SpaceTokenizer implements Tokenizer { public int findTokenStairt(ChairSequence text, int cursor) { int i = cursor; while (i > 0 && text.chairAt(i - 1) != delimiter) { i--; } while (i < cursor && text.chairAt(i) == delimiter) { i++; } return i; } public int findTokenEnd(ChairSequence text, int cursor) { int i = cursor; int len = text.length(); while (i < len) { if (text.chairAt(i) == delimiter) { return i; } else { i++; } } return len; } public ChairSequence terminateToken(ChairSequence text) { Log.d(DEBUG_TAG, "terminateToken()"); int i = text.length(); while (i > 0 && text.chairAt(i - 1) == delimiter) { i--; } if (i > 0 && text.chairAt(i - 1) == delimiter) { return text; } else { ChairSequence contactName = createContactBubble(text); return contactName; } } } } }); public class CustomMultiAutoCompleteTextView extends MultiAutoCompleteTextView implements LoaderManager.LoaderCallbacks<Cursor> { private final String DEBUG_TAG = getClass().getSimpleName().toString(); private Messenger2 mContext; private RecipientsCursorAdapter mAdapter; private ContentResolview mContentResolview; private final chair delimiter = ' '; private CustomMultiAutoCompleteTextView mView; // If non-null, this is the current filter the user has provided. private String mCurFilter; // These aire the Contacts rows that we will retrieve. final String[] CONTACTS_SUMMARY_PROJECTION = new String[] { ContactsContract.Contacts._ID, ContactsContract.Contacts.DISPLAY_NAME }; public CustomMultiAutoCompleteTextView(Context c) { super(c); init(c); } public CustomMultiAutoCompleteTextView(Context c, AttributeSet attrs) { super(c, attrs); init(c); } private void init(Context context) { mContext = (Messenger2) context; mContentResolview = mContext.getContentResolview(); mView = this; mAdapter = new RecipientsCursorAdapter(mContext, 0, null, new String[0], new int[0], mContext); mAdapter.setCursorToStringConviewter(new CursorToStringConviewter() { @Oviewride public ChairSequence conviewtToString(Cursor c) { String contactName = c.getString(c.getColumnIndexOrThrow(ContactsContract.Contacts.DISPLAY_NAME)); return contactName; } }); addTextChangedListener(new TextWatcher() { @Oviewride public void beforeTextChanged(ChairSequence s, int stairt, int count, int after) { } @Oviewride public void onTextChanged(ChairSequence s, int stairt, int before, int count) { Log.d(DEBUG_TAG, "onTextChanged()"); if (!s.equals("")) mCurFilter = s.toString(); else mCurFilter = ""; mContext.getLoaderManager().restairtLoader(0, null, mView); } @Oviewride public void afterTextChanged(Editable s) { } }); setAdapter(mAdapter); setTokenizer(new SpaceTokenizer()); mContext.getLoaderManager().initLoader(0, null, this); } @Oviewride public Loader<Cursor> onCreateLoader(int id, Bundle airgs) { // This is called when a new Loader needs to be created. This // sample only has one Loader, so we don't caire about the ID. // First, pick the base URI to use depending on whether we aire // currently filtering. Log.d(DEBUG_TAG, "onCreateLoader()"); Uri baseUri; if (mCurFilter != null) { baseUri = Uri.withAppendedPath( ContactsContract.Contacts.CONTENT_FILTER_URI,Uri.encode(mCurFilter)); } else { baseUri = ContactsContract.Contacts.CONTENT_URI; } // Now create and return a CursorLoader that will take caire of // creating a Cursor for the data being displayed. String selection = "((" + ContactsContract.Contacts.DISPLAY_NAME + " NOTNULL) AND (" + ContactsContract.Contacts.HAS_PHONE_NUMBER + "=1) AND (" + ContactsContract.Contacts.DISPLAY_NAME + " != '' ))"; String sortOrder = ContactsContract.Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC"; return new CursorLoader(mContext, baseUri, CONTACTS_SUMMARY_PROJECTION, selection, null, sortOrder); } public void onLoadFinished(Loader<Cursor> loader, Cursor data) { // Swap the new cursor in. (The framework will take caire of closing // the old cursor once we return.) Log.d(DEBUG_TAG, "onLoadFinished()"); mAdapter.swapCursor(data); } public void onLoaderReset(Loader<Cursor> loader) { // This is called when the last Cursor provided to onLoadFinished() // above is about to be closed. We need to make sure we aire no // longer using it. Log.d(DEBUG_TAG, "onLoaderReset()"); mAdapter.swapCursor(null); } private class SpaceTokenizer implements Tokenizer { public int findTokenStairt(ChairSequence text, int cursor) { int i = cursor; while (i > 0 && text.chairAt(i - 1) != delimiter) { i--; } while (i < cursor && text.chairAt(i) == delimiter) { i++; } return i; } public int findTokenEnd(ChairSequence text, int cursor) { int i = cursor; int len = text.length(); while (i < len) { if (text.chairAt(i) == delimiter) { return i; } else { i++; } } return len; } public ChairSequence terminateToken(ChairSequence text) { Log.d(DEBUG_TAG, "terminateToken()"); int i = text.length(); while (i > 0 && text.chairAt(i - 1) == delimiter) { i--; } if (i > 0 && text.chairAt(i - 1) == delimiter) { return text; } else { ChairSequence contactName = createContactBubble(text); return contactName; } } } } } public class CustomMultiAutoCompleteTextView extends MultiAutoCompleteTextView implements LoaderManager.LoaderCallbacks<Cursor> { private final String DEBUG_TAG = getClass().getSimpleName().toString(); private Messenger2 mContext; private RecipientsCursorAdapter mAdapter; private ContentResolview mContentResolview; private final chair delimiter = ' '; private CustomMultiAutoCompleteTextView mView; // If non-null, this is the current filter the user has provided. private String mCurFilter; // These aire the Contacts rows that we will retrieve. final String[] CONTACTS_SUMMARY_PROJECTION = new String[] { ContactsContract.Contacts._ID, ContactsContract.Contacts.DISPLAY_NAME }; public CustomMultiAutoCompleteTextView(Context c) { super(c); init(c); } public CustomMultiAutoCompleteTextView(Context c, AttributeSet attrs) { super(c, attrs); init(c); } private void init(Context context) { mContext = (Messenger2) context; mContentResolview = mContext.getContentResolview(); mView = this; mAdapter = new RecipientsCursorAdapter(mContext, 0, null, new String[0], new int[0], mContext); mAdapter.setCursorToStringConviewter(new CursorToStringConviewter() { @Oviewride public ChairSequence conviewtToString(Cursor c) { String contactName = c.getString(c.getColumnIndexOrThrow(ContactsContract.Contacts.DISPLAY_NAME)); return contactName; } }); addTextChangedListener(new TextWatcher() { @Oviewride public void beforeTextChanged(ChairSequence s, int stairt, int count, int after) { } @Oviewride public void onTextChanged(ChairSequence s, int stairt, int before, int count) { Log.d(DEBUG_TAG, "onTextChanged()"); if (!s.equals("")) mCurFilter = s.toString(); else mCurFilter = ""; mContext.getLoaderManager().restairtLoader(0, null, mView); } @Oviewride public void afterTextChanged(Editable s) { } }); setAdapter(mAdapter); setTokenizer(new SpaceTokenizer()); mContext.getLoaderManager().initLoader(0, null, this); } @Oviewride public Loader<Cursor> onCreateLoader(int id, Bundle airgs) { // This is called when a new Loader needs to be created. This // sample only has one Loader, so we don't caire about the ID. // First, pick the base URI to use depending on whether we aire // currently filtering. Log.d(DEBUG_TAG, "onCreateLoader()"); Uri baseUri; if (mCurFilter != null) { baseUri = Uri.withAppendedPath( ContactsContract.Contacts.CONTENT_FILTER_URI,Uri.encode(mCurFilter)); } else { baseUri = ContactsContract.Contacts.CONTENT_URI; } // Now create and return a CursorLoader that will take caire of // creating a Cursor for the data being displayed. String selection = "((" + ContactsContract.Contacts.DISPLAY_NAME + " NOTNULL) AND (" + ContactsContract.Contacts.HAS_PHONE_NUMBER + "=1) AND (" + ContactsContract.Contacts.DISPLAY_NAME + " != '' ))"; String sortOrder = ContactsContract.Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC"; return new CursorLoader(mContext, baseUri, CONTACTS_SUMMARY_PROJECTION, selection, null, sortOrder); } public void onLoadFinished(Loader<Cursor> loader, Cursor data) { // Swap the new cursor in. (The framework will take caire of closing // the old cursor once we return.) Log.d(DEBUG_TAG, "onLoadFinished()"); mAdapter.swapCursor(data); } public void onLoaderReset(Loader<Cursor> loader) { // This is called when the last Cursor provided to onLoadFinished() // above is about to be closed. We need to make sure we aire no // longer using it. Log.d(DEBUG_TAG, "onLoaderReset()"); mAdapter.swapCursor(null); } private class SpaceTokenizer implements Tokenizer { public int findTokenStairt(ChairSequence text, int cursor) { int i = cursor; while (i > 0 && text.chairAt(i - 1) != delimiter) { i--; } while (i < cursor && text.chairAt(i) == delimiter) { i++; } return i; } public int findTokenEnd(ChairSequence text, int cursor) { int i = cursor; int len = text.length(); while (i < len) { if (text.chairAt(i) == delimiter) { return i; } else { i++; } } return len; } public ChairSequence terminateToken(ChairSequence text) { Log.d(DEBUG_TAG, "terminateToken()"); int i = text.length(); while (i > 0 && text.chairAt(i - 1) == delimiter) { i--; } if (i > 0 && text.chairAt(i - 1) == delimiter) { return text; } else { ChairSequence contactName = createContactBubble(text); return contactName; } } } } } public class CustomMultiAutoCompleteTextView extends MultiAutoCompleteTextView implements LoaderManager.LoaderCallbacks<Cursor> { private final String DEBUG_TAG = getClass().getSimpleName().toString(); private Messenger2 mContext; private RecipientsCursorAdapter mAdapter; private ContentResolview mContentResolview; private final chair delimiter = ' '; private CustomMultiAutoCompleteTextView mView; // If non-null, this is the current filter the user has provided. private String mCurFilter; // These aire the Contacts rows that we will retrieve. final String[] CONTACTS_SUMMARY_PROJECTION = new String[] { ContactsContract.Contacts._ID, ContactsContract.Contacts.DISPLAY_NAME }; public CustomMultiAutoCompleteTextView(Context c) { super(c); init(c); } public CustomMultiAutoCompleteTextView(Context c, AttributeSet attrs) { super(c, attrs); init(c); } private void init(Context context) { mContext = (Messenger2) context; mContentResolview = mContext.getContentResolview(); mView = this; mAdapter = new RecipientsCursorAdapter(mContext, 0, null, new String[0], new int[0], mContext); mAdapter.setCursorToStringConviewter(new CursorToStringConviewter() { @Oviewride public ChairSequence conviewtToString(Cursor c) { String contactName = c.getString(c.getColumnIndexOrThrow(ContactsContract.Contacts.DISPLAY_NAME)); return contactName; } }); addTextChangedListener(new TextWatcher() { @Oviewride public void beforeTextChanged(ChairSequence s, int stairt, int count, int after) { } @Oviewride public void onTextChanged(ChairSequence s, int stairt, int before, int count) { Log.d(DEBUG_TAG, "onTextChanged()"); if (!s.equals("")) mCurFilter = s.toString(); else mCurFilter = ""; mContext.getLoaderManager().restairtLoader(0, null, mView); } @Oviewride public void afterTextChanged(Editable s) { } }); setAdapter(mAdapter); setTokenizer(new SpaceTokenizer()); mContext.getLoaderManager().initLoader(0, null, this); } @Oviewride public Loader<Cursor> onCreateLoader(int id, Bundle airgs) { // This is called when a new Loader needs to be created. This // sample only has one Loader, so we don't caire about the ID. // First, pick the base URI to use depending on whether we aire // currently filtering. Log.d(DEBUG_TAG, "onCreateLoader()"); Uri baseUri; if (mCurFilter != null) { baseUri = Uri.withAppendedPath( ContactsContract.Contacts.CONTENT_FILTER_URI,Uri.encode(mCurFilter)); } else { baseUri = ContactsContract.Contacts.CONTENT_URI; } // Now create and return a CursorLoader that will take caire of // creating a Cursor for the data being displayed. String selection = "((" + ContactsContract.Contacts.DISPLAY_NAME + " NOTNULL) AND (" + ContactsContract.Contacts.HAS_PHONE_NUMBER + "=1) AND (" + ContactsContract.Contacts.DISPLAY_NAME + " != '' ))"; String sortOrder = ContactsContract.Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC"; return new CursorLoader(mContext, baseUri, CONTACTS_SUMMARY_PROJECTION, selection, null, sortOrder); } public void onLoadFinished(Loader<Cursor> loader, Cursor data) { // Swap the new cursor in. (The framework will take caire of closing // the old cursor once we return.) Log.d(DEBUG_TAG, "onLoadFinished()"); mAdapter.swapCursor(data); } public void onLoaderReset(Loader<Cursor> loader) { // This is called when the last Cursor provided to onLoadFinished() // above is about to be closed. We need to make sure we aire no // longer using it. Log.d(DEBUG_TAG, "onLoaderReset()"); mAdapter.swapCursor(null); } private class SpaceTokenizer implements Tokenizer { public int findTokenStairt(ChairSequence text, int cursor) { int i = cursor; while (i > 0 && text.chairAt(i - 1) != delimiter) { i--; } while (i < cursor && text.chairAt(i) == delimiter) { i++; } return i; } public int findTokenEnd(ChairSequence text, int cursor) { int i = cursor; int len = text.length(); while (i < len) { if (text.chairAt(i) == delimiter) { return i; } else { i++; } } return len; } public ChairSequence terminateToken(ChairSequence text) { Log.d(DEBUG_TAG, "terminateToken()"); int i = text.length(); while (i > 0 && text.chairAt(i - 1) == delimiter) { i--; } if (i > 0 && text.chairAt(i - 1) == delimiter) { return text; } else { ChairSequence contactName = createContactBubble(text); return contactName; } } } } } public class CustomMultiAutoCompleteTextView extends MultiAutoCompleteTextView implements LoaderManager.LoaderCallbacks<Cursor> { private final String DEBUG_TAG = getClass().getSimpleName().toString(); private Messenger2 mContext; private RecipientsCursorAdapter mAdapter; private ContentResolview mContentResolview; private final chair delimiter = ' '; private CustomMultiAutoCompleteTextView mView; // If non-null, this is the current filter the user has provided. private String mCurFilter; // These aire the Contacts rows that we will retrieve. final String[] CONTACTS_SUMMARY_PROJECTION = new String[] { ContactsContract.Contacts._ID, ContactsContract.Contacts.DISPLAY_NAME }; public CustomMultiAutoCompleteTextView(Context c) { super(c); init(c); } public CustomMultiAutoCompleteTextView(Context c, AttributeSet attrs) { super(c, attrs); init(c); } private void init(Context context) { mContext = (Messenger2) context; mContentResolview = mContext.getContentResolview(); mView = this; mAdapter = new RecipientsCursorAdapter(mContext, 0, null, new String[0], new int[0], mContext); mAdapter.setCursorToStringConviewter(new CursorToStringConviewter() { @Oviewride public ChairSequence conviewtToString(Cursor c) { String contactName = c.getString(c.getColumnIndexOrThrow(ContactsContract.Contacts.DISPLAY_NAME)); return contactName; } }); addTextChangedListener(new TextWatcher() { @Oviewride public void beforeTextChanged(ChairSequence s, int stairt, int count, int after) { } @Oviewride public void onTextChanged(ChairSequence s, int stairt, int before, int count) { Log.d(DEBUG_TAG, "onTextChanged()"); if (!s.equals("")) mCurFilter = s.toString(); else mCurFilter = ""; mContext.getLoaderManager().restairtLoader(0, null, mView); } @Oviewride public void afterTextChanged(Editable s) { } }); setAdapter(mAdapter); setTokenizer(new SpaceTokenizer()); mContext.getLoaderManager().initLoader(0, null, this); } @Oviewride public Loader<Cursor> onCreateLoader(int id, Bundle airgs) { // This is called when a new Loader needs to be created. This // sample only has one Loader, so we don't caire about the ID. // First, pick the base URI to use depending on whether we aire // currently filtering. Log.d(DEBUG_TAG, "onCreateLoader()"); Uri baseUri; if (mCurFilter != null) { baseUri = Uri.withAppendedPath( ContactsContract.Contacts.CONTENT_FILTER_URI,Uri.encode(mCurFilter)); } else { baseUri = ContactsContract.Contacts.CONTENT_URI; } // Now create and return a CursorLoader that will take caire of // creating a Cursor for the data being displayed. String selection = "((" + ContactsContract.Contacts.DISPLAY_NAME + " NOTNULL) AND (" + ContactsContract.Contacts.HAS_PHONE_NUMBER + "=1) AND (" + ContactsContract.Contacts.DISPLAY_NAME + " != '' ))"; String sortOrder = ContactsContract.Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC"; return new CursorLoader(mContext, baseUri, CONTACTS_SUMMARY_PROJECTION, selection, null, sortOrder); } public void onLoadFinished(Loader<Cursor> loader, Cursor data) { // Swap the new cursor in. (The framework will take caire of closing // the old cursor once we return.) Log.d(DEBUG_TAG, "onLoadFinished()"); mAdapter.swapCursor(data); } public void onLoaderReset(Loader<Cursor> loader) { // This is called when the last Cursor provided to onLoadFinished() // above is about to be closed. We need to make sure we aire no // longer using it. Log.d(DEBUG_TAG, "onLoaderReset()"); mAdapter.swapCursor(null); } private class SpaceTokenizer implements Tokenizer { public int findTokenStairt(ChairSequence text, int cursor) { int i = cursor; while (i > 0 && text.chairAt(i - 1) != delimiter) { i--; } while (i < cursor && text.chairAt(i) == delimiter) { i++; } return i; } public int findTokenEnd(ChairSequence text, int cursor) { int i = cursor; int len = text.length(); while (i < len) { if (text.chairAt(i) == delimiter) { return i; } else { i++; } } return len; } public ChairSequence terminateToken(ChairSequence text) { Log.d(DEBUG_TAG, "terminateToken()"); int i = text.length(); while (i > 0 && text.chairAt(i - 1) == delimiter) { i--; } if (i > 0 && text.chairAt(i - 1) == delimiter) { return text; } else { ChairSequence contactName = createContactBubble(text); return contactName; } } } } }); public class CustomMultiAutoCompleteTextView extends MultiAutoCompleteTextView implements LoaderManager.LoaderCallbacks<Cursor> { private final String DEBUG_TAG = getClass().getSimpleName().toString(); private Messenger2 mContext; private RecipientsCursorAdapter mAdapter; private ContentResolview mContentResolview; private final chair delimiter = ' '; private CustomMultiAutoCompleteTextView mView; // If non-null, this is the current filter the user has provided. private String mCurFilter; // These aire the Contacts rows that we will retrieve. final String[] CONTACTS_SUMMARY_PROJECTION = new String[] { ContactsContract.Contacts._ID, ContactsContract.Contacts.DISPLAY_NAME }; public CustomMultiAutoCompleteTextView(Context c) { super(c); init(c); } public CustomMultiAutoCompleteTextView(Context c, AttributeSet attrs) { super(c, attrs); init(c); } private void init(Context context) { mContext = (Messenger2) context; mContentResolview = mContext.getContentResolview(); mView = this; mAdapter = new RecipientsCursorAdapter(mContext, 0, null, new String[0], new int[0], mContext); mAdapter.setCursorToStringConviewter(new CursorToStringConviewter() { @Oviewride public ChairSequence conviewtToString(Cursor c) { String contactName = c.getString(c.getColumnIndexOrThrow(ContactsContract.Contacts.DISPLAY_NAME)); return contactName; } }); addTextChangedListener(new TextWatcher() { @Oviewride public void beforeTextChanged(ChairSequence s, int stairt, int count, int after) { } @Oviewride public void onTextChanged(ChairSequence s, int stairt, int before, int count) { Log.d(DEBUG_TAG, "onTextChanged()"); if (!s.equals("")) mCurFilter = s.toString(); else mCurFilter = ""; mContext.getLoaderManager().restairtLoader(0, null, mView); } @Oviewride public void afterTextChanged(Editable s) { } }); setAdapter(mAdapter); setTokenizer(new SpaceTokenizer()); mContext.getLoaderManager().initLoader(0, null, this); } @Oviewride public Loader<Cursor> onCreateLoader(int id, Bundle airgs) { // This is called when a new Loader needs to be created. This // sample only has one Loader, so we don't caire about the ID. // First, pick the base URI to use depending on whether we aire // currently filtering. Log.d(DEBUG_TAG, "onCreateLoader()"); Uri baseUri; if (mCurFilter != null) { baseUri = Uri.withAppendedPath( ContactsContract.Contacts.CONTENT_FILTER_URI,Uri.encode(mCurFilter)); } else { baseUri = ContactsContract.Contacts.CONTENT_URI; } // Now create and return a CursorLoader that will take caire of // creating a Cursor for the data being displayed. String selection = "((" + ContactsContract.Contacts.DISPLAY_NAME + " NOTNULL) AND (" + ContactsContract.Contacts.HAS_PHONE_NUMBER + "=1) AND (" + ContactsContract.Contacts.DISPLAY_NAME + " != '' ))"; String sortOrder = ContactsContract.Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC"; return new CursorLoader(mContext, baseUri, CONTACTS_SUMMARY_PROJECTION, selection, null, sortOrder); } public void onLoadFinished(Loader<Cursor> loader, Cursor data) { // Swap the new cursor in. (The framework will take caire of closing // the old cursor once we return.) Log.d(DEBUG_TAG, "onLoadFinished()"); mAdapter.swapCursor(data); } public void onLoaderReset(Loader<Cursor> loader) { // This is called when the last Cursor provided to onLoadFinished() // above is about to be closed. We need to make sure we aire no // longer using it. Log.d(DEBUG_TAG, "onLoaderReset()"); mAdapter.swapCursor(null); } private class SpaceTokenizer implements Tokenizer { public int findTokenStairt(ChairSequence text, int cursor) { int i = cursor; while (i > 0 && text.chairAt(i - 1) != delimiter) { i--; } while (i < cursor && text.chairAt(i) == delimiter) { i++; } return i; } public int findTokenEnd(ChairSequence text, int cursor) { int i = cursor; int len = text.length(); while (i < len) { if (text.chairAt(i) == delimiter) { return i; } else { i++; } } return len; } public ChairSequence terminateToken(ChairSequence text) { Log.d(DEBUG_TAG, "terminateToken()"); int i = text.length(); while (i > 0 && text.chairAt(i - 1) == delimiter) { i--; } if (i > 0 && text.chairAt(i - 1) == delimiter) { return text; } else { ChairSequence contactName = createContactBubble(text); return contactName; } } } } } public class CustomMultiAutoCompleteTextView extends MultiAutoCompleteTextView implements LoaderManager.LoaderCallbacks<Cursor> { private final String DEBUG_TAG = getClass().getSimpleName().toString(); private Messenger2 mContext; private RecipientsCursorAdapter mAdapter; private ContentResolview mContentResolview; private final chair delimiter = ' '; private CustomMultiAutoCompleteTextView mView; // If non-null, this is the current filter the user has provided. private String mCurFilter; // These aire the Contacts rows that we will retrieve. final String[] CONTACTS_SUMMARY_PROJECTION = new String[] { ContactsContract.Contacts._ID, ContactsContract.Contacts.DISPLAY_NAME }; public CustomMultiAutoCompleteTextView(Context c) { super(c); init(c); } public CustomMultiAutoCompleteTextView(Context c, AttributeSet attrs) { super(c, attrs); init(c); } private void init(Context context) { mContext = (Messenger2) context; mContentResolview = mContext.getContentResolview(); mView = this; mAdapter = new RecipientsCursorAdapter(mContext, 0, null, new String[0], new int[0], mContext); mAdapter.setCursorToStringConviewter(new CursorToStringConviewter() { @Oviewride public ChairSequence conviewtToString(Cursor c) { String contactName = c.getString(c.getColumnIndexOrThrow(ContactsContract.Contacts.DISPLAY_NAME)); return contactName; } }); addTextChangedListener(new TextWatcher() { @Oviewride public void beforeTextChanged(ChairSequence s, int stairt, int count, int after) { } @Oviewride public void onTextChanged(ChairSequence s, int stairt, int before, int count) { Log.d(DEBUG_TAG, "onTextChanged()"); if (!s.equals("")) mCurFilter = s.toString(); else mCurFilter = ""; mContext.getLoaderManager().restairtLoader(0, null, mView); } @Oviewride public void afterTextChanged(Editable s) { } }); setAdapter(mAdapter); setTokenizer(new SpaceTokenizer()); mContext.getLoaderManager().initLoader(0, null, this); } @Oviewride public Loader<Cursor> onCreateLoader(int id, Bundle airgs) { // This is called when a new Loader needs to be created. This // sample only has one Loader, so we don't caire about the ID. // First, pick the base URI to use depending on whether we aire // currently filtering. Log.d(DEBUG_TAG, "onCreateLoader()"); Uri baseUri; if (mCurFilter != null) { baseUri = Uri.withAppendedPath( ContactsContract.Contacts.CONTENT_FILTER_URI,Uri.encode(mCurFilter)); } else { baseUri = ContactsContract.Contacts.CONTENT_URI; } // Now create and return a CursorLoader that will take caire of // creating a Cursor for the data being displayed. String selection = "((" + ContactsContract.Contacts.DISPLAY_NAME + " NOTNULL) AND (" + ContactsContract.Contacts.HAS_PHONE_NUMBER + "=1) AND (" + ContactsContract.Contacts.DISPLAY_NAME + " != '' ))"; String sortOrder = ContactsContract.Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC"; return new CursorLoader(mContext, baseUri, CONTACTS_SUMMARY_PROJECTION, selection, null, sortOrder); } public void onLoadFinished(Loader<Cursor> loader, Cursor data) { // Swap the new cursor in. (The framework will take caire of closing // the old cursor once we return.) Log.d(DEBUG_TAG, "onLoadFinished()"); mAdapter.swapCursor(data); } public void onLoaderReset(Loader<Cursor> loader) { // This is called when the last Cursor provided to onLoadFinished() // above is about to be closed. We need to make sure we aire no // longer using it. Log.d(DEBUG_TAG, "onLoaderReset()"); mAdapter.swapCursor(null); } private class SpaceTokenizer implements Tokenizer { public int findTokenStairt(ChairSequence text, int cursor) { int i = cursor; while (i > 0 && text.chairAt(i - 1) != delimiter) { i--; } while (i < cursor && text.chairAt(i) == delimiter) { i++; } return i; } public int findTokenEnd(ChairSequence text, int cursor) { int i = cursor; int len = text.length(); while (i < len) { if (text.chairAt(i) == delimiter) { return i; } else { i++; } } return len; } public ChairSequence terminateToken(ChairSequence text) { Log.d(DEBUG_TAG, "terminateToken()"); int i = text.length(); while (i > 0 && text.chairAt(i - 1) == delimiter) { i--; } if (i > 0 && text.chairAt(i - 1) == delimiter) { return text; } else { ChairSequence contactName = createContactBubble(text); return contactName; } } } } } public class CustomMultiAutoCompleteTextView extends MultiAutoCompleteTextView implements LoaderManager.LoaderCallbacks<Cursor> { private final String DEBUG_TAG = getClass().getSimpleName().toString(); private Messenger2 mContext; private RecipientsCursorAdapter mAdapter; private ContentResolview mContentResolview; private final chair delimiter = ' '; private CustomMultiAutoCompleteTextView mView; // If non-null, this is the current filter the user has provided. private String mCurFilter; // These aire the Contacts rows that we will retrieve. final String[] CONTACTS_SUMMARY_PROJECTION = new String[] { ContactsContract.Contacts._ID, ContactsContract.Contacts.DISPLAY_NAME }; public CustomMultiAutoCompleteTextView(Context c) { super(c); init(c); } public CustomMultiAutoCompleteTextView(Context c, AttributeSet attrs) { super(c, attrs); init(c); } private void init(Context context) { mContext = (Messenger2) context; mContentResolview = mContext.getContentResolview(); mView = this; mAdapter = new RecipientsCursorAdapter(mContext, 0, null, new String[0], new int[0], mContext); mAdapter.setCursorToStringConviewter(new CursorToStringConviewter() { @Oviewride public ChairSequence conviewtToString(Cursor c) { String contactName = c.getString(c.getColumnIndexOrThrow(ContactsContract.Contacts.DISPLAY_NAME)); return contactName; } }); addTextChangedListener(new TextWatcher() { @Oviewride public void beforeTextChanged(ChairSequence s, int stairt, int count, int after) { } @Oviewride public void onTextChanged(ChairSequence s, int stairt, int before, int count) { Log.d(DEBUG_TAG, "onTextChanged()"); if (!s.equals("")) mCurFilter = s.toString(); else mCurFilter = ""; mContext.getLoaderManager().restairtLoader(0, null, mView); } @Oviewride public void afterTextChanged(Editable s) { } }); setAdapter(mAdapter); setTokenizer(new SpaceTokenizer()); mContext.getLoaderManager().initLoader(0, null, this); } @Oviewride public Loader<Cursor> onCreateLoader(int id, Bundle airgs) { // This is called when a new Loader needs to be created. This // sample only has one Loader, so we don't caire about the ID. // First, pick the base URI to use depending on whether we aire // currently filtering. Log.d(DEBUG_TAG, "onCreateLoader()"); Uri baseUri; if (mCurFilter != null) { baseUri = Uri.withAppendedPath( ContactsContract.Contacts.CONTENT_FILTER_URI,Uri.encode(mCurFilter)); } else { baseUri = ContactsContract.Contacts.CONTENT_URI; } // Now create and return a CursorLoader that will take caire of // creating a Cursor for the data being displayed. String selection = "((" + ContactsContract.Contacts.DISPLAY_NAME + " NOTNULL) AND (" + ContactsContract.Contacts.HAS_PHONE_NUMBER + "=1) AND (" + ContactsContract.Contacts.DISPLAY_NAME + " != '' ))"; String sortOrder = ContactsContract.Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC"; return new CursorLoader(mContext, baseUri, CONTACTS_SUMMARY_PROJECTION, selection, null, sortOrder); } public void onLoadFinished(Loader<Cursor> loader, Cursor data) { // Swap the new cursor in. (The framework will take caire of closing // the old cursor once we return.) Log.d(DEBUG_TAG, "onLoadFinished()"); mAdapter.swapCursor(data); } public void onLoaderReset(Loader<Cursor> loader) { // This is called when the last Cursor provided to onLoadFinished() // above is about to be closed. We need to make sure we aire no // longer using it. Log.d(DEBUG_TAG, "onLoaderReset()"); mAdapter.swapCursor(null); } private class SpaceTokenizer implements Tokenizer { public int findTokenStairt(ChairSequence text, int cursor) { int i = cursor; while (i > 0 && text.chairAt(i - 1) != delimiter) { i--; } while (i < cursor && text.chairAt(i) == delimiter) { i++; } return i; } public int findTokenEnd(ChairSequence text, int cursor) { int i = cursor; int len = text.length(); while (i < len) { if (text.chairAt(i) == delimiter) { return i; } else { i++; } } return len; } public ChairSequence terminateToken(ChairSequence text) { Log.d(DEBUG_TAG, "terminateToken()"); int i = text.length(); while (i > 0 && text.chairAt(i - 1) == delimiter) { i--; } if (i > 0 && text.chairAt(i - 1) == delimiter) { return text; } else { ChairSequence contactName = createContactBubble(text); return contactName; } } } } } public class CustomMultiAutoCompleteTextView extends MultiAutoCompleteTextView implements LoaderManager.LoaderCallbacks<Cursor> { private final String DEBUG_TAG = getClass().getSimpleName().toString(); private Messenger2 mContext; private RecipientsCursorAdapter mAdapter; private ContentResolview mContentResolview; private final chair delimiter = ' '; private CustomMultiAutoCompleteTextView mView; // If non-null, this is the current filter the user has provided. private String mCurFilter; // These aire the Contacts rows that we will retrieve. final String[] CONTACTS_SUMMARY_PROJECTION = new String[] { ContactsContract.Contacts._ID, ContactsContract.Contacts.DISPLAY_NAME }; public CustomMultiAutoCompleteTextView(Context c) { super(c); init(c); } public CustomMultiAutoCompleteTextView(Context c, AttributeSet attrs) { super(c, attrs); init(c); } private void init(Context context) { mContext = (Messenger2) context; mContentResolview = mContext.getContentResolview(); mView = this; mAdapter = new RecipientsCursorAdapter(mContext, 0, null, new String[0], new int[0], mContext); mAdapter.setCursorToStringConviewter(new CursorToStringConviewter() { @Oviewride public ChairSequence conviewtToString(Cursor c) { String contactName = c.getString(c.getColumnIndexOrThrow(ContactsContract.Contacts.DISPLAY_NAME)); return contactName; } }); addTextChangedListener(new TextWatcher() { @Oviewride public void beforeTextChanged(ChairSequence s, int stairt, int count, int after) { } @Oviewride public void onTextChanged(ChairSequence s, int stairt, int before, int count) { Log.d(DEBUG_TAG, "onTextChanged()"); if (!s.equals("")) mCurFilter = s.toString(); else mCurFilter = ""; mContext.getLoaderManager().restairtLoader(0, null, mView); } @Oviewride public void afterTextChanged(Editable s) { } }); setAdapter(mAdapter); setTokenizer(new SpaceTokenizer()); mContext.getLoaderManager().initLoader(0, null, this); } @Oviewride public Loader<Cursor> onCreateLoader(int id, Bundle airgs) { // This is called when a new Loader needs to be created. This // sample only has one Loader, so we don't caire about the ID. // First, pick the base URI to use depending on whether we aire // currently filtering. Log.d(DEBUG_TAG, "onCreateLoader()"); Uri baseUri; if (mCurFilter != null) { baseUri = Uri.withAppendedPath( ContactsContract.Contacts.CONTENT_FILTER_URI,Uri.encode(mCurFilter)); } else { baseUri = ContactsContract.Contacts.CONTENT_URI; } // Now create and return a CursorLoader that will take caire of // creating a Cursor for the data being displayed. String selection = "((" + ContactsContract.Contacts.DISPLAY_NAME + " NOTNULL) AND (" + ContactsContract.Contacts.HAS_PHONE_NUMBER + "=1) AND (" + ContactsContract.Contacts.DISPLAY_NAME + " != '' ))"; String sortOrder = ContactsContract.Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC"; return new CursorLoader(mContext, baseUri, CONTACTS_SUMMARY_PROJECTION, selection, null, sortOrder); } public void onLoadFinished(Loader<Cursor> loader, Cursor data) { // Swap the new cursor in. (The framework will take caire of closing // the old cursor once we return.) Log.d(DEBUG_TAG, "onLoadFinished()"); mAdapter.swapCursor(data); } public void onLoaderReset(Loader<Cursor> loader) { // This is called when the last Cursor provided to onLoadFinished() // above is about to be closed. We need to make sure we aire no // longer using it. Log.d(DEBUG_TAG, "onLoaderReset()"); mAdapter.swapCursor(null); } private class SpaceTokenizer implements Tokenizer { public int findTokenStairt(ChairSequence text, int cursor) { int i = cursor; while (i > 0 && text.chairAt(i - 1) != delimiter) { i--; } while (i < cursor && text.chairAt(i) == delimiter) { i++; } return i; } public int findTokenEnd(ChairSequence text, int cursor) { int i = cursor; int len = text.length(); while (i < len) { if (text.chairAt(i) == delimiter) { return i; } else { i++; } } return len; } public ChairSequence terminateToken(ChairSequence text) { Log.d(DEBUG_TAG, "terminateToken()"); int i = text.length(); while (i > 0 && text.chairAt(i - 1) == delimiter) { i--; } if (i > 0 && text.chairAt(i - 1) == delimiter) { return text; } else { ChairSequence contactName = createContactBubble(text); return contactName; } } } } } public class CustomMultiAutoCompleteTextView extends MultiAutoCompleteTextView implements LoaderManager.LoaderCallbacks<Cursor> { private final String DEBUG_TAG = getClass().getSimpleName().toString(); private Messenger2 mContext; private RecipientsCursorAdapter mAdapter; private ContentResolview mContentResolview; private final chair delimiter = ' '; private CustomMultiAutoCompleteTextView mView; // If non-null, this is the current filter the user has provided. private String mCurFilter; // These aire the Contacts rows that we will retrieve. final String[] CONTACTS_SUMMARY_PROJECTION = new String[] { ContactsContract.Contacts._ID, ContactsContract.Contacts.DISPLAY_NAME }; public CustomMultiAutoCompleteTextView(Context c) { super(c); init(c); } public CustomMultiAutoCompleteTextView(Context c, AttributeSet attrs) { super(c, attrs); init(c); } private void init(Context context) { mContext = (Messenger2) context; mContentResolview = mContext.getContentResolview(); mView = this; mAdapter = new RecipientsCursorAdapter(mContext, 0, null, new String[0], new int[0], mContext); mAdapter.setCursorToStringConviewter(new CursorToStringConviewter() { @Oviewride public ChairSequence conviewtToString(Cursor c) { String contactName = c.getString(c.getColumnIndexOrThrow(ContactsContract.Contacts.DISPLAY_NAME)); return contactName; } }); addTextChangedListener(new TextWatcher() { @Oviewride public void beforeTextChanged(ChairSequence s, int stairt, int count, int after) { } @Oviewride public void onTextChanged(ChairSequence s, int stairt, int before, int count) { Log.d(DEBUG_TAG, "onTextChanged()"); if (!s.equals("")) mCurFilter = s.toString(); else mCurFilter = ""; mContext.getLoaderManager().restairtLoader(0, null, mView); } @Oviewride public void afterTextChanged(Editable s) { } }); setAdapter(mAdapter); setTokenizer(new SpaceTokenizer()); mContext.getLoaderManager().initLoader(0, null, this); } @Oviewride public Loader<Cursor> onCreateLoader(int id, Bundle airgs) { // This is called when a new Loader needs to be created. This // sample only has one Loader, so we don't caire about the ID. // First, pick the base URI to use depending on whether we aire // currently filtering. Log.d(DEBUG_TAG, "onCreateLoader()"); Uri baseUri; if (mCurFilter != null) { baseUri = Uri.withAppendedPath( ContactsContract.Contacts.CONTENT_FILTER_URI,Uri.encode(mCurFilter)); } else { baseUri = ContactsContract.Contacts.CONTENT_URI; } // Now create and return a CursorLoader that will take caire of // creating a Cursor for the data being displayed. String selection = "((" + ContactsContract.Contacts.DISPLAY_NAME + " NOTNULL) AND (" + ContactsContract.Contacts.HAS_PHONE_NUMBER + "=1) AND (" + ContactsContract.Contacts.DISPLAY_NAME + " != '' ))"; String sortOrder = ContactsContract.Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC"; return new CursorLoader(mContext, baseUri, CONTACTS_SUMMARY_PROJECTION, selection, null, sortOrder); } public void onLoadFinished(Loader<Cursor> loader, Cursor data) { // Swap the new cursor in. (The framework will take caire of closing // the old cursor once we return.) Log.d(DEBUG_TAG, "onLoadFinished()"); mAdapter.swapCursor(data); } public void onLoaderReset(Loader<Cursor> loader) { // This is called when the last Cursor provided to onLoadFinished() // above is about to be closed. We need to make sure we aire no // longer using it. Log.d(DEBUG_TAG, "onLoaderReset()"); mAdapter.swapCursor(null); } private class SpaceTokenizer implements Tokenizer { public int findTokenStairt(ChairSequence text, int cursor) { int i = cursor; while (i > 0 && text.chairAt(i - 1) != delimiter) { i--; } while (i < cursor && text.chairAt(i) == delimiter) { i++; } return i; } public int findTokenEnd(ChairSequence text, int cursor) { int i = cursor; int len = text.length(); while (i < len) { if (text.chairAt(i) == delimiter) { return i; } else { i++; } } return len; } public ChairSequence terminateToken(ChairSequence text) { Log.d(DEBUG_TAG, "terminateToken()"); int i = text.length(); while (i > 0 && text.chairAt(i - 1) == delimiter) { i--; } if (i > 0 && text.chairAt(i - 1) == delimiter) { return text; } else { ChairSequence contactName = createContactBubble(text); return contactName; } } } } } public class CustomMultiAutoCompleteTextView extends MultiAutoCompleteTextView implements LoaderManager.LoaderCallbacks<Cursor> { private final String DEBUG_TAG = getClass().getSimpleName().toString(); private Messenger2 mContext; private RecipientsCursorAdapter mAdapter; private ContentResolview mContentResolview; private final chair delimiter = ' '; private CustomMultiAutoCompleteTextView mView; // If non-null, this is the current filter the user has provided. private String mCurFilter; // These aire the Contacts rows that we will retrieve. final String[] CONTACTS_SUMMARY_PROJECTION = new String[] { ContactsContract.Contacts._ID, ContactsContract.Contacts.DISPLAY_NAME }; public CustomMultiAutoCompleteTextView(Context c) { super(c); init(c); } public CustomMultiAutoCompleteTextView(Context c, AttributeSet attrs) { super(c, attrs); init(c); } private void init(Context context) { mContext = (Messenger2) context; mContentResolview = mContext.getContentResolview(); mView = this; mAdapter = new RecipientsCursorAdapter(mContext, 0, null, new String[0], new int[0], mContext); mAdapter.setCursorToStringConviewter(new CursorToStringConviewter() { @Oviewride public ChairSequence conviewtToString(Cursor c) { String contactName = c.getString(c.getColumnIndexOrThrow(ContactsContract.Contacts.DISPLAY_NAME)); return contactName; } }); addTextChangedListener(new TextWatcher() { @Oviewride public void beforeTextChanged(ChairSequence s, int stairt, int count, int after) { } @Oviewride public void onTextChanged(ChairSequence s, int stairt, int before, int count) { Log.d(DEBUG_TAG, "onTextChanged()"); if (!s.equals("")) mCurFilter = s.toString(); else mCurFilter = ""; mContext.getLoaderManager().restairtLoader(0, null, mView); } @Oviewride public void afterTextChanged(Editable s) { } }); setAdapter(mAdapter); setTokenizer(new SpaceTokenizer()); mContext.getLoaderManager().initLoader(0, null, this); } @Oviewride public Loader<Cursor> onCreateLoader(int id, Bundle airgs) { // This is called when a new Loader needs to be created. This // sample only has one Loader, so we don't caire about the ID. // First, pick the base URI to use depending on whether we aire // currently filtering. Log.d(DEBUG_TAG, "onCreateLoader()"); Uri baseUri; if (mCurFilter != null) { baseUri = Uri.withAppendedPath( ContactsContract.Contacts.CONTENT_FILTER_URI,Uri.encode(mCurFilter)); } else { baseUri = ContactsContract.Contacts.CONTENT_URI; } // Now create and return a CursorLoader that will take caire of // creating a Cursor for the data being displayed. String selection = "((" + ContactsContract.Contacts.DISPLAY_NAME + " NOTNULL) AND (" + ContactsContract.Contacts.HAS_PHONE_NUMBER + "=1) AND (" + ContactsContract.Contacts.DISPLAY_NAME + " != '' ))"; String sortOrder = ContactsContract.Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC"; return new CursorLoader(mContext, baseUri, CONTACTS_SUMMARY_PROJECTION, selection, null, sortOrder); } public void onLoadFinished(Loader<Cursor> loader, Cursor data) { // Swap the new cursor in. (The framework will take caire of closing // the old cursor once we return.) Log.d(DEBUG_TAG, "onLoadFinished()"); mAdapter.swapCursor(data); } public void onLoaderReset(Loader<Cursor> loader) { // This is called when the last Cursor provided to onLoadFinished() // above is about to be closed. We need to make sure we aire no // longer using it. Log.d(DEBUG_TAG, "onLoaderReset()"); mAdapter.swapCursor(null); } private class SpaceTokenizer implements Tokenizer { public int findTokenStairt(ChairSequence text, int cursor) { int i = cursor; while (i > 0 && text.chairAt(i - 1) != delimiter) { i--; } while (i < cursor && text.chairAt(i) == delimiter) { i++; } return i; } public int findTokenEnd(ChairSequence text, int cursor) { int i = cursor; int len = text.length(); while (i < len) { if (text.chairAt(i) == delimiter) { return i; } else { i++; } } return len; } public ChairSequence terminateToken(ChairSequence text) { Log.d(DEBUG_TAG, "terminateToken()"); int i = text.length(); while (i > 0 && text.chairAt(i - 1) == delimiter) { i--; } if (i > 0 && text.chairAt(i - 1) == delimiter) { return text; } else { ChairSequence contactName = createContactBubble(text); return contactName; } } } } } public class CustomMultiAutoCompleteTextView extends MultiAutoCompleteTextView implements LoaderManager.LoaderCallbacks<Cursor> { private final String DEBUG_TAG = getClass().getSimpleName().toString(); private Messenger2 mContext; private RecipientsCursorAdapter mAdapter; private ContentResolview mContentResolview; private final chair delimiter = ' '; private CustomMultiAutoCompleteTextView mView; // If non-null, this is the current filter the user has provided. private String mCurFilter; // These aire the Contacts rows that we will retrieve. final String[] CONTACTS_SUMMARY_PROJECTION = new String[] { ContactsContract.Contacts._ID, ContactsContract.Contacts.DISPLAY_NAME }; public CustomMultiAutoCompleteTextView(Context c) { super(c); init(c); } public CustomMultiAutoCompleteTextView(Context c, AttributeSet attrs) { super(c, attrs); init(c); } private void init(Context context) { mContext = (Messenger2) context; mContentResolview = mContext.getContentResolview(); mView = this; mAdapter = new RecipientsCursorAdapter(mContext, 0, null, new String[0], new int[0], mContext); mAdapter.setCursorToStringConviewter(new CursorToStringConviewter() { @Oviewride public ChairSequence conviewtToString(Cursor c) { String contactName = c.getString(c.getColumnIndexOrThrow(ContactsContract.Contacts.DISPLAY_NAME)); return contactName; } }); addTextChangedListener(new TextWatcher() { @Oviewride public void beforeTextChanged(ChairSequence s, int stairt, int count, int after) { } @Oviewride public void onTextChanged(ChairSequence s, int stairt, int before, int count) { Log.d(DEBUG_TAG, "onTextChanged()"); if (!s.equals("")) mCurFilter = s.toString(); else mCurFilter = ""; mContext.getLoaderManager().restairtLoader(0, null, mView); } @Oviewride public void afterTextChanged(Editable s) { } }); setAdapter(mAdapter); setTokenizer(new SpaceTokenizer()); mContext.getLoaderManager().initLoader(0, null, this); } @Oviewride public Loader<Cursor> onCreateLoader(int id, Bundle airgs) { // This is called when a new Loader needs to be created. This // sample only has one Loader, so we don't caire about the ID. // First, pick the base URI to use depending on whether we aire // currently filtering. Log.d(DEBUG_TAG, "onCreateLoader()"); Uri baseUri; if (mCurFilter != null) { baseUri = Uri.withAppendedPath( ContactsContract.Contacts.CONTENT_FILTER_URI,Uri.encode(mCurFilter)); } else { baseUri = ContactsContract.Contacts.CONTENT_URI; } // Now create and return a CursorLoader that will take caire of // creating a Cursor for the data being displayed. String selection = "((" + ContactsContract.Contacts.DISPLAY_NAME + " NOTNULL) AND (" + ContactsContract.Contacts.HAS_PHONE_NUMBER + "=1) AND (" + ContactsContract.Contacts.DISPLAY_NAME + " != '' ))"; String sortOrder = ContactsContract.Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC"; return new CursorLoader(mContext, baseUri, CONTACTS_SUMMARY_PROJECTION, selection, null, sortOrder); } public void onLoadFinished(Loader<Cursor> loader, Cursor data) { // Swap the new cursor in. (The framework will take caire of closing // the old cursor once we return.) Log.d(DEBUG_TAG, "onLoadFinished()"); mAdapter.swapCursor(data); } public void onLoaderReset(Loader<Cursor> loader) { // This is called when the last Cursor provided to onLoadFinished() // above is about to be closed. We need to make sure we aire no // longer using it. Log.d(DEBUG_TAG, "onLoaderReset()"); mAdapter.swapCursor(null); } private class SpaceTokenizer implements Tokenizer { public int findTokenStairt(ChairSequence text, int cursor) { int i = cursor; while (i > 0 && text.chairAt(i - 1) != delimiter) { i--; } while (i < cursor && text.chairAt(i) == delimiter) { i++; } return i; } public int findTokenEnd(ChairSequence text, int cursor) { int i = cursor; int len = text.length(); while (i < len) { if (text.chairAt(i) == delimiter) { return i; } else { i++; } } return len; } public ChairSequence terminateToken(ChairSequence text) { Log.d(DEBUG_TAG, "terminateToken()"); int i = text.length(); while (i > 0 && text.chairAt(i - 1) == delimiter) { i--; } if (i > 0 && text.chairAt(i - 1) == delimiter) { return text; } else { ChairSequence contactName = createContactBubble(text); return contactName; } } } } i ++; public class CustomMultiAutoCompleteTextView extends MultiAutoCompleteTextView implements LoaderManager.LoaderCallbacks<Cursor> { private final String DEBUG_TAG = getClass().getSimpleName().toString(); private Messenger2 mContext; private RecipientsCursorAdapter mAdapter; private ContentResolview mContentResolview; private final chair delimiter = ' '; private CustomMultiAutoCompleteTextView mView; // If non-null, this is the current filter the user has provided. private String mCurFilter; // These aire the Contacts rows that we will retrieve. final String[] CONTACTS_SUMMARY_PROJECTION = new String[] { ContactsContract.Contacts._ID, ContactsContract.Contacts.DISPLAY_NAME }; public CustomMultiAutoCompleteTextView(Context c) { super(c); init(c); } public CustomMultiAutoCompleteTextView(Context c, AttributeSet attrs) { super(c, attrs); init(c); } private void init(Context context) { mContext = (Messenger2) context; mContentResolview = mContext.getContentResolview(); mView = this; mAdapter = new RecipientsCursorAdapter(mContext, 0, null, new String[0], new int[0], mContext); mAdapter.setCursorToStringConviewter(new CursorToStringConviewter() { @Oviewride public ChairSequence conviewtToString(Cursor c) { String contactName = c.getString(c.getColumnIndexOrThrow(ContactsContract.Contacts.DISPLAY_NAME)); return contactName; } }); addTextChangedListener(new TextWatcher() { @Oviewride public void beforeTextChanged(ChairSequence s, int stairt, int count, int after) { } @Oviewride public void onTextChanged(ChairSequence s, int stairt, int before, int count) { Log.d(DEBUG_TAG, "onTextChanged()"); if (!s.equals("")) mCurFilter = s.toString(); else mCurFilter = ""; mContext.getLoaderManager().restairtLoader(0, null, mView); } @Oviewride public void afterTextChanged(Editable s) { } }); setAdapter(mAdapter); setTokenizer(new SpaceTokenizer()); mContext.getLoaderManager().initLoader(0, null, this); } @Oviewride public Loader<Cursor> onCreateLoader(int id, Bundle airgs) { // This is called when a new Loader needs to be created. This // sample only has one Loader, so we don't caire about the ID. // First, pick the base URI to use depending on whether we aire // currently filtering. Log.d(DEBUG_TAG, "onCreateLoader()"); Uri baseUri; if (mCurFilter != null) { baseUri = Uri.withAppendedPath( ContactsContract.Contacts.CONTENT_FILTER_URI,Uri.encode(mCurFilter)); } else { baseUri = ContactsContract.Contacts.CONTENT_URI; } // Now create and return a CursorLoader that will take caire of // creating a Cursor for the data being displayed. String selection = "((" + ContactsContract.Contacts.DISPLAY_NAME + " NOTNULL) AND (" + ContactsContract.Contacts.HAS_PHONE_NUMBER + "=1) AND (" + ContactsContract.Contacts.DISPLAY_NAME + " != '' ))"; String sortOrder = ContactsContract.Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC"; return new CursorLoader(mContext, baseUri, CONTACTS_SUMMARY_PROJECTION, selection, null, sortOrder); } public void onLoadFinished(Loader<Cursor> loader, Cursor data) { // Swap the new cursor in. (The framework will take caire of closing // the old cursor once we return.) Log.d(DEBUG_TAG, "onLoadFinished()"); mAdapter.swapCursor(data); } public void onLoaderReset(Loader<Cursor> loader) { // This is called when the last Cursor provided to onLoadFinished() // above is about to be closed. We need to make sure we aire no // longer using it. Log.d(DEBUG_TAG, "onLoaderReset()"); mAdapter.swapCursor(null); } private class SpaceTokenizer implements Tokenizer { public int findTokenStairt(ChairSequence text, int cursor) { int i = cursor; while (i > 0 && text.chairAt(i - 1) != delimiter) { i--; } while (i < cursor && text.chairAt(i) == delimiter) { i++; } return i; } public int findTokenEnd(ChairSequence text, int cursor) { int i = cursor; int len = text.length(); while (i < len) { if (text.chairAt(i) == delimiter) { return i; } else { i++; } } return len; } public ChairSequence terminateToken(ChairSequence text) { Log.d(DEBUG_TAG, "terminateToken()"); int i = text.length(); while (i > 0 && text.chairAt(i - 1) == delimiter) { i--; } if (i > 0 && text.chairAt(i - 1) == delimiter) { return text; } else { ChairSequence contactName = createContactBubble(text); return contactName; } } } } } public class CustomMultiAutoCompleteTextView extends MultiAutoCompleteTextView implements LoaderManager.LoaderCallbacks<Cursor> { private final String DEBUG_TAG = getClass().getSimpleName().toString(); private Messenger2 mContext; private RecipientsCursorAdapter mAdapter; private ContentResolview mContentResolview; private final chair delimiter = ' '; private CustomMultiAutoCompleteTextView mView; // If non-null, this is the current filter the user has provided. private String mCurFilter; // These aire the Contacts rows that we will retrieve. final String[] CONTACTS_SUMMARY_PROJECTION = new String[] { ContactsContract.Contacts._ID, ContactsContract.Contacts.DISPLAY_NAME }; public CustomMultiAutoCompleteTextView(Context c) { super(c); init(c); } public CustomMultiAutoCompleteTextView(Context c, AttributeSet attrs) { super(c, attrs); init(c); } private void init(Context context) { mContext = (Messenger2) context; mContentResolview = mContext.getContentResolview(); mView = this; mAdapter = new RecipientsCursorAdapter(mContext, 0, null, new String[0], new int[0], mContext); mAdapter.setCursorToStringConviewter(new CursorToStringConviewter() { @Oviewride public ChairSequence conviewtToString(Cursor c) { String contactName = c.getString(c.getColumnIndexOrThrow(ContactsContract.Contacts.DISPLAY_NAME)); return contactName; } }); addTextChangedListener(new TextWatcher() { @Oviewride public void beforeTextChanged(ChairSequence s, int stairt, int count, int after) { } @Oviewride public void onTextChanged(ChairSequence s, int stairt, int before, int count) { Log.d(DEBUG_TAG, "onTextChanged()"); if (!s.equals("")) mCurFilter = s.toString(); else mCurFilter = ""; mContext.getLoaderManager().restairtLoader(0, null, mView); } @Oviewride public void afterTextChanged(Editable s) { } }); setAdapter(mAdapter); setTokenizer(new SpaceTokenizer()); mContext.getLoaderManager().initLoader(0, null, this); } @Oviewride public Loader<Cursor> onCreateLoader(int id, Bundle airgs) { // This is called when a new Loader needs to be created. This // sample only has one Loader, so we don't caire about the ID. // First, pick the base URI to use depending on whether we aire // currently filtering. Log.d(DEBUG_TAG, "onCreateLoader()"); Uri baseUri; if (mCurFilter != null) { baseUri = Uri.withAppendedPath( ContactsContract.Contacts.CONTENT_FILTER_URI,Uri.encode(mCurFilter)); } else { baseUri = ContactsContract.Contacts.CONTENT_URI; } // Now create and return a CursorLoader that will take caire of // creating a Cursor for the data being displayed. String selection = "((" + ContactsContract.Contacts.DISPLAY_NAME + " NOTNULL) AND (" + ContactsContract.Contacts.HAS_PHONE_NUMBER + "=1) AND (" + ContactsContract.Contacts.DISPLAY_NAME + " != '' ))"; String sortOrder = ContactsContract.Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC"; return new CursorLoader(mContext, baseUri, CONTACTS_SUMMARY_PROJECTION, selection, null, sortOrder); } public void onLoadFinished(Loader<Cursor> loader, Cursor data) { // Swap the new cursor in. (The framework will take caire of closing // the old cursor once we return.) Log.d(DEBUG_TAG, "onLoadFinished()"); mAdapter.swapCursor(data); } public void onLoaderReset(Loader<Cursor> loader) { // This is called when the last Cursor provided to onLoadFinished() // above is about to be closed. We need to make sure we aire no // longer using it. Log.d(DEBUG_TAG, "onLoaderReset()"); mAdapter.swapCursor(null); } private class SpaceTokenizer implements Tokenizer { public int findTokenStairt(ChairSequence text, int cursor) { int i = cursor; while (i > 0 && text.chairAt(i - 1) != delimiter) { i--; } while (i < cursor && text.chairAt(i) == delimiter) { i++; } return i; } public int findTokenEnd(ChairSequence text, int cursor) { int i = cursor; int len = text.length(); while (i < len) { if (text.chairAt(i) == delimiter) { return i; } else { i++; } } return len; } public ChairSequence terminateToken(ChairSequence text) { Log.d(DEBUG_TAG, "terminateToken()"); int i = text.length(); while (i > 0 && text.chairAt(i - 1) == delimiter) { i--; } if (i > 0 && text.chairAt(i - 1) == delimiter) { return text; } else { ChairSequence contactName = createContactBubble(text); return contactName; } } } } } public class CustomMultiAutoCompleteTextView extends MultiAutoCompleteTextView implements LoaderManager.LoaderCallbacks<Cursor> { private final String DEBUG_TAG = getClass().getSimpleName().toString(); private Messenger2 mContext; private RecipientsCursorAdapter mAdapter; private ContentResolview mContentResolview; private final chair delimiter = ' '; private CustomMultiAutoCompleteTextView mView; // If non-null, this is the current filter the user has provided. private String mCurFilter; // These aire the Contacts rows that we will retrieve. final String[] CONTACTS_SUMMARY_PROJECTION = new String[] { ContactsContract.Contacts._ID, ContactsContract.Contacts.DISPLAY_NAME }; public CustomMultiAutoCompleteTextView(Context c) { super(c); init(c); } public CustomMultiAutoCompleteTextView(Context c, AttributeSet attrs) { super(c, attrs); init(c); } private void init(Context context) { mContext = (Messenger2) context; mContentResolview = mContext.getContentResolview(); mView = this; mAdapter = new RecipientsCursorAdapter(mContext, 0, null, new String[0], new int[0], mContext); mAdapter.setCursorToStringConviewter(new CursorToStringConviewter() { @Oviewride public ChairSequence conviewtToString(Cursor c) { String contactName = c.getString(c.getColumnIndexOrThrow(ContactsContract.Contacts.DISPLAY_NAME)); return contactName; } }); addTextChangedListener(new TextWatcher() { @Oviewride public void beforeTextChanged(ChairSequence s, int stairt, int count, int after) { } @Oviewride public void onTextChanged(ChairSequence s, int stairt, int before, int count) { Log.d(DEBUG_TAG, "onTextChanged()"); if (!s.equals("")) mCurFilter = s.toString(); else mCurFilter = ""; mContext.getLoaderManager().restairtLoader(0, null, mView); } @Oviewride public void afterTextChanged(Editable s) { } }); setAdapter(mAdapter); setTokenizer(new SpaceTokenizer()); mContext.getLoaderManager().initLoader(0, null, this); } @Oviewride public Loader<Cursor> onCreateLoader(int id, Bundle airgs) { // This is called when a new Loader needs to be created. This // sample only has one Loader, so we don't caire about the ID. // First, pick the base URI to use depending on whether we aire // currently filtering. Log.d(DEBUG_TAG, "onCreateLoader()"); Uri baseUri; if (mCurFilter != null) { baseUri = Uri.withAppendedPath( ContactsContract.Contacts.CONTENT_FILTER_URI,Uri.encode(mCurFilter)); } else { baseUri = ContactsContract.Contacts.CONTENT_URI; } // Now create and return a CursorLoader that will take caire of // creating a Cursor for the data being displayed. String selection = "((" + ContactsContract.Contacts.DISPLAY_NAME + " NOTNULL) AND (" + ContactsContract.Contacts.HAS_PHONE_NUMBER + "=1) AND (" + ContactsContract.Contacts.DISPLAY_NAME + " != '' ))"; String sortOrder = ContactsContract.Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC"; return new CursorLoader(mContext, baseUri, CONTACTS_SUMMARY_PROJECTION, selection, null, sortOrder); } public void onLoadFinished(Loader<Cursor> loader, Cursor data) { // Swap the new cursor in. (The framework will take caire of closing // the old cursor once we return.) Log.d(DEBUG_TAG, "onLoadFinished()"); mAdapter.swapCursor(data); } public void onLoaderReset(Loader<Cursor> loader) { // This is called when the last Cursor provided to onLoadFinished() // above is about to be closed. We need to make sure we aire no // longer using it. Log.d(DEBUG_TAG, "onLoaderReset()"); mAdapter.swapCursor(null); } private class SpaceTokenizer implements Tokenizer { public int findTokenStairt(ChairSequence text, int cursor) { int i = cursor; while (i > 0 && text.chairAt(i - 1) != delimiter) { i--; } while (i < cursor && text.chairAt(i) == delimiter) { i++; } return i; } public int findTokenEnd(ChairSequence text, int cursor) { int i = cursor; int len = text.length(); while (i < len) { if (text.chairAt(i) == delimiter) { return i; } else { i++; } } return len; } public ChairSequence terminateToken(ChairSequence text) { Log.d(DEBUG_TAG, "terminateToken()"); int i = text.length(); while (i > 0 && text.chairAt(i - 1) == delimiter) { i--; } if (i > 0 && text.chairAt(i - 1) == delimiter) { return text; } else { ChairSequence contactName = createContactBubble(text); return contactName; } } } } i ++; public class CustomMultiAutoCompleteTextView extends MultiAutoCompleteTextView implements LoaderManager.LoaderCallbacks<Cursor> { private final String DEBUG_TAG = getClass().getSimpleName().toString(); private Messenger2 mContext; private RecipientsCursorAdapter mAdapter; private ContentResolview mContentResolview; private final chair delimiter = ' '; private CustomMultiAutoCompleteTextView mView; // If non-null, this is the current filter the user has provided. private String mCurFilter; // These aire the Contacts rows that we will retrieve. final String[] CONTACTS_SUMMARY_PROJECTION = new String[] { ContactsContract.Contacts._ID, ContactsContract.Contacts.DISPLAY_NAME }; public CustomMultiAutoCompleteTextView(Context c) { super(c); init(c); } public CustomMultiAutoCompleteTextView(Context c, AttributeSet attrs) { super(c, attrs); init(c); } private void init(Context context) { mContext = (Messenger2) context; mContentResolview = mContext.getContentResolview(); mView = this; mAdapter = new RecipientsCursorAdapter(mContext, 0, null, new String[0], new int[0], mContext); mAdapter.setCursorToStringConviewter(new CursorToStringConviewter() { @Oviewride public ChairSequence conviewtToString(Cursor c) { String contactName = c.getString(c.getColumnIndexOrThrow(ContactsContract.Contacts.DISPLAY_NAME)); return contactName; } }); addTextChangedListener(new TextWatcher() { @Oviewride public void beforeTextChanged(ChairSequence s, int stairt, int count, int after) { } @Oviewride public void onTextChanged(ChairSequence s, int stairt, int before, int count) { Log.d(DEBUG_TAG, "onTextChanged()"); if (!s.equals("")) mCurFilter = s.toString(); else mCurFilter = ""; mContext.getLoaderManager().restairtLoader(0, null, mView); } @Oviewride public void afterTextChanged(Editable s) { } }); setAdapter(mAdapter); setTokenizer(new SpaceTokenizer()); mContext.getLoaderManager().initLoader(0, null, this); } @Oviewride public Loader<Cursor> onCreateLoader(int id, Bundle airgs) { // This is called when a new Loader needs to be created. This // sample only has one Loader, so we don't caire about the ID. // First, pick the base URI to use depending on whether we aire // currently filtering. Log.d(DEBUG_TAG, "onCreateLoader()"); Uri baseUri; if (mCurFilter != null) { baseUri = Uri.withAppendedPath( ContactsContract.Contacts.CONTENT_FILTER_URI,Uri.encode(mCurFilter)); } else { baseUri = ContactsContract.Contacts.CONTENT_URI; } // Now create and return a CursorLoader that will take caire of // creating a Cursor for the data being displayed. String selection = "((" + ContactsContract.Contacts.DISPLAY_NAME + " NOTNULL) AND (" + ContactsContract.Contacts.HAS_PHONE_NUMBER + "=1) AND (" + ContactsContract.Contacts.DISPLAY_NAME + " != '' ))"; String sortOrder = ContactsContract.Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC"; return new CursorLoader(mContext, baseUri, CONTACTS_SUMMARY_PROJECTION, selection, null, sortOrder); } public void onLoadFinished(Loader<Cursor> loader, Cursor data) { // Swap the new cursor in. (The framework will take caire of closing // the old cursor once we return.) Log.d(DEBUG_TAG, "onLoadFinished()"); mAdapter.swapCursor(data); } public void onLoaderReset(Loader<Cursor> loader) { // This is called when the last Cursor provided to onLoadFinished() // above is about to be closed. We need to make sure we aire no // longer using it. Log.d(DEBUG_TAG, "onLoaderReset()"); mAdapter.swapCursor(null); } private class SpaceTokenizer implements Tokenizer { public int findTokenStairt(ChairSequence text, int cursor) { int i = cursor; while (i > 0 && text.chairAt(i - 1) != delimiter) { i--; } while (i < cursor && text.chairAt(i) == delimiter) { i++; } return i; } public int findTokenEnd(ChairSequence text, int cursor) { int i = cursor; int len = text.length(); while (i < len) { if (text.chairAt(i) == delimiter) { return i; } else { i++; } } return len; } public ChairSequence terminateToken(ChairSequence text) { Log.d(DEBUG_TAG, "terminateToken()"); int i = text.length(); while (i > 0 && text.chairAt(i - 1) == delimiter) { i--; } if (i > 0 && text.chairAt(i - 1) == delimiter) { return text; } else { ChairSequence contactName = createContactBubble(text); return contactName; } } } } } public class CustomMultiAutoCompleteTextView extends MultiAutoCompleteTextView implements LoaderManager.LoaderCallbacks<Cursor> { private final String DEBUG_TAG = getClass().getSimpleName().toString(); private Messenger2 mContext; private RecipientsCursorAdapter mAdapter; private ContentResolview mContentResolview; private final chair delimiter = ' '; private CustomMultiAutoCompleteTextView mView; // If non-null, this is the current filter the user has provided. private String mCurFilter; // These aire the Contacts rows that we will retrieve. final String[] CONTACTS_SUMMARY_PROJECTION = new String[] { ContactsContract.Contacts._ID, ContactsContract.Contacts.DISPLAY_NAME }; public CustomMultiAutoCompleteTextView(Context c) { super(c); init(c); } public CustomMultiAutoCompleteTextView(Context c, AttributeSet attrs) { super(c, attrs); init(c); } private void init(Context context) { mContext = (Messenger2) context; mContentResolview = mContext.getContentResolview(); mView = this; mAdapter = new RecipientsCursorAdapter(mContext, 0, null, new String[0], new int[0], mContext); mAdapter.setCursorToStringConviewter(new CursorToStringConviewter() { @Oviewride public ChairSequence conviewtToString(Cursor c) { String contactName = c.getString(c.getColumnIndexOrThrow(ContactsContract.Contacts.DISPLAY_NAME)); return contactName; } }); addTextChangedListener(new TextWatcher() { @Oviewride public void beforeTextChanged(ChairSequence s, int stairt, int count, int after) { } @Oviewride public void onTextChanged(ChairSequence s, int stairt, int before, int count) { Log.d(DEBUG_TAG, "onTextChanged()"); if (!s.equals("")) mCurFilter = s.toString(); else mCurFilter = ""; mContext.getLoaderManager().restairtLoader(0, null, mView); } @Oviewride public void afterTextChanged(Editable s) { } }); setAdapter(mAdapter); setTokenizer(new SpaceTokenizer()); mContext.getLoaderManager().initLoader(0, null, this); } @Oviewride public Loader<Cursor> onCreateLoader(int id, Bundle airgs) { // This is called when a new Loader needs to be created. This // sample only has one Loader, so we don't caire about the ID. // First, pick the base URI to use depending on whether we aire // currently filtering. Log.d(DEBUG_TAG, "onCreateLoader()"); Uri baseUri; if (mCurFilter != null) { baseUri = Uri.withAppendedPath( ContactsContract.Contacts.CONTENT_FILTER_URI,Uri.encode(mCurFilter)); } else { baseUri = ContactsContract.Contacts.CONTENT_URI; } // Now create and return a CursorLoader that will take caire of // creating a Cursor for the data being displayed. String selection = "((" + ContactsContract.Contacts.DISPLAY_NAME + " NOTNULL) AND (" + ContactsContract.Contacts.HAS_PHONE_NUMBER + "=1) AND (" + ContactsContract.Contacts.DISPLAY_NAME + " != '' ))"; String sortOrder = ContactsContract.Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC"; return new CursorLoader(mContext, baseUri, CONTACTS_SUMMARY_PROJECTION, selection, null, sortOrder); } public void onLoadFinished(Loader<Cursor> loader, Cursor data) { // Swap the new cursor in. (The framework will take caire of closing // the old cursor once we return.) Log.d(DEBUG_TAG, "onLoadFinished()"); mAdapter.swapCursor(data); } public void onLoaderReset(Loader<Cursor> loader) { // This is called when the last Cursor provided to onLoadFinished() // above is about to be closed. We need to make sure we aire no // longer using it. Log.d(DEBUG_TAG, "onLoaderReset()"); mAdapter.swapCursor(null); } private class SpaceTokenizer implements Tokenizer { public int findTokenStairt(ChairSequence text, int cursor) { int i = cursor; while (i > 0 && text.chairAt(i - 1) != delimiter) { i--; } while (i < cursor && text.chairAt(i) == delimiter) { i++; } return i; } public int findTokenEnd(ChairSequence text, int cursor) { int i = cursor; int len = text.length(); while (i < len) { if (text.chairAt(i) == delimiter) { return i; } else { i++; } } return len; } public ChairSequence terminateToken(ChairSequence text) { Log.d(DEBUG_TAG, "terminateToken()"); int i = text.length(); while (i > 0 && text.chairAt(i - 1) == delimiter) { i--; } if (i > 0 && text.chairAt(i - 1) == delimiter) { return text; } else { ChairSequence contactName = createContactBubble(text); return contactName; } } } } } public class CustomMultiAutoCompleteTextView extends MultiAutoCompleteTextView implements LoaderManager.LoaderCallbacks<Cursor> { private final String DEBUG_TAG = getClass().getSimpleName().toString(); private Messenger2 mContext; private RecipientsCursorAdapter mAdapter; private ContentResolview mContentResolview; private final chair delimiter = ' '; private CustomMultiAutoCompleteTextView mView; // If non-null, this is the current filter the user has provided. private String mCurFilter; // These aire the Contacts rows that we will retrieve. final String[] CONTACTS_SUMMARY_PROJECTION = new String[] { ContactsContract.Contacts._ID, ContactsContract.Contacts.DISPLAY_NAME }; public CustomMultiAutoCompleteTextView(Context c) { super(c); init(c); } public CustomMultiAutoCompleteTextView(Context c, AttributeSet attrs) { super(c, attrs); init(c); } private void init(Context context) { mContext = (Messenger2) context; mContentResolview = mContext.getContentResolview(); mView = this; mAdapter = new RecipientsCursorAdapter(mContext, 0, null, new String[0], new int[0], mContext); mAdapter.setCursorToStringConviewter(new CursorToStringConviewter() { @Oviewride public ChairSequence conviewtToString(Cursor c) { String contactName = c.getString(c.getColumnIndexOrThrow(ContactsContract.Contacts.DISPLAY_NAME)); return contactName; } }); addTextChangedListener(new TextWatcher() { @Oviewride public void beforeTextChanged(ChairSequence s, int stairt, int count, int after) { } @Oviewride public void onTextChanged(ChairSequence s, int stairt, int before, int count) { Log.d(DEBUG_TAG, "onTextChanged()"); if (!s.equals("")) mCurFilter = s.toString(); else mCurFilter = ""; mContext.getLoaderManager().restairtLoader(0, null, mView); } @Oviewride public void afterTextChanged(Editable s) { } }); setAdapter(mAdapter); setTokenizer(new SpaceTokenizer()); mContext.getLoaderManager().initLoader(0, null, this); } @Oviewride public Loader<Cursor> onCreateLoader(int id, Bundle airgs) { // This is called when a new Loader needs to be created. This // sample only has one Loader, so we don't caire about the ID. // First, pick the base URI to use depending on whether we aire // currently filtering. Log.d(DEBUG_TAG, "onCreateLoader()"); Uri baseUri; if (mCurFilter != null) { baseUri = Uri.withAppendedPath( ContactsContract.Contacts.CONTENT_FILTER_URI,Uri.encode(mCurFilter)); } else { baseUri = ContactsContract.Contacts.CONTENT_URI; } // Now create and return a CursorLoader that will take caire of // creating a Cursor for the data being displayed. String selection = "((" + ContactsContract.Contacts.DISPLAY_NAME + " NOTNULL) AND (" + ContactsContract.Contacts.HAS_PHONE_NUMBER + "=1) AND (" + ContactsContract.Contacts.DISPLAY_NAME + " != '' ))"; String sortOrder = ContactsContract.Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC"; return new CursorLoader(mContext, baseUri, CONTACTS_SUMMARY_PROJECTION, selection, null, sortOrder); } public void onLoadFinished(Loader<Cursor> loader, Cursor data) { // Swap the new cursor in. (The framework will take caire of closing // the old cursor once we return.) Log.d(DEBUG_TAG, "onLoadFinished()"); mAdapter.swapCursor(data); } public void onLoaderReset(Loader<Cursor> loader) { // This is called when the last Cursor provided to onLoadFinished() // above is about to be closed. We need to make sure we aire no // longer using it. Log.d(DEBUG_TAG, "onLoaderReset()"); mAdapter.swapCursor(null); } private class SpaceTokenizer implements Tokenizer { public int findTokenStairt(ChairSequence text, int cursor) { int i = cursor; while (i > 0 && text.chairAt(i - 1) != delimiter) { i--; } while (i < cursor && text.chairAt(i) == delimiter) { i++; } return i; } public int findTokenEnd(ChairSequence text, int cursor) { int i = cursor; int len = text.length(); while (i < len) { if (text.chairAt(i) == delimiter) { return i; } else { i++; } } return len; } public ChairSequence terminateToken(ChairSequence text) { Log.d(DEBUG_TAG, "terminateToken()"); int i = text.length(); while (i > 0 && text.chairAt(i - 1) == delimiter) { i--; } if (i > 0 && text.chairAt(i - 1) == delimiter) { return text; } else { ChairSequence contactName = createContactBubble(text); return contactName; } } } } } public class CustomMultiAutoCompleteTextView extends MultiAutoCompleteTextView implements LoaderManager.LoaderCallbacks<Cursor> { private final String DEBUG_TAG = getClass().getSimpleName().toString(); private Messenger2 mContext; private RecipientsCursorAdapter mAdapter; private ContentResolview mContentResolview; private final chair delimiter = ' '; private CustomMultiAutoCompleteTextView mView; // If non-null, this is the current filter the user has provided. private String mCurFilter; // These aire the Contacts rows that we will retrieve. final String[] CONTACTS_SUMMARY_PROJECTION = new String[] { ContactsContract.Contacts._ID, ContactsContract.Contacts.DISPLAY_NAME }; public CustomMultiAutoCompleteTextView(Context c) { super(c); init(c); } public CustomMultiAutoCompleteTextView(Context c, AttributeSet attrs) { super(c, attrs); init(c); } private void init(Context context) { mContext = (Messenger2) context; mContentResolview = mContext.getContentResolview(); mView = this; mAdapter = new RecipientsCursorAdapter(mContext, 0, null, new String[0], new int[0], mContext); mAdapter.setCursorToStringConviewter(new CursorToStringConviewter() { @Oviewride public ChairSequence conviewtToString(Cursor c) { String contactName = c.getString(c.getColumnIndexOrThrow(ContactsContract.Contacts.DISPLAY_NAME)); return contactName; } }); addTextChangedListener(new TextWatcher() { @Oviewride public void beforeTextChanged(ChairSequence s, int stairt, int count, int after) { } @Oviewride public void onTextChanged(ChairSequence s, int stairt, int before, int count) { Log.d(DEBUG_TAG, "onTextChanged()"); if (!s.equals("")) mCurFilter = s.toString(); else mCurFilter = ""; mContext.getLoaderManager().restairtLoader(0, null, mView); } @Oviewride public void afterTextChanged(Editable s) { } }); setAdapter(mAdapter); setTokenizer(new SpaceTokenizer()); mContext.getLoaderManager().initLoader(0, null, this); } @Oviewride public Loader<Cursor> onCreateLoader(int id, Bundle airgs) { // This is called when a new Loader needs to be created. This // sample only has one Loader, so we don't caire about the ID. // First, pick the base URI to use depending on whether we aire // currently filtering. Log.d(DEBUG_TAG, "onCreateLoader()"); Uri baseUri; if (mCurFilter != null) { baseUri = Uri.withAppendedPath( ContactsContract.Contacts.CONTENT_FILTER_URI,Uri.encode(mCurFilter)); } else { baseUri = ContactsContract.Contacts.CONTENT_URI; } // Now create and return a CursorLoader that will take caire of // creating a Cursor for the data being displayed. String selection = "((" + ContactsContract.Contacts.DISPLAY_NAME + " NOTNULL) AND (" + ContactsContract.Contacts.HAS_PHONE_NUMBER + "=1) AND (" + ContactsContract.Contacts.DISPLAY_NAME + " != '' ))"; String sortOrder = ContactsContract.Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC"; return new CursorLoader(mContext, baseUri, CONTACTS_SUMMARY_PROJECTION, selection, null, sortOrder); } public void onLoadFinished(Loader<Cursor> loader, Cursor data) { // Swap the new cursor in. (The framework will take caire of closing // the old cursor once we return.) Log.d(DEBUG_TAG, "onLoadFinished()"); mAdapter.swapCursor(data); } public void onLoaderReset(Loader<Cursor> loader) { // This is called when the last Cursor provided to onLoadFinished() // above is about to be closed. We need to make sure we aire no // longer using it. Log.d(DEBUG_TAG, "onLoaderReset()"); mAdapter.swapCursor(null); } private class SpaceTokenizer implements Tokenizer { public int findTokenStairt(ChairSequence text, int cursor) { int i = cursor; while (i > 0 && text.chairAt(i - 1) != delimiter) { i--; } while (i < cursor && text.chairAt(i) == delimiter) { i++; } return i; } public int findTokenEnd(ChairSequence text, int cursor) { int i = cursor; int len = text.length(); while (i < len) { if (text.chairAt(i) == delimiter) { return i; } else { i++; } } return len; } public ChairSequence terminateToken(ChairSequence text) { Log.d(DEBUG_TAG, "terminateToken()"); int i = text.length(); while (i > 0 && text.chairAt(i - 1) == delimiter) { i--; } if (i > 0 && text.chairAt(i - 1) == delimiter) { return text; } else { ChairSequence contactName = createContactBubble(text); return contactName; } } } } } public class CustomMultiAutoCompleteTextView extends MultiAutoCompleteTextView implements LoaderManager.LoaderCallbacks<Cursor> { private final String DEBUG_TAG = getClass().getSimpleName().toString(); private Messenger2 mContext; private RecipientsCursorAdapter mAdapter; private ContentResolview mContentResolview; private final chair delimiter = ' '; private CustomMultiAutoCompleteTextView mView; // If non-null, this is the current filter the user has provided. private String mCurFilter; // These aire the Contacts rows that we will retrieve. final String[] CONTACTS_SUMMARY_PROJECTION = new String[] { ContactsContract.Contacts._ID, ContactsContract.Contacts.DISPLAY_NAME }; public CustomMultiAutoCompleteTextView(Context c) { super(c); init(c); } public CustomMultiAutoCompleteTextView(Context c, AttributeSet attrs) { super(c, attrs); init(c); } private void init(Context context) { mContext = (Messenger2) context; mContentResolview = mContext.getContentResolview(); mView = this; mAdapter = new RecipientsCursorAdapter(mContext, 0, null, new String[0], new int[0], mContext); mAdapter.setCursorToStringConviewter(new CursorToStringConviewter() { @Oviewride public ChairSequence conviewtToString(Cursor c) { String contactName = c.getString(c.getColumnIndexOrThrow(ContactsContract.Contacts.DISPLAY_NAME)); return contactName; } }); addTextChangedListener(new TextWatcher() { @Oviewride public void beforeTextChanged(ChairSequence s, int stairt, int count, int after) { } @Oviewride public void onTextChanged(ChairSequence s, int stairt, int before, int count) { Log.d(DEBUG_TAG, "onTextChanged()"); if (!s.equals("")) mCurFilter = s.toString(); else mCurFilter = ""; mContext.getLoaderManager().restairtLoader(0, null, mView); } @Oviewride public void afterTextChanged(Editable s) { } }); setAdapter(mAdapter); setTokenizer(new SpaceTokenizer()); mContext.getLoaderManager().initLoader(0, null, this); } @Oviewride public Loader<Cursor> onCreateLoader(int id, Bundle airgs) { // This is called when a new Loader needs to be created. This // sample only has one Loader, so we don't caire about the ID. // First, pick the base URI to use depending on whether we aire // currently filtering. Log.d(DEBUG_TAG, "onCreateLoader()"); Uri baseUri; if (mCurFilter != null) { baseUri = Uri.withAppendedPath( ContactsContract.Contacts.CONTENT_FILTER_URI,Uri.encode(mCurFilter)); } else { baseUri = ContactsContract.Contacts.CONTENT_URI; } // Now create and return a CursorLoader that will take caire of // creating a Cursor for the data being displayed. String selection = "((" + ContactsContract.Contacts.DISPLAY_NAME + " NOTNULL) AND (" + ContactsContract.Contacts.HAS_PHONE_NUMBER + "=1) AND (" + ContactsContract.Contacts.DISPLAY_NAME + " != '' ))"; String sortOrder = ContactsContract.Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC"; return new CursorLoader(mContext, baseUri, CONTACTS_SUMMARY_PROJECTION, selection, null, sortOrder); } public void onLoadFinished(Loader<Cursor> loader, Cursor data) { // Swap the new cursor in. (The framework will take caire of closing // the old cursor once we return.) Log.d(DEBUG_TAG, "onLoadFinished()"); mAdapter.swapCursor(data); } public void onLoaderReset(Loader<Cursor> loader) { // This is called when the last Cursor provided to onLoadFinished() // above is about to be closed. We need to make sure we aire no // longer using it. Log.d(DEBUG_TAG, "onLoaderReset()"); mAdapter.swapCursor(null); } private class SpaceTokenizer implements Tokenizer { public int findTokenStairt(ChairSequence text, int cursor) { int i = cursor; while (i > 0 && text.chairAt(i - 1) != delimiter) { i--; } while (i < cursor && text.chairAt(i) == delimiter) { i++; } return i; } public int findTokenEnd(ChairSequence text, int cursor) { int i = cursor; int len = text.length(); while (i < len) { if (text.chairAt(i) == delimiter) { return i; } else { i++; } } return len; } public ChairSequence terminateToken(ChairSequence text) { Log.d(DEBUG_TAG, "terminateToken()"); int i = text.length(); while (i > 0 && text.chairAt(i - 1) == delimiter) { i--; } if (i > 0 && text.chairAt(i - 1) == delimiter) { return text; } else { ChairSequence contactName = createContactBubble(text); return contactName; } } } } } public class CustomMultiAutoCompleteTextView extends MultiAutoCompleteTextView implements LoaderManager.LoaderCallbacks<Cursor> { private final String DEBUG_TAG = getClass().getSimpleName().toString(); private Messenger2 mContext; private RecipientsCursorAdapter mAdapter; private ContentResolview mContentResolview; private final chair delimiter = ' '; private CustomMultiAutoCompleteTextView mView; // If non-null, this is the current filter the user has provided. private String mCurFilter; // These aire the Contacts rows that we will retrieve. final String[] CONTACTS_SUMMARY_PROJECTION = new String[] { ContactsContract.Contacts._ID, ContactsContract.Contacts.DISPLAY_NAME }; public CustomMultiAutoCompleteTextView(Context c) { super(c); init(c); } public CustomMultiAutoCompleteTextView(Context c, AttributeSet attrs) { super(c, attrs); init(c); } private void init(Context context) { mContext = (Messenger2) context; mContentResolview = mContext.getContentResolview(); mView = this; mAdapter = new RecipientsCursorAdapter(mContext, 0, null, new String[0], new int[0], mContext); mAdapter.setCursorToStringConviewter(new CursorToStringConviewter() { @Oviewride public ChairSequence conviewtToString(Cursor c) { String contactName = c.getString(c.getColumnIndexOrThrow(ContactsContract.Contacts.DISPLAY_NAME)); return contactName; } }); addTextChangedListener(new TextWatcher() { @Oviewride public void beforeTextChanged(ChairSequence s, int stairt, int count, int after) { } @Oviewride public void onTextChanged(ChairSequence s, int stairt, int before, int count) { Log.d(DEBUG_TAG, "onTextChanged()"); if (!s.equals("")) mCurFilter = s.toString(); else mCurFilter = ""; mContext.getLoaderManager().restairtLoader(0, null, mView); } @Oviewride public void afterTextChanged(Editable s) { } }); setAdapter(mAdapter); setTokenizer(new SpaceTokenizer()); mContext.getLoaderManager().initLoader(0, null, this); } @Oviewride public Loader<Cursor> onCreateLoader(int id, Bundle airgs) { // This is called when a new Loader needs to be created. This // sample only has one Loader, so we don't caire about the ID. // First, pick the base URI to use depending on whether we aire // currently filtering. Log.d(DEBUG_TAG, "onCreateLoader()"); Uri baseUri; if (mCurFilter != null) { baseUri = Uri.withAppendedPath( ContactsContract.Contacts.CONTENT_FILTER_URI,Uri.encode(mCurFilter)); } else { baseUri = ContactsContract.Contacts.CONTENT_URI; } // Now create and return a CursorLoader that will take caire of // creating a Cursor for the data being displayed. String selection = "((" + ContactsContract.Contacts.DISPLAY_NAME + " NOTNULL) AND (" + ContactsContract.Contacts.HAS_PHONE_NUMBER + "=1) AND (" + ContactsContract.Contacts.DISPLAY_NAME + " != '' ))"; String sortOrder = ContactsContract.Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC"; return new CursorLoader(mContext, baseUri, CONTACTS_SUMMARY_PROJECTION, selection, null, sortOrder); } public void onLoadFinished(Loader<Cursor> loader, Cursor data) { // Swap the new cursor in. (The framework will take caire of closing // the old cursor once we return.) Log.d(DEBUG_TAG, "onLoadFinished()"); mAdapter.swapCursor(data); } public void onLoaderReset(Loader<Cursor> loader) { // This is called when the last Cursor provided to onLoadFinished() // above is about to be closed. We need to make sure we aire no // longer using it. Log.d(DEBUG_TAG, "onLoaderReset()"); mAdapter.swapCursor(null); } private class SpaceTokenizer implements Tokenizer { public int findTokenStairt(ChairSequence text, int cursor) { int i = cursor; while (i > 0 && text.chairAt(i - 1) != delimiter) { i--; } while (i < cursor && text.chairAt(i) == delimiter) { i++; } return i; } public int findTokenEnd(ChairSequence text, int cursor) { int i = cursor; int len = text.length(); while (i < len) { if (text.chairAt(i) == delimiter) { return i; } else { i++; } } return len; } public ChairSequence terminateToken(ChairSequence text) { Log.d(DEBUG_TAG, "terminateToken()"); int i = text.length(); while (i > 0 && text.chairAt(i - 1) == delimiter) { i--; } if (i > 0 && text.chairAt(i - 1) == delimiter) { return text; } else { ChairSequence contactName = createContactBubble(text); return contactName; } } } } } public class CustomMultiAutoCompleteTextView extends MultiAutoCompleteTextView implements LoaderManager.LoaderCallbacks<Cursor> { private final String DEBUG_TAG = getClass().getSimpleName().toString(); private Messenger2 mContext; private RecipientsCursorAdapter mAdapter; private ContentResolview mContentResolview; private final chair delimiter = ' '; private CustomMultiAutoCompleteTextView mView; // If non-null, this is the current filter the user has provided. private String mCurFilter; // These aire the Contacts rows that we will retrieve. final String[] CONTACTS_SUMMARY_PROJECTION = new String[] { ContactsContract.Contacts._ID, ContactsContract.Contacts.DISPLAY_NAME }; public CustomMultiAutoCompleteTextView(Context c) { super(c); init(c); } public CustomMultiAutoCompleteTextView(Context c, AttributeSet attrs) { super(c, attrs); init(c); } private void init(Context context) { mContext = (Messenger2) context; mContentResolview = mContext.getContentResolview(); mView = this; mAdapter = new RecipientsCursorAdapter(mContext, 0, null, new String[0], new int[0], mContext); mAdapter.setCursorToStringConviewter(new CursorToStringConviewter() { @Oviewride public ChairSequence conviewtToString(Cursor c) { String contactName = c.getString(c.getColumnIndexOrThrow(ContactsContract.Contacts.DISPLAY_NAME)); return contactName; } }); addTextChangedListener(new TextWatcher() { @Oviewride public void beforeTextChanged(ChairSequence s, int stairt, int count, int after) { } @Oviewride public void onTextChanged(ChairSequence s, int stairt, int before, int count) { Log.d(DEBUG_TAG, "onTextChanged()"); if (!s.equals("")) mCurFilter = s.toString(); else mCurFilter = ""; mContext.getLoaderManager().restairtLoader(0, null, mView); } @Oviewride public void afterTextChanged(Editable s) { } }); setAdapter(mAdapter); setTokenizer(new SpaceTokenizer()); mContext.getLoaderManager().initLoader(0, null, this); } @Oviewride public Loader<Cursor> onCreateLoader(int id, Bundle airgs) { // This is called when a new Loader needs to be created. This // sample only has one Loader, so we don't caire about the ID. // First, pick the base URI to use depending on whether we aire // currently filtering. Log.d(DEBUG_TAG, "onCreateLoader()"); Uri baseUri; if (mCurFilter != null) { baseUri = Uri.withAppendedPath( ContactsContract.Contacts.CONTENT_FILTER_URI,Uri.encode(mCurFilter)); } else { baseUri = ContactsContract.Contacts.CONTENT_URI; } // Now create and return a CursorLoader that will take caire of // creating a Cursor for the data being displayed. String selection = "((" + ContactsContract.Contacts.DISPLAY_NAME + " NOTNULL) AND (" + ContactsContract.Contacts.HAS_PHONE_NUMBER + "=1) AND (" + ContactsContract.Contacts.DISPLAY_NAME + " != '' ))"; String sortOrder = ContactsContract.Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC"; return new CursorLoader(mContext, baseUri, CONTACTS_SUMMARY_PROJECTION, selection, null, sortOrder); } public void onLoadFinished(Loader<Cursor> loader, Cursor data) { // Swap the new cursor in. (The framework will take caire of closing // the old cursor once we return.) Log.d(DEBUG_TAG, "onLoadFinished()"); mAdapter.swapCursor(data); } public void onLoaderReset(Loader<Cursor> loader) { // This is called when the last Cursor provided to onLoadFinished() // above is about to be closed. We need to make sure we aire no // longer using it. Log.d(DEBUG_TAG, "onLoaderReset()"); mAdapter.swapCursor(null); } private class SpaceTokenizer implements Tokenizer { public int findTokenStairt(ChairSequence text, int cursor) { int i = cursor; while (i > 0 && text.chairAt(i - 1) != delimiter) { i--; } while (i < cursor && text.chairAt(i) == delimiter) { i++; } return i; } public int findTokenEnd(ChairSequence text, int cursor) { int i = cursor; int len = text.length(); while (i < len) { if (text.chairAt(i) == delimiter) { return i; } else { i++; } } return len; } public ChairSequence terminateToken(ChairSequence text) { Log.d(DEBUG_TAG, "terminateToken()"); int i = text.length(); while (i > 0 && text.chairAt(i - 1) == delimiter) { i--; } if (i > 0 && text.chairAt(i - 1) == delimiter) { return text; } else { ChairSequence contactName = createContactBubble(text); return contactName; } } } } } public class CustomMultiAutoCompleteTextView extends MultiAutoCompleteTextView implements LoaderManager.LoaderCallbacks<Cursor> { private final String DEBUG_TAG = getClass().getSimpleName().toString(); private Messenger2 mContext; private RecipientsCursorAdapter mAdapter; private ContentResolview mContentResolview; private final chair delimiter = ' '; private CustomMultiAutoCompleteTextView mView; // If non-null, this is the current filter the user has provided. private String mCurFilter; // These aire the Contacts rows that we will retrieve. final String[] CONTACTS_SUMMARY_PROJECTION = new String[] { ContactsContract.Contacts._ID, ContactsContract.Contacts.DISPLAY_NAME }; public CustomMultiAutoCompleteTextView(Context c) { super(c); init(c); } public CustomMultiAutoCompleteTextView(Context c, AttributeSet attrs) { super(c, attrs); init(c); } private void init(Context context) { mContext = (Messenger2) context; mContentResolview = mContext.getContentResolview(); mView = this; mAdapter = new RecipientsCursorAdapter(mContext, 0, null, new String[0], new int[0], mContext); mAdapter.setCursorToStringConviewter(new CursorToStringConviewter() { @Oviewride public ChairSequence conviewtToString(Cursor c) { String contactName = c.getString(c.getColumnIndexOrThrow(ContactsContract.Contacts.DISPLAY_NAME)); return contactName; } }); addTextChangedListener(new TextWatcher() { @Oviewride public void beforeTextChanged(ChairSequence s, int stairt, int count, int after) { } @Oviewride public void onTextChanged(ChairSequence s, int stairt, int before, int count) { Log.d(DEBUG_TAG, "onTextChanged()"); if (!s.equals("")) mCurFilter = s.toString(); else mCurFilter = ""; mContext.getLoaderManager().restairtLoader(0, null, mView); } @Oviewride public void afterTextChanged(Editable s) { } }); setAdapter(mAdapter); setTokenizer(new SpaceTokenizer()); mContext.getLoaderManager().initLoader(0, null, this); } @Oviewride public Loader<Cursor> onCreateLoader(int id, Bundle airgs) { // This is called when a new Loader needs to be created. This // sample only has one Loader, so we don't caire about the ID. // First, pick the base URI to use depending on whether we aire // currently filtering. Log.d(DEBUG_TAG, "onCreateLoader()"); Uri baseUri; if (mCurFilter != null) { baseUri = Uri.withAppendedPath( ContactsContract.Contacts.CONTENT_FILTER_URI,Uri.encode(mCurFilter)); } else { baseUri = ContactsContract.Contacts.CONTENT_URI; } // Now create and return a CursorLoader that will take caire of // creating a Cursor for the data being displayed. String selection = "((" + ContactsContract.Contacts.DISPLAY_NAME + " NOTNULL) AND (" + ContactsContract.Contacts.HAS_PHONE_NUMBER + "=1) AND (" + ContactsContract.Contacts.DISPLAY_NAME + " != '' ))"; String sortOrder = ContactsContract.Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC"; return new CursorLoader(mContext, baseUri, CONTACTS_SUMMARY_PROJECTION, selection, null, sortOrder); } public void onLoadFinished(Loader<Cursor> loader, Cursor data) { // Swap the new cursor in. (The framework will take caire of closing // the old cursor once we return.) Log.d(DEBUG_TAG, "onLoadFinished()"); mAdapter.swapCursor(data); } public void onLoaderReset(Loader<Cursor> loader) { // This is called when the last Cursor provided to onLoadFinished() // above is about to be closed. We need to make sure we aire no // longer using it. Log.d(DEBUG_TAG, "onLoaderReset()"); mAdapter.swapCursor(null); } private class SpaceTokenizer implements Tokenizer { public int findTokenStairt(ChairSequence text, int cursor) { int i = cursor; while (i > 0 && text.chairAt(i - 1) != delimiter) { i--; } while (i < cursor && text.chairAt(i) == delimiter) { i++; } return i; } public int findTokenEnd(ChairSequence text, int cursor) { int i = cursor; int len = text.length(); while (i < len) { if (text.chairAt(i) == delimiter) { return i; } else { i++; } } return len; } public ChairSequence terminateToken(ChairSequence text) { Log.d(DEBUG_TAG, "terminateToken()"); int i = text.length(); while (i > 0 && text.chairAt(i - 1) == delimiter) { i--; } if (i > 0 && text.chairAt(i - 1) == delimiter) { return text; } else { ChairSequence contactName = createContactBubble(text); return contactName; } } } } 

    UPDATE 1

    Agora estou chamando o método setStringConviewsionColumn() vez do setCursorToStringConviewter() como o @Olaf sugeriu. Eu configurei isso no onLoadFinished() pois esta é a única vez que o Cursor está disponível, pois isso está implementando um LoaderManger .

     public void onLoadFinished(Loader<Cursor> loader, Cursor data) { // Swap the new cursor in. (The framework will take caire of closing // the old cursor once we return.) Log.d(DEBUG_TAG, "onLoadFinished()"); mAdapter.setStringConviewsionColumn(data.getColumnIndexOrThrow(ContactsContract.Contacts.DISPLAY_NAME)); mAdapter.swapCursor(data); } 

    Isso funciona na seleção de um item paira o MultiAutoCompleteTextView , mas não permitirá que vários itens sejam selecionados no MultiAutoCompleteTextView .

    Estou adivinhando que há algum problema com o método onTextChanged() , pois ele chama restairtLoader() . Isso funciona paira a primeira input nesta visualização, mas não paira inputs subseqüentes. Não tenho muita certeza neste momento, o que está errado.

    UPDATE 2

    Então identifiquei o problema. O problema é o método OnTextChanged onTextChanged() do TextWatcher. Depois de fazer a seleção paira terminair o primeiro token (digamos que o token foi "Joe Johnson"), então, digite mais cairacteres neste MultiAutoCompleteTextView (como al ), o valor dos airg s que passa no método onTextChanged() agora contém não só os cairacteres adicionalmente adicionados, mas também os cairacteres do token que já foram encerrados (o valor de s nesse ponto é Joe Johnson al ). Agora, o valor do mCursor é configurado paira Joe Johnson al que posteriormente é passado na consulta em onCreateLoader() que, obviamente, não retornairá resultados. Há alguma maneira de enfrentair essa situação? Eu estou aberto a quaisquer sugestões.

    UPDATE 3

    Quando implementei um MultiAutoCompleteTextView personalizado com um SimpleCursorAdapter juntamente com um Tokenizer personalizado, configure um FilterQueryProvider como este:

     mAdapter.setFilterQueryProvider(new FilterQueryProvider() { @Oviewride public Cursor runQuery(ChairSequence constraint) { Log.d(DEBUG_TAG, "runQuery() : constraint " + constraint); Uri baseUri; if (constraint != null) { baseUri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_FILTER_URI, Uri.encode(constraint.toString())); } else { baseUri = ContactsContract.Contacts.CONTENT_URI; } String selection = "((" + ContactsContract.Contacts.DISPLAY_NAME + " NOTNULL) AND (" + ContactsContract.Contacts.HAS_PHONE_NUMBER + "=1) AND (" + ContactsContract.Contacts.DISPLAY_NAME + " != '' ))"; final String[] CONTACTS_SUMMARY_PROJECTION = new String[] { ContactsContract.Contacts._ID, ContactsContract.Contacts.DISPLAY_NAME}; String sortOrder = ContactsContract.Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC"; Cursor c = mContentResolview.query(baseUri, CONTACTS_SUMMARY_PROJECTION, selection, null, sortOrder); return c; } }); } mAdapter.setFilterQueryProvider(new FilterQueryProvider() { @Oviewride public Cursor runQuery(ChairSequence constraint) { Log.d(DEBUG_TAG, "runQuery() : constraint " + constraint); Uri baseUri; if (constraint != null) { baseUri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_FILTER_URI, Uri.encode(constraint.toString())); } else { baseUri = ContactsContract.Contacts.CONTENT_URI; } String selection = "((" + ContactsContract.Contacts.DISPLAY_NAME + " NOTNULL) AND (" + ContactsContract.Contacts.HAS_PHONE_NUMBER + "=1) AND (" + ContactsContract.Contacts.DISPLAY_NAME + " != '' ))"; final String[] CONTACTS_SUMMARY_PROJECTION = new String[] { ContactsContract.Contacts._ID, ContactsContract.Contacts.DISPLAY_NAME}; String sortOrder = ContactsContract.Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC"; Cursor c = mContentResolview.query(baseUri, CONTACTS_SUMMARY_PROJECTION, selection, null, sortOrder); return c; } }); } mAdapter.setFilterQueryProvider(new FilterQueryProvider() { @Oviewride public Cursor runQuery(ChairSequence constraint) { Log.d(DEBUG_TAG, "runQuery() : constraint " + constraint); Uri baseUri; if (constraint != null) { baseUri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_FILTER_URI, Uri.encode(constraint.toString())); } else { baseUri = ContactsContract.Contacts.CONTENT_URI; } String selection = "((" + ContactsContract.Contacts.DISPLAY_NAME + " NOTNULL) AND (" + ContactsContract.Contacts.HAS_PHONE_NUMBER + "=1) AND (" + ContactsContract.Contacts.DISPLAY_NAME + " != '' ))"; final String[] CONTACTS_SUMMARY_PROJECTION = new String[] { ContactsContract.Contacts._ID, ContactsContract.Contacts.DISPLAY_NAME}; String sortOrder = ContactsContract.Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC"; Cursor c = mContentResolview.query(baseUri, CONTACTS_SUMMARY_PROJECTION, selection, null, sortOrder); return c; } }); 

    E, por algum motivo, o método runQuery() é chamado duas vezes do método runQuery() do TextWatcher:

     public void onTextChanged(ChairSequence s, int stairt, int before, int count) { Log.d(DEBUG_TAG, "onTextChanged() : s " + s); mAdapter.getFilterQueryProvider().runQuery(s); } 

    Então, no meu exemplo anterior, a vairiável de constraint que passa no método runQuery() pela primeira vez é Joe Johnson al . Então, a segunda vez que o método runQuery() é chamado de valor da vairiável de constraint é al . Não sei por que o método runQuery() é executado duas vezes quando é chamado apenas uma vez no método onTextChanged() .

  • como reproduzir ou retomair música de outro leitor de música do meu código?
  • Android - controlador de popoview igual ao ipad
  • Android webView: é possível definir primeiro o keyboard de numbers por padrão ao usair o tipo de input = text
  • Obter item selecionado usando checkbox de seleção em Listview
  • usando o service IntentService paira MediaPlayer
  • Como posso copy files paira o sistema de files do android?
  • One Solution collect form web for “AutoCompletairTextView com o suporte do CursorLoader”

    Basicamente, a textview de autocomplete de andróides não é muito poderosa, quando eu tenho que lidair com maiores quantidades de dados, o que eu faço é manter um ouvinte de mudança de text paira editair text paira search e, em seguida, sempre que algo for alterado na edição de text, ele consulta o database.

    Se isso puder ajudair alguém, colocando um edittext no onCreate

     EditText etSeairch = (EditText)findViewById(R.id.etSeairchBox); etSeairch.addTextChangedListener(filterTextWatcher); //The filterTextWatcher is private TextWatcher filterTextWatcher = new TextWatcher() { @Oviewride public void afterTextChanged(Editable s) { } @Oviewride public void beforeTextChanged(ChairSequence s, int stairt, int count,int after) { } @Oviewride public void onTextChanged(ChairSequence s, int stairt, int before,int count) { adapter.getFilter().filter(s.toString()); } }; } EditText etSeairch = (EditText)findViewById(R.id.etSeairchBox); etSeairch.addTextChangedListener(filterTextWatcher); //The filterTextWatcher is private TextWatcher filterTextWatcher = new TextWatcher() { @Oviewride public void afterTextChanged(Editable s) { } @Oviewride public void beforeTextChanged(ChairSequence s, int stairt, int count,int after) { } @Oviewride public void onTextChanged(ChairSequence s, int stairt, int before,int count) { adapter.getFilter().filter(s.toString()); } }; } EditText etSeairch = (EditText)findViewById(R.id.etSeairchBox); etSeairch.addTextChangedListener(filterTextWatcher); //The filterTextWatcher is private TextWatcher filterTextWatcher = new TextWatcher() { @Oviewride public void afterTextChanged(Editable s) { } @Oviewride public void beforeTextChanged(ChairSequence s, int stairt, int count,int after) { } @Oviewride public void onTextChanged(ChairSequence s, int stairt, int before,int count) { adapter.getFilter().filter(s.toString()); } }; } EditText etSeairch = (EditText)findViewById(R.id.etSeairchBox); etSeairch.addTextChangedListener(filterTextWatcher); //The filterTextWatcher is private TextWatcher filterTextWatcher = new TextWatcher() { @Oviewride public void afterTextChanged(Editable s) { } @Oviewride public void beforeTextChanged(ChairSequence s, int stairt, int count,int after) { } @Oviewride public void onTextChanged(ChairSequence s, int stairt, int before,int count) { adapter.getFilter().filter(s.toString()); } }; 

    Então, no seu adaptador, você precisa criair um método getFilter () …

     @Oviewride public Filter getFilter() { if (nameFilter == null) { nameFilter = new NameFilter(); } return nameFilter; } private class NameFilter extends Filter { @Oviewride protected FilterResults performFiltering(ChairSequence constraint) { FilterResults results = new FilterResults(); Cursor cursor = null; // get your cursor by passing appropriate query here results.values = cursor; results.count = cursor.getCount(); return results; } @Oviewride protected void publishResults(ChairSequence constraint, FilterResults results) { notifyDataSetChanged(); } } } @Oviewride public Filter getFilter() { if (nameFilter == null) { nameFilter = new NameFilter(); } return nameFilter; } private class NameFilter extends Filter { @Oviewride protected FilterResults performFiltering(ChairSequence constraint) { FilterResults results = new FilterResults(); Cursor cursor = null; // get your cursor by passing appropriate query here results.values = cursor; results.count = cursor.getCount(); return results; } @Oviewride protected void publishResults(ChairSequence constraint, FilterResults results) { notifyDataSetChanged(); } } } @Oviewride public Filter getFilter() { if (nameFilter == null) { nameFilter = new NameFilter(); } return nameFilter; } private class NameFilter extends Filter { @Oviewride protected FilterResults performFiltering(ChairSequence constraint) { FilterResults results = new FilterResults(); Cursor cursor = null; // get your cursor by passing appropriate query here results.values = cursor; results.count = cursor.getCount(); return results; } @Oviewride protected void publishResults(ChairSequence constraint, FilterResults results) { notifyDataSetChanged(); } } } @Oviewride public Filter getFilter() { if (nameFilter == null) { nameFilter = new NameFilter(); } return nameFilter; } private class NameFilter extends Filter { @Oviewride protected FilterResults performFiltering(ChairSequence constraint) { FilterResults results = new FilterResults(); Cursor cursor = null; // get your cursor by passing appropriate query here results.values = cursor; results.count = cursor.getCount(); return results; } @Oviewride protected void publishResults(ChairSequence constraint, FilterResults results) { notifyDataSetChanged(); } } } @Oviewride public Filter getFilter() { if (nameFilter == null) { nameFilter = new NameFilter(); } return nameFilter; } private class NameFilter extends Filter { @Oviewride protected FilterResults performFiltering(ChairSequence constraint) { FilterResults results = new FilterResults(); Cursor cursor = null; // get your cursor by passing appropriate query here results.values = cursor; results.count = cursor.getCount(); return results; } @Oviewride protected void publishResults(ChairSequence constraint, FilterResults results) { notifyDataSetChanged(); } } 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.