Merge.
authorVincent Veronis <veroni_v@epitech.net>
Fri, 30 Oct 2009 22:38:11 +0100
changeset 488 77e8f3384a3b
parent 487 6122f9ed186f (current diff)
parent 484 776575982b48 (diff)
child 489 77c573c8217e
Merge.
src/com/beem/project/beem/ui/ContactList.java
--- a/.classpath	Fri Oct 30 19:25:20 2009 +0100
+++ b/.classpath	Fri Oct 30 22:38:11 2009 +0100
@@ -8,7 +8,7 @@
 		</attributes>
 	</classpathentry>
 	<classpathentry kind="lib" path="libs/security.jar"/>
-	<classpathentry kind="lib" path="libs/smack.jar" sourcepath="/home/marseille/smack_src_3_1_0/source">
+	<classpathentry kind="lib" path="libs/smack.jar" sourcepath="/home/nikita/devel/smack/source">
 		<attributes>
 			<attribute name="javadoc_location" value="file:/home/nikita/devel/smack_src_3_1_0/javadoc/org/"/>
 		</attributes>
--- a/AndroidManifest.xml	Fri Oct 30 19:25:20 2009 +0100
+++ b/AndroidManifest.xml	Fri Oct 30 22:38:11 2009 +0100
@@ -3,7 +3,9 @@
 	package="com.beem.project.beem" android:versionCode="1"
 	android:versionName="1.0">
 	<application android:label="@string/app_name" android:icon="@drawable/beem_launcher_icon_silver"
-		android:theme="@style/Theme.BEEM.Default" android:debuggable="true">
+		android:theme="@style/Theme.BEEM.Default" android:debuggable="true"
+		android:name="@string/app_name"
+		>
 		<activity android:name=".ui.Login" android:label="@string/app_name"
 			android:launchMode="singleTask">
 			<intent-filter>
--- a/src/com/beem/project/beem/service/RosterAdapter.java	Fri Oct 30 19:25:20 2009 +0100
+++ b/src/com/beem/project/beem/service/RosterAdapter.java	Fri Oct 30 22:38:11 2009 +0100
@@ -192,7 +192,11 @@
 	String user = entry.getUser();
 	Contact c = new Contact(user);
 	c.setStatus(mAdaptee.getPresence(user));
-	c.setGroups(entry.getGroups());
+	try {
+	    c.setGroups(entry.getGroups());
+	}catch(NullPointerException e){
+	    Log.d(TAG, "Group list not ready");
+	}
 	c.setName(entry.getName());
 	return c;
     }
--- a/src/com/beem/project/beem/ui/ContactList.java	Fri Oct 30 19:25:20 2009 +0100
+++ b/src/com/beem/project/beem/ui/ContactList.java	Fri Oct 30 22:38:11 2009 +0100
@@ -15,9 +15,10 @@
 import android.content.Intent;
 import android.content.IntentFilter;
 import android.content.ServiceConnection;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
 import android.graphics.Color;
 import android.graphics.Typeface;
-import android.graphics.drawable.Drawable;
 import android.os.Bundle;
 import android.os.Handler;
 import android.os.IBinder;
