Search in sources :

Example 1 with RequestChannelGetMemberList

use of net.iGap.request.RequestChannelGetMemberList in project iGap-Android by KianIranian-STDG.

the class FragmentShowMember method getMemberList.

private void getMemberList() {
    mMemberCount = listMembers.size();
    infoUpdateListenerCount = (result, messageOne, MessageTow) -> {
        if (MessageTow.contains("OK")) {
            new Handler(Looper.getMainLooper()).post(() -> DbManager.getInstance().doRealmTask(realm -> {
                realm.executeTransactionAsync(realm12 -> {
                    final RealmList<RealmMember> newMemberList = new RealmList<>();
                    RealmRoom realmRoom = realm12.where(RealmRoom.class).equalTo("id", mRoomID).findFirst();
                    if (realmRoom != null) {
                        if (realmRoom.getType() == GROUP) {
                            for (ProtoGroupGetMemberList.GroupGetMemberListResponse.Member member : listMembers) {
                                if (Long.parseLong(messageOne) == member.getUserId()) {
                                    mCurrentUpdateCount++;
                                    newMemberList.add(RealmMember.put(realm12, member));
                                    newMemberList.addAll(0, realmRoom.getGroupRoom().getMembers());
                                    realmRoom.getGroupRoom().setMembers(newMemberList);
                                    newMemberList.clear();
                                    break;
                                }
                            }
                        } else {
                            for (ProtoChannelGetMemberList.ChannelGetMemberListResponse.Member member : listMembersChannal) {
                                if (Long.parseLong(messageOne) == member.getUserId()) {
                                    mCurrentUpdateCount++;
                                    newMemberList.add(RealmMember.put(realm12, member));
                                    newMemberList.addAll(0, realmRoom.getChannelRoom().getMembers());
                                    realmRoom.getChannelRoom().setMembers(newMemberList);
                                    newMemberList.clear();
                                    break;
                                }
                            }
                        }
                    }
                }, () -> fillItem());
            }));
        } else {
            mCurrentUpdateCount++;
        }
    };
    G.onGroupGetMemberList = new OnGroupGetMemberList() {

        @Override
        public void onGroupGetMemberList(final List<ProtoGroupGetMemberList.GroupGetMemberListResponse.Member> members) {
            mMemberCount = members.size();
            if (mMemberCount > 0) {
                listMembers.clear();
                for (final ProtoGroupGetMemberList.GroupGetMemberListResponse.Member member : members) {
                    listMembers.add(member);
                    new RequestUserInfo().userInfoWithCallBack(infoUpdateListenerCount, member.getUserId(), "" + member.getUserId());
                }
            } else {
                G.handler.post(() -> {
                    if (progressBar != null) {
                        progressBar.setVisibility(View.GONE);
                    }
                });
                isOne = true;
                if (isFirstFill) {
                    fillAdapter();
                    isFirstFill = false;
                }
            }
        }

        @Override
        public void onError(int majorCode, int minorCode) {
            G.handler.post(() -> {
                if (progressBar != null)
                    progressBar.setVisibility(View.GONE);
                HelperError.showSnackMessage(G.currentActivity.getString(R.string.AccessBan), false);
            });
        }

        @Override
        public void onTimeOut() {
            G.handler.post(() -> {
                if (progressBar != null)
                    progressBar.setVisibility(View.GONE);
                HelperError.showSnackMessage(G.currentActivity.getString(R.string.time_out), false);
            });
        }
    };
    G.onChannelGetMemberList = new OnChannelGetMemberList() {

        @Override
        public void onChannelGetMemberList(List<ProtoChannelGetMemberList.ChannelGetMemberListResponse.Member> members) {
            mMemberCount = members.size();
            if (mMemberCount > 0) {
                listMembersChannal.clear();
                for (final ProtoChannelGetMemberList.ChannelGetMemberListResponse.Member member : members) {
                    listMembersChannal.add(member);
                    new RequestUserInfo().userInfoWithCallBack(infoUpdateListenerCount, member.getUserId(), "" + member.getUserId());
                }
            } else {
                G.handler.post(() -> {
                    if (progressBar != null) {
                        progressBar.setVisibility(View.GONE);
                    }
                });
                isOne = true;
                if (isFirstFill) {
                    fillAdapter();
                    isFirstFill = false;
                }
            }
        }

        @Override
        public void onError(int majorCode, int minorCode) {
            G.handler.post(() -> {
                if (progressBar != null) {
                    progressBar.setVisibility(View.GONE);
                    HelperError.showSnackMessage(requireActivity().getString(R.string.AccessBan), false);
                }
            });
        }

        @Override
        public void onTimeOut() {
            G.handler.post(() -> {
                if (progressBar != null)
                    progressBar.setVisibility(View.GONE);
                HelperError.showSnackMessage(requireActivity().getString(R.string.time_out), false);
            });
        }
    };
    G.handler.post(() -> {
        mCurrentUpdateCount = 0;
        DbManager.getInstance().doRealmTask(realm -> {
            realm.executeTransactionAsync(realm1 -> RealmMember.deleteAllMembers(realm1, mRoomID, selectedRole), () -> {
                if (roomType == GROUP) {
                    new RequestGroupGetMemberList().getMemberList(mRoomID, offset, limit, ProtoGroupGetMemberList.GroupGetMemberList.FilterRole.valueOf(selectedRole));
                } else {
                    new RequestChannelGetMemberList().channelGetMemberList(mRoomID, offset, limit, ProtoChannelGetMemberList.ChannelGetMemberList.FilterRole.valueOf(selectedRole));
                }
            });
        });
    });
}
Also used : LinearLayout(android.widget.LinearLayout) Bundle(android.os.Bundle) AppUtils(net.iGap.module.AppUtils) ToolbarListener(net.iGap.observers.interfaces.ToolbarListener) ProgressBar(android.widget.ProgressBar) LastSeenTimeUtil(net.iGap.module.LastSeenTimeUtil) Theme(net.iGap.module.Theme) G(net.iGap.G) RequestGroupGetMemberList(net.iGap.request.RequestGroupGetMemberList) GroupChatRole(net.iGap.module.enums.GroupChatRole) RealmChannelRoom(net.iGap.realm.RealmChannelRoom) Handler(android.os.Handler) Looper(android.os.Looper) Fragment(androidx.fragment.app.Fragment) View(android.view.View) OnGroupKickMember(net.iGap.observers.interfaces.OnGroupKickMember) HelperError(net.iGap.helper.HelperError) RecyclerView(androidx.recyclerview.widget.RecyclerView) HelperFragment(net.iGap.helper.HelperFragment) RequestGroupAddMember(net.iGap.request.RequestGroupAddMember) ParamWithAvatarType(net.iGap.helper.avatar.ParamWithAvatarType) RealmMember(net.iGap.realm.RealmMember) AsyncTask(android.os.AsyncTask) OnComplete(net.iGap.observers.interfaces.OnComplete) RealmRoom(net.iGap.realm.RealmRoom) RealmGroupRoom(net.iGap.realm.RealmGroupRoom) ViewGroup(android.view.ViewGroup) CHANNEL(net.iGap.proto.ProtoGlobal.Room.Type.CHANNEL) OnGroupGetMemberList(net.iGap.observers.interfaces.OnGroupGetMemberList) List(java.util.List) TextView(android.widget.TextView) Nullable(androidx.annotation.Nullable) RealmRegisteredInfo(net.iGap.realm.RealmRegisteredInfo) RealmRecyclerViewAdapter(io.realm.RealmRecyclerViewAdapter) RequestChannelAddMember(net.iGap.request.RequestChannelAddMember) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) TextCell(net.iGap.adapter.items.cells.TextCell) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) ProtoGroupGetMemberList(net.iGap.proto.ProtoGroupGetMemberList) NotNull(org.jetbrains.annotations.NotNull) EndlessRecyclerViewScrollListener(net.iGap.module.EndlessRecyclerViewScrollListener) TextWatcher(android.text.TextWatcher) HelperToolbar(net.iGap.helper.HelperToolbar) Context(android.content.Context) RequestChannelGetMemberList(net.iGap.request.RequestChannelGetMemberList) RealmList(io.realm.RealmList) AccountManager(net.iGap.module.accountManager.AccountManager) StructContactInfo(net.iGap.module.structs.StructContactInfo) Dialog(android.app.Dialog) Editable(android.text.Editable) DeviceUtils(net.iGap.module.DeviceUtils) ArrayList(java.util.ArrayList) ProtoChannelGetMemberList(net.iGap.proto.ProtoChannelGetMemberList) LayoutCreator(net.iGap.helper.LayoutCreator) Contacts(net.iGap.module.Contacts) RealmRoomMessage(net.iGap.realm.RealmRoomMessage) RequestUserInfo(net.iGap.request.RequestUserInfo) AvatarHandler(net.iGap.helper.avatar.AvatarHandler) OnSelectedList(net.iGap.observers.interfaces.OnSelectedList) RealmRoomAccess(net.iGap.realm.RealmRoomAccess) LayoutInflater(android.view.LayoutInflater) RealmResults(io.realm.RealmResults) CircleImageView(net.iGap.module.CircleImageView) PreCachingLayoutManager(net.iGap.module.PreCachingLayoutManager) Gravity(android.view.Gravity) ProtoGlobal(net.iGap.proto.ProtoGlobal) R(net.iGap.R) ChannelChatRole(net.iGap.module.enums.ChannelChatRole) OnChannelGetMemberList(net.iGap.observers.interfaces.OnChannelGetMemberList) GROUP(net.iGap.proto.ProtoGlobal.Room.Type.GROUP) DbManager(net.iGap.module.accountManager.DbManager) RequestGroupKickMember(net.iGap.request.RequestGroupKickMember) EditText(android.widget.EditText) RequestChannelKickMember(net.iGap.request.RequestChannelKickMember) RealmList(io.realm.RealmList) Handler(android.os.Handler) AvatarHandler(net.iGap.helper.avatar.AvatarHandler) RequestGroupGetMemberList(net.iGap.request.RequestGroupGetMemberList) OnGroupGetMemberList(net.iGap.observers.interfaces.OnGroupGetMemberList) RequestUserInfo(net.iGap.request.RequestUserInfo) RequestChannelGetMemberList(net.iGap.request.RequestChannelGetMemberList) OnChannelGetMemberList(net.iGap.observers.interfaces.OnChannelGetMemberList) RealmRoom(net.iGap.realm.RealmRoom) ProtoChannelGetMemberList(net.iGap.proto.ProtoChannelGetMemberList) OnGroupKickMember(net.iGap.observers.interfaces.OnGroupKickMember) RequestGroupAddMember(net.iGap.request.RequestGroupAddMember) RealmMember(net.iGap.realm.RealmMember) RequestChannelAddMember(net.iGap.request.RequestChannelAddMember) RequestGroupKickMember(net.iGap.request.RequestGroupKickMember) RequestChannelKickMember(net.iGap.request.RequestChannelKickMember) ProtoGroupGetMemberList(net.iGap.proto.ProtoGroupGetMemberList)

