Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- EditText searchText;
- ArrayList<String> phno0 = new ArrayList<String>();
- List<String> arrayListNames;
- public List<ProfileBean> list;
- public SearchableAdapter adapter;
- //ProfileBean bean;
- String[] cellArray = null;
- String contacts;
- ListView lv;
- String phoneNumber, name;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- ActionBar actionBar = getActionBar();
- lv = (ListView) findViewById(R.id.listview);
- list = new ArrayList<ProfileBean>();
- getAllCallLogs(this.getContentResolver());
- adapter = new SearchableAdapter(getApplication(), list);
- lv.setAdapter(adapter);
- lv.setItemsCanFocus(false);
- lv.setOnItemClickListener(this);
- lv.setTextFilterEnabled(true);
- }
- @Override
- protected void onStart() {
- // TODO Auto-generated method stub
- super.onStart();
- }
- public void getAllCallLogs(ContentResolver cr) {
- Cursor phones = cr.query(
- ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, null,
- null, ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME
- + " ASC");
- while (phones.moveToNext()) {
- phoneNumber = phones
- .getString(phones
- .getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
- name = phones
- .getString(phones
- .getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME));
- list.add(new ProfileBean(name, phoneNumber));
- }
- phones.close();
- }
- int flag = 0
- if(list.size() == 0){
- list.add(new ProfileBean(name, phoneNumber));
- }
- for(int i=0;i<list.size();i++){
- if(!list.get(i).getProfileName().trim().equals(name)){
- flag = 1;
- }else{
- flag =0;
- break;
- }
- if(flag == 1){
- list.add(new ProfileBean(name, phoneNumber));
- }
- if (!myList.contains(newContact))
- myList.add(newContact);
- public ArrayList<String> listWithoutDuplicates(ArrayList<String> duplicateList) {
- // Converting ArrayList to HashSet to remove duplicates
- LinkedHashSet<String> listToSet = new LinkedHashSet<String>(duplicateList);
- // Creating Arraylist without duplicate values
- ArrayList<String> listWithoutDuplicates = new ArrayList<String>(listToSet);
- return listWithoutDuplicates;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement