Search in sources :

Example 6 with RecyclerTouchListener

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;
}
Also used : RecyclerTouchListener(com.cometchat.pro.uikit.ui_resources.utils.recycler_touch.RecyclerTouchListener) GroupMember(com.cometchat.pro.models.GroupMember) GroupMemberAdapter(com.cometchat.pro.uikit.ui_components.groups.group_members.GroupMemberAdapter) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) ClickListener(com.cometchat.pro.uikit.ui_resources.utils.recycler_touch.ClickListener)

Example 7 with RecyclerTouchListener

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);
        }
    });
}
Also used : RecyclerTouchListener(com.cometchat.pro.uikit.ui_resources.utils.recycler_touch.RecyclerTouchListener) GroupMember(com.cometchat.pro.models.GroupMember) UserToGroupMember(com.cometchat.pro.uikit.ui_resources.utils.Utils.UserToGroupMember) FeatureRestriction(com.cometchat.pro.uikit.ui_settings.FeatureRestriction) TextView(android.widget.TextView) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ClickListener(com.cometchat.pro.uikit.ui_resources.utils.recycler_touch.ClickListener)

Example 8 with RecyclerTouchListener

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;
}
Also used : Sticker(com.cometchat.pro.uikit.ui_components.shared.cometchatStickers.model.Sticker) StickersAdapter(com.cometchat.pro.uikit.ui_components.shared.cometchatStickers.adapter.StickersAdapter) RecyclerTouchListener(com.cometchat.pro.uikit.ui_resources.utils.recycler_touch.RecyclerTouchListener) GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) ClickListener(com.cometchat.pro.uikit.ui_resources.utils.recycler_touch.ClickListener) StickerClickListener(com.cometchat.pro.uikit.ui_components.shared.cometchatStickers.listener.StickerClickListener) Nullable(androidx.annotation.Nullable)

Example 9 with RecyclerTouchListener

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;
}
Also used : RecyclerTouchListener(com.cometchat.pro.uikit.ui_resources.utils.recycler_touch.RecyclerTouchListener) User(com.cometchat.pro.models.User) DialogInterface(android.content.DialogInterface) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder) MaterialToolbar(com.google.android.material.appbar.MaterialToolbar) RecyclerView(androidx.recyclerview.widget.RecyclerView) ClickListener(com.cometchat.pro.uikit.ui_resources.utils.recycler_touch.ClickListener)

Aggregations

View (android.view.View)9 RecyclerView (androidx.recyclerview.widget.RecyclerView)9 ClickListener (com.cometchat.pro.uikit.ui_resources.utils.recycler_touch.ClickListener)9 RecyclerTouchListener (com.cometchat.pro.uikit.ui_resources.utils.recycler_touch.RecyclerTouchListener)9 TextView (android.widget.TextView)5 GroupMember (com.cometchat.pro.models.GroupMember)4 ImageView (android.widget.ImageView)3 MaterialToolbar (com.google.android.material.appbar.MaterialToolbar)3 MaterialAlertDialogBuilder (com.google.android.material.dialog.MaterialAlertDialogBuilder)3 DialogInterface (android.content.DialogInterface)2 Intent (android.content.Intent)2 Editable (android.text.Editable)2 TextWatcher (android.text.TextWatcher)2 InputMethodManager (android.view.inputmethod.InputMethodManager)2 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)2 Call (com.cometchat.pro.core.Call)2 User (com.cometchat.pro.models.User)2 GroupMemberAdapter (com.cometchat.pro.uikit.ui_components.groups.group_members.GroupMemberAdapter)2 OnItemClickListener (com.cometchat.pro.uikit.ui_resources.utils.item_clickListener.OnItemClickListener)2 KeyEvent (android.view.KeyEvent)1