merged
authornikita@nikita-lab
Fri, 22 May 2009 15:43:31 +0200
changeset 198 088857b09c7d
parent 195 fb0591e482d8 (diff)
parent 197 73b3c7576722 (current diff)
child 199 32104eafe784
merged
src/com/beem/project/beem/ui/ContactDialog.java
src/com/beem/project/beem/ui/ContactList.java
--- a/src/com/beem/project/beem/ui/ContactDialog.java	Fri May 22 15:07:35 2009 +0200
+++ b/src/com/beem/project/beem/ui/ContactDialog.java	Fri May 22 15:43:31 2009 +0200
@@ -6,6 +6,7 @@
 import android.content.Intent;
 import android.view.View;
 import android.widget.Button;
+import android.widget.TextView;
 
 import com.beem.project.beem.R;
 import com.beem.project.beem.service.Contact;
@@ -16,22 +17,23 @@
     private Contact mContact;
     private Context mContext;
 
-    public ContactDialog(final Context context, Contact c) {
+    public ContactDialog(final Context context, Contact curContact, Intent curIntent) {
 	super(context);
 	mContext = context;
 	setContentView(R.layout.contactdialog);
-	mContact = c;
-	setTitle(c.getJID());
+	mContact = curContact;
+	setTitle(curContact.getJID());
 		
 	Button chat = (Button) findViewById(R.id.chat);
 	chat.setOnClickListener(new View.OnClickListener() {
 
 	    @Override
 	    public void onClick(View v) {
-		Activity a = ContactDialog.this.getOwnerActivity();
+		/*Activity a = ContactDialog.this.getOwnerActivity();
 		Intent i = new Intent(mContext, SendIM.class);
 		i.putExtra("contact", mContact);
-		a.startActivity(i);
+		a.startActivity(i);*/
+		String type = ((TextView) v).getText();
 		dismiss();
 	    }
 	    
--- a/src/com/beem/project/beem/ui/ContactList.java	Fri May 22 15:07:35 2009 +0200
+++ b/src/com/beem/project/beem/ui/ContactList.java	Fri May 22 15:43:31 2009 +0200
@@ -65,6 +65,18 @@
 	mRosterListener = new BeemRosterListener();
 	mSettings = getSharedPreferences(getString(R.string.PreferenceFileName), MODE_PRIVATE);
 	mBeemApplication = BeemApplication.getApplication(this);
+<<<<<<< local
+	groupMap = new HashMap<String, List<Contact>>();
+	groupName = new ArrayList<String>();
+	mBeemApplication.callWhenConnectedToServer(mHandler, new Runnable() {
+	    @Override
+	    public void run() {
+		mService = mBeemApplication.getXmppFacade();
+		try {
+		    mRoster = mService.getRoster();
+		} catch (RemoteException e1) {
+		    Log.e(TAG, "Get roster failed", e1);
+=======
 
 	//TODO: a refaire
 	/*if (mSettings.getString(getString(R.string.PreferenceHostKey), "").equals(""))
@@ -75,6 +87,7 @@
 		protected void onResume() {	
 			super.onResume();
 
+>>>>>>> other
 		}
 
 	@Override
@@ -82,14 +95,31 @@
 			mBeemApplication.unbindBeemService();
 			super.onDestroy();
 		}
+<<<<<<< local
+		callbackShowContactList();
+	    }
+	});
+	//TODO: a refaire
+	if (mSettings.getString(getString(R.string.PreferenceHostKey), "").equals(""))
+	    startActivityForResult(new Intent(ContactList.this, ContactListSettings.class), PREFERENCECHANGED);
+    }    
+
+    @Override
+    protected void onDestroy() {
+	mBeemApplication.unbindBeemService();
+	super.onDestroy();	
+    }
+=======
+>>>>>>> other
 
     private void callbackShowContactList() {
-	if (mRoster != null)
+	if (mRoster != null) {
 	    try {
 		buildContactList(mRoster.getContactList());
 	    } catch (RemoteException e) {
 		e.printStackTrace();
 	    }
+	}
     }
 
     /**
@@ -143,12 +173,26 @@
 		mBeemApplication.stopBeemService();
 	    }
 	}
+<<<<<<< local
+    }
+
+    @Override
+    public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
+	Intent i = new Intent(ContactList.this, SendIM.class);
+	try {
+	    i.putExtra("contact", groupMap.get(groupName.get(groupPosition)).get(childPosition));
+	    startActivity(i);
+	    return true;
+	} catch (NullPointerException e) {
+	    Log.e(TAG, "Child not found", e);
+	    return false;
+	}
+=======
+>>>>>>> other
     }
 
     private void buildContactList(List<Contact> listContact) {
-	mListContact = listContact;
-	groupMap = new HashMap<String, List<Contact>>();
-	groupName = new ArrayList<String>();
+	mListContact = listContact;	
 	for (Contact contact : listContact) {
 	    for (String group : contact.getGroups()) {
 		if (!groupMap.containsKey(group)) {
@@ -156,7 +200,8 @@
 		    groupName.add(group);
 		}
 		try {
-		    groupMap.get(group).add(contact);
+		    if (!groupMap.get(group).contains(contact))
+			groupMap.get(group).add(contact);
 		} catch (NullPointerException e) {
 		    Log.e(TAG, "Failed to find group in groupMap", e);
 		}