@Override public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) { final Cursor cursor = mAdapter.getCursor(); cursor.moveToPosition(position); Contact contact = contactDatabase.getContact(cursor, "_id"); if (disableCheckBox) { isUserPresnt = ChannelService.getInstance(getActivity()).isUserAlreadyPresentInChannel(channel.getKey(), contact.getContactIds()); if (!isUserPresnt) { Intent intent = new Intent(); intent.putExtra(ChannelInfoActivity.USERID, contact.getUserId()); getActivity().setResult(getActivity().RESULT_OK, intent); getActivity().finish(); } } else { AppCompatCheckBox checkBox = (AppCompatCheckBox) view.findViewById(R.id.checkbox); checkBox.toggle(); if (checkBox.isChecked()) { userIdList.add(contact.getContactIds()); } else if (!checkBox.isChecked()) { userIdList.remove(contact.getContactIds()); } } }
/** * Defines the SectionIndexer.getPositionForSection() interface. */ @Override public int getPositionForSection(int i) { if (getCursor() == null) { return 0; } return mAlphabetIndexer.getPositionForSection(i); }
/** * An override of getCount that simplifies accessing the Cursor. If the Cursor is null, * getCount returns zero. As a result, no test for Cursor == null is needed. */ @Override public int getCount() { if (getCursor() == null) { return 0; } return super.getCount(); }
/** * Defines the SectionIndexer.getSectionForPosition() interface. */ @Override public int getSectionForPosition(int i) { if (getCursor() == null) { return 0; } return mAlphabetIndexer.getSectionForPosition(i); }