Example 2 with RequestChannelGetMemberList

use of net.iGap.request.RequestChannelGetMemberList in project iGap-Android by KianIranian-STDG.

the class FragmentShowMember method loadMoreMember.

private void loadMoreMember() {
    if (isOne) {
        isOne = false;
        mCurrentUpdateCount = 0;
        offset += limit;
        if (roomType == GROUP) {
            new RequestGroupGetMemberList().getMemberList(mRoomID, offset, limit, ProtoGroupGetMemberList.GroupGetMemberList.FilterRole.valueOf(selectedRole));
        } else {
            new RequestChannelGetMemberList().channelGetMemberList(mRoomID, offset, limit, ProtoChannelGetMemberList.ChannelGetMemberList.FilterRole.valueOf(selectedRole));
        }
    }
}
Also used : RequestGroupGetMemberList(net.iGap.request.RequestGroupGetMemberList) RequestChannelGetMemberList(net.iGap.request.RequestChannelGetMemberList)

Aggregations

Dialog (android.app.Dialog)1 Context (android.content.Context)1 AsyncTask (android.os.AsyncTask)1 Bundle (android.os.Bundle)1 Handler (android.os.Handler)1 Looper (android.os.Looper)1 Editable (android.text.Editable)1 TextWatcher (android.text.TextWatcher)1 Gravity (android.view.Gravity)1 LayoutInflater (android.view.LayoutInflater)1 View (android.view.View)1 ViewGroup (android.view.ViewGroup)1 EditText (android.widget.EditText)1 LinearLayout (android.widget.LinearLayout)1 ProgressBar (android.widget.ProgressBar)1 TextView (android.widget.TextView)1 Nullable (androidx.annotation.Nullable)1 Fragment (androidx.fragment.app.Fragment)1 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)1 RecyclerView (androidx.recyclerview.widget.RecyclerView)1