src/com/beem/project/beem/ui/ContactList.java
changeset 441 de9f5da0a294
parent 438 051fa95b54f7
child 444 5fedf5cec9c9
equal deleted inserted replaced
440:1b04c885f87d 441:de9f5da0a294
   350 	 * {@inheritDoc}
   350 	 * {@inheritDoc}
   351 	 */
   351 	 */
   352 	@Override
   352 	@Override
   353 	public void onEntriesAdded(List<String> addresses) throws RemoteException {
   353 	public void onEntriesAdded(List<String> addresses) throws RemoteException {
   354 	    for (String newName : addresses) {
   354 	    for (String newName : addresses) {
   355 		Contact c = new Contact(newName);
   355 		Contact c = mRoster.getContact(newName);
   356 		mListContact.add(c);
   356 		mContactOnGroup.get(getString(R.string.contact_list_all_contact)).add(c);
       
   357 		if (c.getGroups().size() == 0)
       
   358 		    mContactOnGroup.get(getString(R.string.contact_list_no_group)).add(c);
       
   359 		else {
       
   360 		    for (String group : c.getGroups()) {
       
   361 			if (!mListGroup.contains(group)) {
       
   362 			    mListGroup.add(mListGroup.size() - 1, group);
       
   363 			    List<Contact> tmplist = new ArrayList<Contact>();
       
   364 			    mContactOnGroup.put(group, tmplist);
       
   365 			}
       
   366 			mContactOnGroup.get(group).add(c);
       
   367 			if (group.equals(mCurGroup))
       
   368 			    mListContact.add(c);
       
   369 		    }
       
   370 		}
   357 	    }
   371 	    }
   358 	    mHandler.post(new RunnableChange());
   372 	    mHandler.post(new RunnableChange());
   359 	}
   373 	}
   360 
   374 
   361 	/**
   375 	/**
   365 	public void onEntriesDeleted(List<String> addresses) throws RemoteException {
   379 	public void onEntriesDeleted(List<String> addresses) throws RemoteException {
   366 	    for (String cToDelete : addresses) {
   380 	    for (String cToDelete : addresses) {
   367 		for (Contact c : mListContact) {
   381 		for (Contact c : mListContact) {
   368 		    if (c.getJID().equals(cToDelete)) {
   382 		    if (c.getJID().equals(cToDelete)) {
   369 			mListContact.remove(c);
   383 			mListContact.remove(c);
       
   384 			for (String group : mListGroup) {
       
   385 			    mContactOnGroup.get(group).remove(c);
       
   386 			    if (mContactOnGroup.get(group).size() == 0) {
       
   387 				mListGroup.remove(group);
       
   388 				mListContact = mContactOnGroup.get(getString(R.string.contact_list_all_contact));
       
   389 			    }
       
   390 			}
   370 			break;
   391 			break;
   371 		    }
   392 		    }
   372 		}
   393 		}
   373 	    }
   394 	    }
   374 	    mHandler.post(new RunnableChange());
   395 	    mHandler.post(new RunnableChange());
   527 		    case Status.CONTACT_STATUS_UNAVAILABLE:
   548 		    case Status.CONTACT_STATUS_UNAVAILABLE:
   528 			imageDrawable = getResources().getDrawable(R.drawable.requested);
   549 			imageDrawable = getResources().getDrawable(R.drawable.requested);
   529 			break;
   550 			break;
   530 		    default:
   551 		    default:
   531 			imageDrawable = getResources().getDrawable(R.drawable.error);
   552 			imageDrawable = getResources().getDrawable(R.drawable.error);
   532 		    break;
   553 			break;
   533 		}
   554 		}
   534 		imgV.setImageDrawable(imageDrawable);
   555 		imgV.setImageDrawable(imageDrawable);
   535 
   556 
   536 		String mContactName = curContact.getName();
   557 		String mContactName = curContact.getName();
   537 		if ("".equals(mContactName)) {
   558 		if ("".equals(mContactName)) {
   551 		 * Rajouter l'avatar du contact getAvatar() dans la classe imgV = (ImageView)
   572 		 * Rajouter l'avatar du contact getAvatar() dans la classe imgV = (ImageView)
   552 		 * view.findViewById(R.id.contactlistavatar); if (imgV != null) { imageDrawable =
   573 		 * view.findViewById(R.id.contactlistavatar); if (imgV != null) { imageDrawable =
   553 		 * getResources().getDrawable(R.drawable.avatar); imgV.setImageDrawable(imageDrawable); }
   574 		 * getResources().getDrawable(R.drawable.avatar); imgV.setImageDrawable(imageDrawable); }
   554 		 */
   575 		 */
   555 
   576 
   556 		if (false){
   577 		if (false) {
   557 		    imgV = (ImageView) view.findViewById(R.id.contactlistavatar);
   578 		    imgV = (ImageView) view.findViewById(R.id.contactlistavatar);
   558 
   579 
   559 		    byte[] rawImg;
   580 		    byte[] rawImg;
   560 		    try {
   581 		    try {
   561 			//TODO: le faire en asynchrone, car la ca bloque tout.
   582 			// TODO: le faire en asynchrone, car la ca bloque tout.
   562 			rawImg = mXmppFacade.getVcardAvater(curContact.getJID());
   583 			rawImg = mXmppFacade.getVcardAvater(curContact.getJID());
   563 			if (rawImg != null)
   584 			if (rawImg != null)
   564 			    imgV.setImageBitmap(BitmapFactory.decodeByteArray(rawImg, 0, rawImg.length));
   585 			    imgV.setImageBitmap(BitmapFactory.decodeByteArray(rawImg, 0, rawImg.length));
   565 		    } catch (RemoteException e) {
   586 		    } catch (RemoteException e) {
   566 			e.printStackTrace();
   587 			e.printStackTrace();