use of net.iGap.observers.interfaces.OnGroupGetMemberList 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));
}
});
});
});
}
Aggregations