# HG changeset patch # User Nikita Kozlov # Date 1320253266 -3600 # Node ID 391114f750f0f6972ba65a847ed465494580d302 # Parent 46ca87505a619735c04eeefd631a03cd6ebf398f GroupBanner show or not and update after sync G: -- diff -r 46ca87505a61 -r 391114f750f0 default.properties --- a/default.properties Fri Oct 28 19:12:38 2011 +0200 +++ b/default.properties Wed Nov 02 18:01:06 2011 +0100 @@ -1,11 +1,2 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must be checked in Version Control Systems. -# -# To customize properties used by the Ant build system use, -# "build.properties", and override values to adapt the script to your -# project structure. - # Project target. -target=android-8 +target=android-14 diff -r 46ca87505a61 -r 391114f750f0 src/com/beem/project/beem/ui/ContactList.java --- a/src/com/beem/project/beem/ui/ContactList.java Fri Oct 28 19:12:38 2011 +0200 +++ b/src/com/beem/project/beem/ui/ContactList.java Wed Nov 02 18:01:06 2011 +0100 @@ -37,9 +37,11 @@ import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; +import android.database.ContentObserver; import android.database.Cursor; import android.net.Uri; import android.os.Bundle; +import android.os.Handler; import android.os.RemoteException; import android.preference.PreferenceManager; import android.provider.ContactsContract; @@ -124,7 +126,7 @@ ContactsContract.Groups.ACCOUNT_NAME + "=?", new String[] { mAccountName }, null); mAdapterBanner = new BeemBanner(this, R.layout.contactlist_group, cursorGroup, new String[] { ContactsContract.Groups.TITLE }, new int[] { R.id.contactlist_group }); - + cursorGroup.registerContentObserver(new BeemGroupObserver(new Handler())); // Get Contacts list // TODO: Get contact list by account -> Create Sqlite View or join final Cursor cursorContact = getContentResolver().query(ContactsContract.RawContacts.CONTENT_URI, @@ -281,13 +283,16 @@ * Show the groups view. */ private void showGroups() { - ViewStub stub = (ViewStub) findViewById(R.id.contactlist_stub); if (stub != null) { View v = stub.inflate(); Gallery g = (Gallery) v.findViewById(R.id.contactlist_banner); g.setOnItemClickListener(new OnItemClickGroupName()); g.setAdapter(mAdapterBanner); + if (mAdapterBanner.getCount() == 0) + v.setVisibility(View.GONE); + else + v.setVisibility(View.VISIBLE); } } @@ -518,4 +523,30 @@ } } + private class BeemGroupObserver extends ContentObserver { + + public BeemGroupObserver(Handler handler) { + super(handler); + } + + @Override + public boolean deliverSelfNotifications() { + return true; + } + + @Override + public void onChange(boolean selfChange) { + super.onChange(selfChange); + View v = findViewById(R.id.contactlist_groupstub); + if (v != null) { + if (mAdapterBanner.getCount() > 0) { + v.setVisibility(View.VISIBLE); + } else { + v.setVisibility(View.GONE); + } + } + } + + } + }