# HG changeset patch # User Vincent Veronis # Date 1256938691 -3600 # Node ID 77e8f3384a3b6386a1546367711060bbc04e37b1 # Parent 6122f9ed186f9f71e58e72208e0c0c8042b6f3f8# Parent 776575982b48e7c962af83df54a741046346d99e Merge. diff -r 6122f9ed186f -r 77e8f3384a3b .classpath --- a/.classpath Fri Oct 30 19:25:20 2009 +0100 +++ b/.classpath Fri Oct 30 22:38:11 2009 +0100 @@ -8,7 +8,7 @@ - + diff -r 6122f9ed186f -r 77e8f3384a3b AndroidManifest.xml --- 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"> + android:theme="@style/Theme.BEEM.Default" android:debuggable="true" + android:name="@string/app_name" + > diff -r 6122f9ed186f -r 77e8f3384a3b src/com/beem/project/beem/service/RosterAdapter.java --- 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; } diff -r 6122f9ed186f -r 77e8f3384a3b src/com/beem/project/beem/ui/ContactList.java --- 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 mIconsMap = new HashMap(); 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); } }