Search in sources :

Example 1 with OnItemClickListener

use of com.cometchat.pro.uikit.ui_resources.utils.item_clickListener.OnItemClickListener in project android-java-chat-push-notification-app by cometchat-pro.

the class CometChatCalls method setItemClickListener.

/**
 *  This method helps to get Click events of CometChatCallList
 *
 * @param onItemClickListener object of the OnItemClickListener
 */
public void setItemClickListener(OnItemClickListener<Call> onItemClickListener) {
    this.addOnItemTouchListener(new RecyclerTouchListener(context, this, new ClickListener() {

        @Override
        public void onClick(View var1, int var2) {
            Call call = (Call) var1.getTag(R.string.call);
            var1.findViewById(R.id.user_detail_vw).setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {
                    if (onItemClickListener != null)
                        onItemClickListener.OnItemClick(call, var2);
                    else
                        throw new NullPointerException("OnItemClickListener<Call> is null");
                }
            });
        }

        @Override
        public void onLongClick(View var1, int var2) {
            Call call = (Call) var1.getTag(R.string.call);
            if (onItemClickListener != null)
                onItemClickListener.OnItemLongClick(call, var2);
            else
                throw new NullPointerException("OnItemClickListener<Call> is null");
        }
    }));
}
Also used : RecyclerTouchListener(com.cometchat.pro.uikit.ui_resources.utils.recycler_touch.RecyclerTouchListener) Call(com.cometchat.pro.core.Call) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) OnItemClickListener(com.cometchat.pro.uikit.ui_resources.utils.item_clickListener.OnItemClickListener) ClickListener(com.cometchat.pro.uikit.ui_resources.utils.recycler_touch.ClickListener)

Example 2 with OnItemClickListener

use of com.cometchat.pro.uikit.ui_resources.utils.item_clickListener.OnItemClickListener in project android-java-chat-push-notification-app by cometchat-pro.

the class CometChatCalls method setItemCallClickListener.

/**
 *  This method helps to get Click events of CometChatCallList
 *
 * @param onItemClickListener object of the OnItemClickListener
 */
public void setItemCallClickListener(OnItemClickListener<Call> onItemClickListener) {
    this.addOnItemTouchListener(new RecyclerTouchListener(context, this, new ClickListener() {

        @Override
        public void onClick(View var1, int var2) {
            String uid;
            String type;
            Call call = (Call) var1.getTag(R.string.call);
            if (call.getReceiverType().equals(CometChatConstants.RECEIVER_TYPE_USER)) {
                if (((User) call.getCallInitiator()).getUid().equals(CometChat.getLoggedInUser().getUid())) {
                    uid = ((User) call.getCallReceiver()).getUid();
                } else {
                    uid = ((User) call.getCallInitiator()).getUid();
                }
                type = CometChatConstants.RECEIVER_TYPE_USER;
            } else {
                uid = ((Group) call.getCallReceiver()).getGuid();
                type = CometChatConstants.RECEIVER_TYPE_GROUP;
            }
            var1.findViewById(R.id.call_iv).setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {
                    Call callObj = new Call(uid, type, CometChatConstants.CALL_TYPE_AUDIO);
                    if (onItemClickListener != null)
                        onItemClickListener.OnItemClick(callObj, var2);
                    else
                        throw new NullPointerException("OnItemClickListener<Call> is null");
                }
            });
        }

        @Override
        public void onLongClick(View var1, int var2) {
        }
    }));
}
Also used : RecyclerTouchListener(com.cometchat.pro.uikit.ui_resources.utils.recycler_touch.RecyclerTouchListener) Call(com.cometchat.pro.core.Call) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) OnItemClickListener(com.cometchat.pro.uikit.ui_resources.utils.item_clickListener.OnItemClickListener) ClickListener(com.cometchat.pro.uikit.ui_resources.utils.recycler_touch.ClickListener)

Aggregations

View (android.view.View)2 RecyclerView (androidx.recyclerview.widget.RecyclerView)2 Call (com.cometchat.pro.core.Call)2 OnItemClickListener (com.cometchat.pro.uikit.ui_resources.utils.item_clickListener.OnItemClickListener)2 ClickListener (com.cometchat.pro.uikit.ui_resources.utils.recycler_touch.ClickListener)2 RecyclerTouchListener (com.cometchat.pro.uikit.ui_resources.utils.recycler_touch.RecyclerTouchListener)2