Quantcast
Channel: Ignite Realtime: Message List
Viewing all articles
Browse latest Browse all 11593

Re: (a)Smack Update/Remove PrivacyItem From List.

$
0
0

Simple oopsie. thanks for the help flow it worked great when using the Iterator.

 

My Code in case some one else comes along

 

 

List<PrivacyItem> pList;

  PrivacyListManager privacyManager = PrivacyListManager.getInstanceFor(GlobalVar.mConnection);

  pList = privacyManager.getPrivacyList("BlockedUsers").getItems();

  /*

//Adding a new entry here

PrivacyItem item = new PrivacyItem(PrivacyItem.Type.jid, "test@"+GlobalVar.mConnection.getServiceName(), false, 1);

          item.setFilterMessage(true);

          item.setFilterPresenceIn(false);

          item.setFilterPresenceOut(true);

          item.setFilterIQ(false);

          pList.add(item);

          privacyManager.updatePrivacyList("BlockedUsers", pList);*/

 

//Remove Item from list

  Iterator<PrivacyItem> it = pList.iterator();

  while(it.hasNext())

  {

//Only send update if the list has been changed while looping

//Optional to add break. If you don't it will loop through entire list and remove all entries. If you know entries cannot be duplicated you can remove comments

  boolean Changed = false;

  Log.i("SChat","it Value = " + it.next().getValue());

  if(it.next().getValue().equalsIgnoreCase("test@"+GlobalVar.mConnection.getServi ceName())){

  it.remove();

  Changed = true;

//privacyManager.updatePrivacyList("BlockedUsers", pList);

//break;

  }

  if(Changed){

  privacyManager.updatePrivacyList("BlockedUsers", pList);

  }

 

  }


Viewing all articles
Browse latest Browse all 11593

Trending Articles