Added contactsUpdated callback on GroupChatFragment
This commit is contained in:
parent
313a80d517
commit
a91f3b4f99
1 changed files with 29 additions and 12 deletions
|
@ -49,13 +49,14 @@ import org.linphone.core.ChatRoomListener;
|
||||||
import org.linphone.core.Content;
|
import org.linphone.core.Content;
|
||||||
import org.linphone.core.Core;
|
import org.linphone.core.Core;
|
||||||
import org.linphone.core.Participant;
|
import org.linphone.core.Participant;
|
||||||
|
import org.linphone.receivers.ContactsUpdatedListener;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static org.linphone.fragments.FragmentsAvailable.CHAT;
|
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 mBackButton, mCallButton, mBackToCallButton, mGroupInfosButton, mEditButton;
|
||||||
private ImageView mCancelEditButton, mSelectAllButton, mDeselectAllButton, mDeleteSelectionButton;
|
private ImageView mCancelEditButton, mSelectAllButton, mDeselectAllButton, mDeleteSelectionButton;
|
||||||
private ImageView mAttachImageButton, mSendMessageButton;
|
private ImageView mAttachImageButton, mSendMessageButton;
|
||||||
|
@ -222,24 +223,20 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener {
|
||||||
if (LinphoneActivity.isInstanciated()) {
|
if (LinphoneActivity.isInstanciated()) {
|
||||||
LinphoneActivity.instance().selectMenu(CHAT);
|
LinphoneActivity.instance().selectMenu(CHAT);
|
||||||
}
|
}
|
||||||
|
ContactsManager.addContactsListener(this);
|
||||||
|
|
||||||
initChatRoom();
|
initChatRoom();
|
||||||
displayChatRoomHeader();
|
displayChatRoomHeader();
|
||||||
displayChatRoomHistory();
|
displayChatRoomHistory();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initChatRoom() {
|
@Override
|
||||||
Core core = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
public void onPause() {
|
||||||
if (mRemoteSipAddress == null || mRemoteSipUri == null || mRemoteSipUri.length() == 0 || core == null) {
|
ContactsManager.removeContactsListener(this);
|
||||||
LinphoneActivity.instance().goToDialerFragment();
|
super.onPause();
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
mChatRoom = core.getChatRoom(mRemoteSipAddress);
|
|
||||||
mChatRoom.setListener(this);
|
|
||||||
mChatRoom.markAsRead();
|
|
||||||
LinphoneActivity.instance().updateMissedChatCount();
|
|
||||||
|
|
||||||
|
private void getContactsForParticipants() {
|
||||||
mParticipants = new ArrayList<>();
|
mParticipants = new ArrayList<>();
|
||||||
if (mChatRoom.canHandleParticipants()) {
|
if (mChatRoom.canHandleParticipants()) {
|
||||||
for (Participant p : mChatRoom.getParticipants()) {
|
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() {
|
private void displayChatRoomHeader() {
|
||||||
Core core = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
Core core = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
if (core == null) return;
|
if (core == null) return;
|
||||||
|
@ -457,4 +469,9 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onContactsUpdated() {
|
||||||
|
getContactsForParticipants();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue