Fixed code duplication
This commit is contained in:
parent
528edd5f97
commit
42322ad324
2 changed files with 28 additions and 38 deletions
|
@ -77,26 +77,21 @@ public class ContactDetailsFragment extends Fragment implements OnClickListener
|
|||
LinphoneActivity.instance().goToChat(room.getPeerAddress().asStringUriOnly());
|
||||
} else {
|
||||
mWaitLayout.setVisibility(View.VISIBLE);
|
||||
room = lc.findOneToOneChatRoom(lc.getDefaultProxyConfig().getContact(), participant);
|
||||
if (room == null) {
|
||||
room = LinphoneManager.getLc().createClientGroupChatRoom(getString(R.string.dummy_group_chat_subject));
|
||||
room.setListener(new ChatRoomListenerStub() {
|
||||
@Override
|
||||
public void onStateChanged(ChatRoom cr, ChatRoom.State newState) {
|
||||
if (newState == ChatRoom.State.Created) {
|
||||
mWaitLayout.setVisibility(View.GONE);
|
||||
LinphoneActivity.instance().goToChat(cr.getPeerAddress().asStringUriOnly());
|
||||
} else if (newState == ChatRoom.State.CreationFailed) {
|
||||
mWaitLayout.setVisibility(View.GONE);
|
||||
LinphoneActivity.instance().displayChatRoomError();
|
||||
Log.e("Group chat room for address " + cr.getPeerAddress() + " has failed !");
|
||||
}
|
||||
room = LinphoneManager.getLc().createClientGroupChatRoom(getString(R.string.dummy_group_chat_subject));
|
||||
room.setListener(new ChatRoomListenerStub() {
|
||||
@Override
|
||||
public void onStateChanged(ChatRoom cr, ChatRoom.State newState) {
|
||||
if (newState == ChatRoom.State.Created) {
|
||||
mWaitLayout.setVisibility(View.GONE);
|
||||
LinphoneActivity.instance().goToChat(cr.getPeerAddress().asStringUriOnly());
|
||||
} else if (newState == ChatRoom.State.CreationFailed) {
|
||||
mWaitLayout.setVisibility(View.GONE);
|
||||
LinphoneActivity.instance().displayChatRoomError();
|
||||
Log.e("Group chat room for address " + cr.getPeerAddress() + " has failed !");
|
||||
}
|
||||
});
|
||||
room.addParticipant(participant);
|
||||
} else {
|
||||
LinphoneActivity.instance().goToChat(room.getPeerAddress().asStringUriOnly());
|
||||
}
|
||||
}
|
||||
});
|
||||
room.addParticipant(participant);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -176,26 +176,21 @@ public class HistoryDetailFragment extends Fragment implements OnClickListener {
|
|||
LinphoneActivity.instance().goToChat(room.getPeerAddress().asStringUriOnly());
|
||||
} else {
|
||||
mWaitLayout.setVisibility(View.VISIBLE);
|
||||
room = lc.findOneToOneChatRoom(lc.getDefaultProxyConfig().getContact(), participant);
|
||||
if (room == null) {
|
||||
room = lc.createClientGroupChatRoom(getString(R.string.dummy_group_chat_subject));
|
||||
room.setListener(new ChatRoomListenerStub() {
|
||||
@Override
|
||||
public void onStateChanged(ChatRoom cr, ChatRoom.State newState) {
|
||||
if (newState == ChatRoom.State.Created) {
|
||||
mWaitLayout.setVisibility(View.GONE);
|
||||
LinphoneActivity.instance().goToChat(cr.getPeerAddress().asStringUriOnly());
|
||||
} else if (newState == ChatRoom.State.CreationFailed) {
|
||||
mWaitLayout.setVisibility(View.GONE);
|
||||
LinphoneActivity.instance().displayChatRoomError();
|
||||
Log.e("Group chat room for address " + cr.getPeerAddress() + " has failed !");
|
||||
}
|
||||
room = lc.createClientGroupChatRoom(getString(R.string.dummy_group_chat_subject));
|
||||
room.setListener(new ChatRoomListenerStub() {
|
||||
@Override
|
||||
public void onStateChanged(ChatRoom cr, ChatRoom.State newState) {
|
||||
if (newState == ChatRoom.State.Created) {
|
||||
mWaitLayout.setVisibility(View.GONE);
|
||||
LinphoneActivity.instance().goToChat(cr.getPeerAddress().asStringUriOnly());
|
||||
} else if (newState == ChatRoom.State.CreationFailed) {
|
||||
mWaitLayout.setVisibility(View.GONE);
|
||||
LinphoneActivity.instance().displayChatRoomError();
|
||||
Log.e("Group chat room for address " + cr.getPeerAddress() + " has failed !");
|
||||
}
|
||||
});
|
||||
room.addParticipant(participant);
|
||||
} else {
|
||||
LinphoneActivity.instance().goToChat(room.getPeerAddress().asStringUriOnly());
|
||||
}
|
||||
}
|
||||
});
|
||||
room.addParticipant(participant);
|
||||
}
|
||||
} else if (id == R.id.add_contact) {
|
||||
Address addr = Factory.instance().createAddress(sipUri);
|
||||
|
|
Loading…
Reference in a new issue