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
|
* @author Sylvain Berfini
|
||||||
*/
|
*/
|
||||||
public class ContactDetailsFragment extends Fragment implements OnClickListener, ContactsUpdatedListener {
|
public class ContactDetailsFragment extends Fragment implements OnClickListener {
|
||||||
private LinphoneContact contact;
|
private LinphoneContact contact;
|
||||||
private ImageView editContact, deleteContact, back;
|
private ImageView editContact, deleteContact, back;
|
||||||
private LayoutInflater inflater;
|
private LayoutInflater inflater;
|
||||||
|
@ -106,12 +106,6 @@ public class ContactDetailsFragment extends Fragment implements OnClickListener,
|
||||||
contact = newContact;
|
contact = newContact;
|
||||||
displayContact(inflater, view);
|
displayContact(inflater, view);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onContactsUpdated() {
|
|
||||||
contact.refresh();
|
|
||||||
displayContact(inflater, view);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressLint("InflateParams")
|
@SuppressLint("InflateParams")
|
||||||
private void displayContact(LayoutInflater inflater, View view) {
|
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
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
ContactsManager.addContactsListener(this);
|
|
||||||
|
|
||||||
if (LinphoneActivity.isInstanciated()) {
|
if (LinphoneActivity.isInstanciated()) {
|
||||||
LinphoneActivity.instance().selectMenu(FragmentsAvailable.CONTACT_DETAIL);
|
LinphoneActivity.instance().selectMenu(FragmentsAvailable.CONTACT_DETAIL);
|
||||||
|
|
|
@ -51,7 +51,7 @@ import android.widget.TextView;
|
||||||
* @author Sylvain Berfini
|
* @author Sylvain Berfini
|
||||||
*/
|
*/
|
||||||
@SuppressLint("DefaultLocale")
|
@SuppressLint("DefaultLocale")
|
||||||
public class ContactsListFragment extends Fragment implements OnClickListener, OnItemClickListener, ContactsUpdatedListener {
|
public class ContactsListFragment extends Fragment implements OnClickListener, OnItemClickListener {
|
||||||
private LayoutInflater mInflater;
|
private LayoutInflater mInflater;
|
||||||
private ListView contactsList;
|
private ListView contactsList;
|
||||||
private TextView noSipContact, noContact;
|
private TextView noSipContact, noContact;
|
||||||
|
@ -369,7 +369,6 @@ public class ContactsListFragment extends Fragment implements OnClickListener, O
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
instance = this;
|
instance = this;
|
||||||
ContactsManager.addContactsListener(this);
|
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
if (editConsumed) {
|
if (editConsumed) {
|
||||||
|
@ -389,14 +388,8 @@ public class ContactsListFragment extends Fragment implements OnClickListener, O
|
||||||
@Override
|
@Override
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
instance = null;
|
instance = null;
|
||||||
ContactsManager.removeContactsListener(this);
|
|
||||||
super.onPause();
|
super.onPause();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onContactsUpdated() {
|
|
||||||
invalidate();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void invalidate() {
|
public void invalidate() {
|
||||||
if (searchField != null && searchField.getText().toString().length() > 0) {
|
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<?>) {
|
if (msg.what == CONTACTS_UPDATED && msg.obj instanceof List<?>) {
|
||||||
List<LinphoneContact> c = (List<LinphoneContact>) msg.obj;
|
List<LinphoneContact> c = (List<LinphoneContact>) msg.obj;
|
||||||
ContactsManager.getInstance().setContacts(c);
|
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) {
|
private ContactsManager(Handler handler) {
|
||||||
super(handler);
|
super(handler);
|
||||||
contactsListeners = new ArrayList<ContactsUpdatedListener>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -86,7 +74,7 @@ public class ContactsManager extends ContentObserver {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onChange(boolean selfChange, Uri uri) {
|
public void onChange(boolean selfChange, Uri uri) {
|
||||||
List<LinphoneContact> contacts = fetchContactsInBackground();
|
List<LinphoneContact> contacts = fetchContactsAsync();
|
||||||
Message msg = handler.obtainMessage();
|
Message msg = handler.obtainMessage();
|
||||||
msg.what = CONTACTS_UPDATED;
|
msg.what = CONTACTS_UPDATED;
|
||||||
msg.obj = contacts;
|
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>();
|
List<LinphoneContact> contacts = new ArrayList<LinphoneContact>();
|
||||||
|
|
||||||
for (LinphoneFriend friend : LinphoneManager.getLc().getFriendList()) {
|
for (LinphoneFriend friend : LinphoneManager.getLc().getFriendList()) {
|
||||||
|
|
Loading…
Reference in a new issue