use of net.iGap.request.RequestChannelAddMember in project iGap-Android by KianIranian-STDG.
the class FragmentShowMember method goToAddMember.
private void goToAddMember() {
List<StructContactInfo> userList = Contacts.retrieve(null);
RealmList<RealmMember> memberList = DbManager.getInstance().doRealmTask(realm -> {
return RealmMember.getMembers(realm, mRoomID);
});
for (int i = 0; i < memberList.size(); i++) {
for (int j = 0; j < userList.size(); j++) {
if (userList.get(j).peerId == memberList.get(i).getPeerId()) {
userList.remove(j);
break;
}
}
}
if (getActivity() != null) {
ShowCustomList showCustomListFragment = new ShowCustomList();
showCustomListFragment.setFields(roomType, userList, new OnSelectedList() {
@Override
public void getSelectedList(boolean result, String message, int countForShowLastMessage, final ArrayList<StructContactInfo> list) {
if (isGroup) {
for (int i = 0; i < list.size(); i++) {
new RequestGroupAddMember().groupAddMember(mRoomID, list.get(i).peerId, RealmRoomMessage.findCustomMessageId(mRoomID, countForShowLastMessage));
}
} else {
for (int i = 0; i < list.size(); i++) {
new RequestChannelAddMember().channelAddMember(mRoomID, list.get(i).peerId);
}
}
}
});
Bundle bundle = new Bundle();
bundle.putBoolean("DIALOG_SHOWING", true);
bundle.putLong("COUNT_MESSAGE", 0);
showCustomListFragment.setArguments(bundle);
new HelperFragment(getActivity().getSupportFragmentManager(), showCustomListFragment).setReplace(false).load();
}
}
use of net.iGap.request.RequestChannelAddMember in project iGap-Android by KianIranian-STDG.
the class ContactGroupFragment method onRightIconClickListener.
@Override
public void onRightIconClickListener(View view) {
fixChipsLayoutShowingState();
if (typeCreate.equals("CHANNEL")) {
G.onChannelAddMember = new OnChannelAddMember() {
@Override
public void onChannelAddMember(Long RoomId, Long UserId, ProtoGlobal.ChannelRoom.Role role) {
G.runOnUiThread(() -> {
progressDialog.dismiss();
countAddMemberResponse++;
addMember(RoomId, ProtoGlobal.Room.Type.CHANNEL);
countMember++;
if (countAddMemberResponse == countAddMemberRequest) {
addMember(RoomId, ProtoGlobal.Room.Type.CHANNEL);
}
});
}
@Override
public void onError(int majorCode, int minorCode) {
G.runOnUiThread(() -> {
progressDialog.dismiss();
countAddMemberResponse++;
if (countAddMemberResponse == countAddMemberRequest) {
addMember(roomId, ProtoGlobal.Room.Type.CHANNEL);
}
HelperError.showSnackMessage(requireContext().getResources().getString(R.string.error), false);
});
}
@Override
public void onTimeOut() {
G.runOnUiThread(() -> {
progressDialog.dismiss();
HelperError.showSnackMessage(requireContext().getResources().getString(R.string.time_out), false);
});
}
};
ArrayList<Long> list = getSelectedList();
if (list.size() > 0) {
for (long peerId : list) {
new RequestChannelAddMember().channelAddMember(roomId, peerId);
progressDialog.show();
progressDialog.setCancelable(false);
}
} else {
if (isAdded()) {
if (getActivity() instanceof ActivityMain) {
((ActivityMain) getActivity()).removeAllFragmentFromMain();
new GoToChatActivity(ContactGroupFragment.this.roomId).startActivity(getActivity());
}
}
}
} else if (typeCreate.equals("GROUP")) {
if (roomId == -127) {
if (getActivity() != null) {
FragmentNewGroup fragment = FragmentNewGroup.newInstance();
Bundle bundle_ = new Bundle();
bundle_.putString("TYPE", "NewGroup");
fragment.setArguments(bundle_);
new HelperFragment(getActivity().getSupportFragmentManager(), fragment).setReplace(false).load(true);
return;
}
}
G.onGroupAddMember = new OnGroupAddMember() {
@Override
public void onGroupAddMember(Long roomId, Long UserId) {
countAddMemberResponse++;
countMember++;
if (countAddMemberResponse == countAddMemberRequest) {
addMember(roomId, ProtoGlobal.Room.Type.GROUP);
}
}
@Override
public void onError(int majorCode, int minorCode) {
countAddMemberResponse++;
if (countAddMemberResponse == countAddMemberRequest) {
addMember(roomId, ProtoGlobal.Room.Type.GROUP);
}
}
};
/**
* request add member for group
*/
ArrayList<Long> list = getSelectedList();
if (list.size() > 0) {
for (long peerId : list) {
new RequestGroupAddMember().groupAddMember(roomId, peerId, 0);
}
} else {
if (getActivity() != null && isAdded()) {
removeFromBaseFragment(ContactGroupFragment.this);
new GoToChatActivity(ContactGroupFragment.this.roomId).startActivity(getActivity());
}
}
}
}
Aggregations