Added contactsUpdated callback on GroupChatFragment

This commit is contained in:
Sylvain Berfini 2017-10-24 10:44:40 +02:00
parent 313a80d517
commit a91f3b4f99

View file

@ -49,13 +49,14 @@ import org.linphone.core.ChatRoomListener;
import org.linphone.core.Content;
import org.linphone.core.Core;
import org.linphone.core.Participant;
import org.linphone.receivers.ContactsUpdatedListener;
import java.util.ArrayList;
import java.util.List;
import static org.linphone.fragments.FragmentsAvailable.CHAT;
public class GroupChatFragment extends Fragment implements ChatRoomListener {
public class GroupChatFragment extends Fragment implements ChatRoomListener, ContactsUpdatedListener {
private ImageView mBackButton, mCallButton, mBackToCallButton, mGroupInfosButton, mEditButton;
private ImageView mCancelEditButton, mSelectAllButton, mDeselectAllButton, mDeleteSelectionButton;
private ImageView mAttachImageButton, mSendMessageButton;
@ -222,24 +223,20 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener {
if (LinphoneActivity.isInstanciated()) {
LinphoneActivity.instance().selectMenu(CHAT);
}
ContactsManager.addContactsListener(this);
initChatRoom();
displayChatRoomHeader();
displayChatRoomHistory();
}
private void initChatRoom() {
Core core = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
if (mRemoteSipAddress == null || mRemoteSipUri == null || mRemoteSipUri.length() == 0 || core == null) {
LinphoneActivity.instance().goToDialerFragment();
return;
}
mChatRoom = core.getChatRoom(mRemoteSipAddress);
mChatRoom.setListener(this);
mChatRoom.markAsRead();
LinphoneActivity.instance().updateMissedChatCount();
@Override
public void onPause() {
ContactsManager.removeContactsListener(this);
super.onPause();
}
private void getContactsForParticipants() {
mParticipants = new ArrayList<>();
if (mChatRoom.canHandleParticipants()) {
for (Participant p : mChatRoom.getParticipants()) {
@ -256,6 +253,21 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener {
}
}
private void initChatRoom() {
Core core = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
if (mRemoteSipAddress == null || mRemoteSipUri == null || mRemoteSipUri.length() == 0 || core == null) {
LinphoneActivity.instance().goToDialerFragment();
return;
}
mChatRoom = core.getChatRoom(mRemoteSipAddress);
mChatRoom.setListener(this);
mChatRoom.markAsRead();
LinphoneActivity.instance().updateMissedChatCount();
getContactsForParticipants();
}
private void displayChatRoomHeader() {
Core core = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
if (core == null) return;
@ -457,4 +469,9 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener {
}
}
}
@Override
public void onContactsUpdated() {
getContactsForParticipants();
}
}