use of com.cometchat.pro.uikit.ui_resources.utils.recycler_touch.RecyclerTouchListener 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;
}
use of com.cometchat.pro.uikit.ui_resources.utils.recycler_touch.RecyclerTouchListener in project android-java-chat-push-notification-app by cometchat-pro.
the class CometChatGroupDetailActivity method initComponent.
private void initComponent() {
dividerAdmin = findViewById(R.id.tv_seperator_admin);
dividerModerator = findViewById(R.id.tv_seperator_moderator);
dividerBan = findViewById(R.id.tv_seperator_ban);
divider2 = findViewById(R.id.tv_seperator_1);
groupIcon = findViewById(R.id.iv_group);
tvGroupName = findViewById(R.id.tv_group_name);
tvGroupDesc = findViewById(R.id.group_description);
tvGroupName.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
}
});
editGroup = findViewById(R.id.edit_group);
editGroup.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
updateGroupDialog();
}
});
tvMemberCount = findViewById(R.id.tv_members);
tvAdminCount = findViewById(R.id.tv_admin_count);
tvModeratorCount = findViewById(R.id.tv_moderator_count);
tvBanMemberCount = findViewById(R.id.tv_ban_count);
rvMemberList = findViewById(R.id.member_list);
tvLoadMore = findViewById(R.id.tv_load_more);
tvLoadMore.setText(String.format(getResources().getString(R.string.load_more_members), LIMIT));
TextView tvAddMember = findViewById(R.id.tv_add_member);
rlBanMembers = findViewById(R.id.rlBanView);
rlBanMembers.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
openBanMemberListScreen();
}
});
rlAddMemberView = findViewById(R.id.rl_add_member);
rlAddMemberView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
addMembers();
}
});
rlAdminListView = findViewById(R.id.rlAdminView);
rlAdminListView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
openAdminListScreen(false);
}
});
rlModeratorView = findViewById(R.id.rlModeratorView);
rlModeratorView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
openAdminListScreen(true);
}
});
tvDelete = findViewById(R.id.tv_delete);
TextView tvExit = findViewById(R.id.tv_exit);
toolbar = findViewById(R.id.groupDetailToolbar);
tvDelete.setTypeface(fontUtils.getTypeFace(FontUtils.robotoMedium));
tvExit.setTypeface(fontUtils.getTypeFace(FontUtils.robotoMedium));
tvAddMember.setTypeface(fontUtils.getTypeFace(FontUtils.robotoRegular));
setSupportActionBar(toolbar);
if (getSupportActionBar() != null)
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
rvMemberList.setLayoutManager(linearLayoutManager);
// rvMemberList.setNestedScrollingEnabled(false);
handleIntent();
if (loggedInUserScope.equalsIgnoreCase(CometChatConstants.SCOPE_ADMIN))
editGroup.setVisibility(View.VISIBLE);
else
editGroup.setVisibility(View.GONE);
checkDarkMode();
sharedMediaLayout = findViewById(R.id.shared_media_layout);
sharedMediaView = findViewById(R.id.shared_media_view);
sharedMediaView.setRecieverId(guid);
sharedMediaView.setRecieverType(CometChatConstants.RECEIVER_TYPE_GROUP);
sharedMediaView.reload();
rvMemberList.addOnItemTouchListener(new RecyclerTouchListener(this, rvMemberList, new ClickListener() {
@Override
public void onClick(View var1, int var2) {
GroupMember user = (GroupMember) var1.getTag(R.string.user);
if (loggedInUserScope != null && (loggedInUserScope.equals(CometChatConstants.SCOPE_ADMIN) || loggedInUserScope.equals(CometChatConstants.SCOPE_MODERATOR))) {
groupMember = user;
boolean isAdmin = user.getScope().equals(CometChatConstants.SCOPE_ADMIN);
boolean isSelf = loggedInUser.getUid().equals(user.getUid());
boolean isOwner = loggedInUser.getUid().equals(ownerId);
if (!isSelf) {
if (!isAdmin || isOwner) {
registerForContextMenu(rvMemberList);
openContextMenu(var1);
}
}
}
}
@Override
public void onLongClick(View var1, int var2) {
}
}));
tvLoadMore.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
getGroupMembers();
}
});
tvExit.setOnClickListener(view -> createDialog(getResources().getString(R.string.leave_group), getResources().getString(R.string.leave_group_message), getResources().getString(R.string.leave_group), getResources().getString(R.string.cancel), R.drawable.ic_exit_to_app));
tvDelete.setOnClickListener(view -> createDialog(getResources().getString(R.string.delete_group), getResources().getString(R.string.delete_group_message), getResources().getString(R.string.delete_group), getResources().getString(R.string.cancel), R.drawable.ic_delete));
//
FeatureRestriction.isJoinOrLeaveGroupEnabled(new FeatureRestriction.OnSuccessListener() {
@Override
public void onSuccess(Boolean booleanVal) {
if (!booleanVal)
tvExit.setVisibility(View.GONE);
}
});
FeatureRestriction.isGroupDeletionEnabled(new FeatureRestriction.OnSuccessListener() {
@Override
public void onSuccess(Boolean booleanVal) {
if (!booleanVal)
tvDelete.setVisibility(View.GONE);
}
});
FeatureRestriction.isSharedMediaEnabled(new FeatureRestriction.OnSuccessListener() {
@Override
public void onSuccess(Boolean booleanVal) {
if (!booleanVal) {
sharedMediaLayout.setVisibility(View.GONE);
}
}
});
FeatureRestriction.isViewGroupMemberInGroupDetails(new FeatureRestriction.OnSuccessListener() {
@Override
public void onSuccess(Boolean booleanVal) {
if (!booleanVal) {
rvMemberList.setVisibility(View.GONE);
tvLoadMore.setVisibility(View.GONE);
rlAddMemberView.setVisibility(View.GONE);
tvMemberCount.setVisibility(View.GONE);
divider2.setVisibility(View.GONE);
}
}
});
FeatureRestriction.isChangingMemberScopeEnabled(new FeatureRestriction.OnSuccessListener() {
@Override
public void onSuccess(Boolean booleanVal) {
if (!booleanVal) {
rlModeratorView.setVisibility(View.GONE);
rlAdminListView.setVisibility(View.GONE);
dividerAdmin.setVisibility(View.GONE);
dividerModerator.setVisibility(View.GONE);
}
}
});
FeatureRestriction.isBanningGroupMembersEnabled(new FeatureRestriction.OnSuccessListener() {
@Override
public void onSuccess(Boolean booleanVal) {
if (!booleanVal)
rlBanMembers.setVisibility(View.GONE);
}
});
}
use of com.cometchat.pro.uikit.ui_resources.utils.recycler_touch.RecyclerTouchListener in project android-java-chat-push-notification-app by cometchat-pro.
the class StickerFragment method onCreateView.
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_stickers_view, container, false);
rvStickers = view.findViewById(R.id.rvStickers);
rvStickers.setLayoutManager(new GridLayoutManager(getContext(), 4));
Id = this.getArguments().getString("Id");
type = this.getArguments().getString("type");
List<Sticker> list = this.getArguments().getParcelableArrayList("stickerList");
stickers = list;
Log.e("onStickerView: ", stickers.get(0).getSetName());
adapter = new StickersAdapter(getContext(), stickers);
rvStickers.setAdapter(adapter);
rvStickers.addOnItemTouchListener(new RecyclerTouchListener(getContext(), rvStickers, new ClickListener() {
@Override
public void onClick(View var1, int var2) {
Sticker sticker = (Sticker) var1.getTag(R.string.sticker);
stickerClickListener.onClickListener(sticker);
}
}));
return view;
}
use of com.cometchat.pro.uikit.ui_resources.utils.recycler_touch.RecyclerTouchListener in project android-java-chat-push-notification-app by cometchat-pro.
the class CometChatBlockUserList 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_block_user, container, false);
setHasOptionsMenu(true);
rvUserList = view.findViewById(R.id.rv_blocked_user_list);
noBlockUserLayout = view.findViewById(R.id.no_block_user);
MaterialToolbar toolbar = view.findViewById(R.id.toolbar_blocked_user);
setToolbar(toolbar);
CometChatError.init(getContext());
rvUserList.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
if (!recyclerView.canScrollVertically(1)) {
fetchBlockedUser();
}
}
});
// It unblock users when click on item in rvUserList
rvUserList.addOnItemTouchListener(new RecyclerTouchListener(getContext(), rvUserList, new ClickListener() {
@Override
public void onClick(View var1, int var2) {
User user = (User) var1.getTag(R.string.user);
if (getActivity() != null) {
MaterialAlertDialogBuilder alert = new MaterialAlertDialogBuilder(getActivity());
alert.setTitle(getResources().getString(R.string.unblock));
String message = String.format(getResources().getString(R.string.unblock_user_question), user.getName());
alert.setMessage(message);
alert.setPositiveButton(getResources().getString(R.string.yes), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
unBlockUser(user, var1);
}
});
alert.setNegativeButton(getResources().getString(R.string.cancel), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
}
});
alert.create();
alert.show();
}
}
}));
fetchBlockedUser();
return view;
}
Aggregations