@@ -53,7 +54,7 @@
  */
 public class ContactList extends Activity {
 
-    // private static final String TAG = "CONTACTLIST_ACT";
+    //private static final String TAG = "CONTACTLIST_ACT";
     private static final Intent SERVICE_INTENT = new Intent();
     private static final int REQUEST_CODE = 1;
     private BeemContactList mAdapterContactList;
@@ -67,6 +68,7 @@
     private IXmppFacade mXmppFacade;
     private final ServiceConnection mServConn = new BeemServiceConnection();
     private BeemBroadcastReceiver mReceiver;
+    private Map<Integer, Bitmap> mIconsMap = new HashMap<Integer, Bitmap>();
 
     static {
 	SERVICE_INTENT.setComponent(new ComponentName("com.beem.project.beem", "com.beem.project.beem.BeemService"));
@@ -91,6 +93,7 @@
 	mHandler = new Handler();
 	mReceiver = new BeemBroadcastReceiver(mServConn);
 	this.registerReceiver(mReceiver, new IntentFilter(BeemBroadcastReceiver.BEEM_CONNECTION_CLOSED));
+	prepareIconsStatus();
     }
 
     /**
@@ -130,6 +133,7 @@
 	super.onActivityResult(requestCode, resultCode, data);
 	if (requestCode == REQUEST_CODE) {
 	    if (resultCode == RESULT_OK) {
+		mListContact.clear();
 		stopService(SERVICE_INTENT);
 		finish();
 		startActivity(new Intent(this, Login.class));
@@ -159,8 +163,8 @@
 
     @Override
     protected void onDestroy() {
-        super.onDestroy();
-        this.unregisterReceiver(mReceiver);
+	super.onDestroy();
+	this.unregisterReceiver(mReceiver);
     }
 
     /**
@@ -297,6 +301,18 @@
     }
 
     /**
+     * Prepare Bitmap Map.
+     */
+    private void prepareIconsStatus(){
+	mIconsMap.put(Status.CONTACT_STATUS_AVAILABLE, BitmapFactory.decodeResource(getResources(), R.drawable.status_available));
+	mIconsMap.put(Status.CONTACT_STATUS_AVAILABLE_FOR_CHAT, BitmapFactory.decodeResource(getResources(), R.drawable.status_available));
+	mIconsMap.put(Status.CONTACT_STATUS_AWAY, BitmapFactory.decodeResource(getResources(), R.drawable.status_away));
+	mIconsMap.put(Status.CONTACT_STATUS_BUSY, BitmapFactory.decodeResource(getResources(), R.drawable.status_dnd));
+	mIconsMap.put(Status.CONTACT_STATUS_DISCONNECT, BitmapFactory.decodeResource(getResources(), R.drawable.status_offline));
+	mIconsMap.put(Status.CONTACT_STATUS_UNAVAILABLE, BitmapFactory.decodeResource(getResources(), R.drawable.status_requested));
+    }
+
+    /**
      * Sort the contact list.
      */
     private void sortBeemContactList() {
@@ -525,32 +541,7 @@
 	    if (curContact != null) {
 		ImageView imgV = (ImageView) view.findViewById(R.id.contactliststatus);
 		TextView v = (TextView) view.findViewById(R.id.contactlistpseudo);
-		Drawable imageDrawable = null;
-		switch (curContact.getStatus()) {
-		    case Status.CONTACT_STATUS_AVAILABLE:
-			imageDrawable = getResources().getDrawable(R.drawable.status_available);
-			break;
-		    case Status.CONTACT_STATUS_AVAILABLE_FOR_CHAT:
-			imageDrawable = getResources().getDrawable(R.drawable.status_available);
-			break;
-		    case Status.CONTACT_STATUS_AWAY:
-			imageDrawable = getResources().getDrawable(R.drawable.status_away);
-			break;
-		    case Status.CONTACT_STATUS_BUSY:
-			imageDrawable = getResources().getDrawable(R.drawable.status_dnd);
-			break;
-		    case Status.CONTACT_STATUS_DISCONNECT:
-			imageDrawable = getResources().getDrawable(R.drawable.status_offline);
-			break;
-		    case Status.CONTACT_STATUS_UNAVAILABLE:
-			imageDrawable = getResources().getDrawable(R.drawable.status_requested);
-			break;
-		    default:
-			imageDrawable = getResources().getDrawable(R.drawable.status_error);
-			break;
-		}
-		imgV.setImageDrawable(imageDrawable);
-
+		imgV.setImageBitmap(mIconsMap.get(curContact.getStatus()));
 		v.setText(curContact.getName());
 		v.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
 		v.setTextColor(Color.WHITE);
@@ -684,6 +675,9 @@
 	    }
 	    mXmppFacade = null;
 	    mRoster = null;
+	    mListContact.clear();
+	    mListGroup.clear();
+	    mContactOnGroup.clear();
 	    mReceiver.setBinded(false);
 	}
     }