Actually previous changes weren't all required...
This commit is contained in:
parent
da2214936a
commit
1bbc54da96
3 changed files with 4 additions and 36 deletions
|
@ -36,7 +36,7 @@ import android.widget.TextView;
|
|||
/**
|
||||
* @author Sylvain Berfini
|
||||
*/
|
||||
public class ContactDetailsFragment extends Fragment implements OnClickListener, ContactsUpdatedListener {
|
||||
public class ContactDetailsFragment extends Fragment implements OnClickListener {
|
||||
private LinphoneContact contact;
|
||||
private ImageView editContact, deleteContact, back;
|
||||
private LayoutInflater inflater;
|
||||
|
@ -106,12 +106,6 @@ public class ContactDetailsFragment extends Fragment implements OnClickListener,
|
|||
contact = newContact;
|
||||
displayContact(inflater, view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContactsUpdated() {
|
||||
contact.refresh();
|
||||
displayContact(inflater, view);
|
||||
}
|
||||
|
||||
@SuppressLint("InflateParams")
|
||||
private void displayContact(LayoutInflater inflater, View view) {
|
||||
|
@ -211,16 +205,9 @@ public class ContactDetailsFragment extends Fragment implements OnClickListener,
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
ContactsManager.removeContactsListener(this);
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
ContactsManager.addContactsListener(this);
|
||||
|
||||
if (LinphoneActivity.isInstanciated()) {
|
||||
LinphoneActivity.instance().selectMenu(FragmentsAvailable.CONTACT_DETAIL);
|
||||
|
|
|
@ -51,7 +51,7 @@ import android.widget.TextView;
|
|||
* @author Sylvain Berfini
|
||||
*/
|
||||
@SuppressLint("DefaultLocale")
|
||||
public class ContactsListFragment extends Fragment implements OnClickListener, OnItemClickListener, ContactsUpdatedListener {
|
||||
public class ContactsListFragment extends Fragment implements OnClickListener, OnItemClickListener {
|
||||
private LayoutInflater mInflater;
|
||||
private ListView contactsList;
|
||||
private TextView noSipContact, noContact;
|
||||
|
@ -369,7 +369,6 @@ public class ContactsListFragment extends Fragment implements OnClickListener, O
|
|||
@Override
|
||||
public void onResume() {
|
||||
instance = this;
|
||||
ContactsManager.addContactsListener(this);
|
||||
super.onResume();
|
||||
|
||||
if (editConsumed) {
|
||||
|
@ -389,14 +388,8 @@ public class ContactsListFragment extends Fragment implements OnClickListener, O
|
|||
@Override
|
||||
public void onPause() {
|
||||
instance = null;
|
||||
ContactsManager.removeContactsListener(this);
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContactsUpdated() {
|
||||
invalidate();
|
||||
}
|
||||
|
||||
public void invalidate() {
|
||||
if (searchField != null && searchField.getText().toString().length() > 0) {
|
||||
|
|
|
@ -59,24 +59,12 @@ public class ContactsManager extends ContentObserver {
|
|||
if (msg.what == CONTACTS_UPDATED && msg.obj instanceof List<?>) {
|
||||
List<LinphoneContact> c = (List<LinphoneContact>) msg.obj;
|
||||
ContactsManager.getInstance().setContacts(c);
|
||||
for (ContactsUpdatedListener listener : contactsListeners) {
|
||||
listener.onContactsUpdated();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private static ArrayList<ContactsUpdatedListener> contactsListeners;
|
||||
public static void addContactsListener(ContactsUpdatedListener listener) {
|
||||
contactsListeners.add(listener);
|
||||
}
|
||||
public static void removeContactsListener(ContactsUpdatedListener listener) {
|
||||
contactsListeners.remove(listener);
|
||||
}
|
||||
|
||||
private ContactsManager(Handler handler) {
|
||||
super(handler);
|
||||
contactsListeners = new ArrayList<ContactsUpdatedListener>();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -86,7 +74,7 @@ public class ContactsManager extends ContentObserver {
|
|||
|
||||
@Override
|
||||
public void onChange(boolean selfChange, Uri uri) {
|
||||
List<LinphoneContact> contacts = fetchContactsInBackground();
|
||||
List<LinphoneContact> contacts = fetchContactsAsync();
|
||||
Message msg = handler.obtainMessage();
|
||||
msg.what = CONTACTS_UPDATED;
|
||||
msg.obj = contacts;
|
||||
|
@ -199,7 +187,7 @@ public class ContactsManager extends ContentObserver {
|
|||
}
|
||||
}
|
||||
|
||||
public List<LinphoneContact> fetchContactsInBackground() {
|
||||
public List<LinphoneContact> fetchContactsAsync() {
|
||||
List<LinphoneContact> contacts = new ArrayList<LinphoneContact>();
|
||||
|
||||
for (LinphoneFriend friend : LinphoneManager.getLc().getFriendList()) {
|
||||
|
|
Loading…
Reference in a new issue