Search in sources :

Example 1 with OnSelectedList

use of net.iGap.observers.interfaces.OnSelectedList 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();
    }
}
Also used : StructContactInfo(net.iGap.module.structs.StructContactInfo) Bundle(android.os.Bundle) OnSelectedList(net.iGap.observers.interfaces.OnSelectedList) RequestGroupAddMember(net.iGap.request.RequestGroupAddMember) HelperFragment(net.iGap.helper.HelperFragment) RealmMember(net.iGap.realm.RealmMember) RequestChannelAddMember(net.iGap.request.RequestChannelAddMember)

Aggregations

Bundle (android.os.Bundle)1 HelperFragment (net.iGap.helper.HelperFragment)1 StructContactInfo (net.iGap.module.structs.StructContactInfo)1 OnSelectedList (net.iGap.observers.interfaces.OnSelectedList)1 RealmMember (net.iGap.realm.RealmMember)1 RequestChannelAddMember (net.iGap.request.RequestChannelAddMember)1 RequestGroupAddMember (net.iGap.request.RequestGroupAddMember)1