use of com.cometchat.pro.uikit.ui_components.groups.group_members.GroupMemberAdapter in project android-java-chat-push-notification-app by cometchat-pro.
the class CometChatAdminModeratorList method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_cometchat_admin_moderator_list, container, false);
adminList = view.findViewById(R.id.adminList);
setHasOptionsMenu(true);
RelativeLayout rlAddMember = view.findViewById(R.id.rl_add_Admin);
addAs = view.findViewById(R.id.add_as_tv);
MaterialToolbar toolbar = view.findViewById(R.id.admin_toolbar);
setToolbar(toolbar);
CometChatError.init(getContext());
if (showModerators) {
toolbar.setTitle(getResources().getString(R.string.moderators));
addAs.setText(getResources().getString(R.string.assign_as_moderator));
} else {
toolbar.setTitle(getResources().getString(R.string.administrators));
addAs.setText(getResources().getString(R.string.assign_as_admin));
}
adapter = new GroupMemberAdapter(getContext(), members, null);
adminList.setAdapter(adapter);
if (loggedInUserScope != null && loggedInUserScope.equals(CometChatConstants.SCOPE_ADMIN)) {
rlAddMember.setVisibility(View.VISIBLE);
}
if (showModerators) {
getModeratorList(guid);
} else {
getAdminList(guid);
}
rlAddMember.setOnClickListener(view1 -> {
Intent intent = new Intent(getContext(), CometChatGroupMemberListActivity.class);
intent.putExtra(UIKitConstants.IntentStrings.GUID, guid);
intent.putExtra(UIKitConstants.IntentStrings.SHOW_MODERATORLIST, showModerators);
startActivity(intent);
});
adminList.addOnItemTouchListener(new RecyclerTouchListener(getContext(), adminList, new ClickListener() {
@Override
public void onClick(View var1, int var2) {
GroupMember groupMember = (GroupMember) var1.getTag(R.string.user);
if (showModerators) {
if (loggedInUserScope.equals(CometChatConstants.SCOPE_ADMIN) && !groupMember.getUid().equals(loggedInUser.getUid())) {
if (getActivity() != null) {
MaterialAlertDialogBuilder alert_dialog = new MaterialAlertDialogBuilder(getActivity());
alert_dialog.setTitle(getResources().getString(R.string.remove));
alert_dialog.setMessage(String.format(getResources().getString(R.string.remove_as_moderator), groupMember.getName()));
alert_dialog.setPositiveButton(getResources().getString(R.string.yes), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
updateMemberScope(groupMember, var1);
}
});
alert_dialog.setNegativeButton(getResources().getString(R.string.cancel), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
}
});
alert_dialog.create();
alert_dialog.show();
}
} else {
String message;
if (groupMember.getUid().equals(loggedInUser.getUid()))
message = getResources().getString(R.string.you_cannot_perform_action);
else
message = getResources().getString(R.string.only_admin_removes_moderator);
CometChatSnackBar.show(getContext(), view, message, CometChatSnackBar.WARNING);
}
} else {
if (ownerId != null && loggedInUser.getUid().equals(ownerId) && loggedInUserScope.equals(CometChatConstants.SCOPE_ADMIN) && !groupMember.getUid().equals(loggedInUser.getUid())) {
if (getActivity() != null) {
MaterialAlertDialogBuilder alert_dialog = new MaterialAlertDialogBuilder(getActivity());
alert_dialog.setTitle(getResources().getString(R.string.remove));
alert_dialog.setMessage(String.format(getResources().getString(R.string.remove_as_admin), groupMember.getName()));
alert_dialog.setPositiveButton(getResources().getString(R.string.yes), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
updateMemberScope(groupMember, var1);
}
});
alert_dialog.setNegativeButton(getResources().getString(R.string.cancel), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
}
});
alert_dialog.create();
alert_dialog.show();
}
} else {
String message;
if (groupMember.getUid().equals(loggedInUser.getUid()))
message = getResources().getString(R.string.you_cannot_perform_action);
else
message = getResources().getString(R.string.only_group_owner_removes_admin);
CometChatSnackBar.show(getContext(), view, message, CometChatSnackBar.WARNING);
}
}
}
}));
return view;
}
use of com.cometchat.pro.uikit.ui_components.groups.group_members.GroupMemberAdapter in project android-java-chat-push-notification-app by cometchat-pro.
the class CometChatBanMembers method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_cometchat_ban_member, container, false);
bannedMemberRv = view.findViewById(R.id.bannedMembers_rv);
noMemberTv = view.findViewById(R.id.no_member_tv);
bannedMemberRv.setLayoutManager(new LinearLayoutManager(getContext()));
groupMemberAdapter = new GroupMemberAdapter(getContext());
bannedMemberRv.setAdapter(groupMemberAdapter);
handleArguments();
CometChatError.init(getContext());
getBannedMembers();
bannedMemberRv.addOnItemTouchListener(new RecyclerTouchListener(getContext(), bannedMemberRv, new ClickListener() {
@Override
public void onClick(View var1, int var2) {
GroupMember user = (GroupMember) var1.getTag(R.string.user);
groupMember = user;
if (loggedInUserScope != null && (loggedInUserScope.equals(CometChatConstants.SCOPE_ADMIN) || loggedInUserScope.equals(CometChatConstants.SCOPE_MODERATOR))) {
registerForContextMenu(bannedMemberRv);
getActivity().openContextMenu(var1);
}
}
}));
return view;
}
Aggregations