Search in sources :

Example 11 with OnLongClickListener

use of android.view.View.OnLongClickListener in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class CopyablePreference method onBindViewHolder.

@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
    super.onBindViewHolder(holder);
    holder.setDividerAllowedAbove(true);
    holder.setDividerAllowedBelow(true);
    holder.itemView.setLongClickable(true);
    holder.itemView.setOnLongClickListener(new OnLongClickListener() {

        @Override
        public boolean onLongClick(View v) {
            copyPreference(getContext(), CopyablePreference.this);
            return true;
        }
    });
}
Also used : OnLongClickListener(android.view.View.OnLongClickListener) View(android.view.View)

Example 12 with OnLongClickListener

use of android.view.View.OnLongClickListener in project android_frameworks_base by ResurrectionRemix.

the class LongpressTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    final Longpress a = getActivity();
    mSimpleView = a.findViewById(R.id.simple_view);
    mSimpleView.setOnLongClickListener(new OnLongClickListener() {

        public boolean onLongClick(View v) {
            mLongClicked = true;
            return true;
        }
    });
}
Also used : Longpress(android.view.Longpress) OnLongClickListener(android.view.View.OnLongClickListener) View(android.view.View)

Example 13 with OnLongClickListener

use of android.view.View.OnLongClickListener in project wechat by motianhuo.

the class MessageAdapter method handleVoiceMessage.

/**
	 * 语音消息
	 * 
	 * @param message
	 * @param holder
	 * @param position
	 * @param convertView
	 */
private void handleVoiceMessage(final EMMessage message, final ViewHolder holder, final int position, View convertView) {
    VoiceMessageBody voiceBody = (VoiceMessageBody) message.getBody();
    holder.tv.setText(voiceBody.getLength() + "\"");
    holder.iv.setOnClickListener(new VoicePlayClickListener(message, holder.iv, holder.iv_read_status, this, activity, username));
    holder.iv.setOnLongClickListener(new OnLongClickListener() {

        @Override
        public boolean onLongClick(View v) {
            activity.startActivityForResult((new Intent(activity, ContextMenu.class)).putExtra("position", position).putExtra("type", EMMessage.Type.VOICE.ordinal()), ChatActivity.REQUEST_CODE_CONTEXT_MENU);
            return true;
        }
    });
    if (((ChatActivity) activity).playMsgId != null && ((ChatActivity) activity).playMsgId.equals(message.getMsgId()) && VoicePlayClickListener.isPlaying) {
        AnimationDrawable voiceAnimation;
        if (message.direct == EMMessage.Direct.RECEIVE) {
            holder.iv.setImageResource(R.anim.voice_from_icon);
        } else {
            holder.iv.setImageResource(R.anim.voice_to_icon);
        }
        voiceAnimation = (AnimationDrawable) holder.iv.getDrawable();
        voiceAnimation.start();
    } else {
        if (message.direct == EMMessage.Direct.RECEIVE) {
            holder.iv.setImageResource(R.drawable.chatfrom_voice_playing);
        } else {
            holder.iv.setImageResource(R.drawable.chatto_voice_playing);
        }
    }
    if (message.direct == EMMessage.Direct.RECEIVE) {
        if (message.isListened()) {
            // 隐藏语音未听标志
            holder.iv_read_status.setVisibility(View.INVISIBLE);
        } else {
            holder.iv_read_status.setVisibility(View.VISIBLE);
        }
        System.err.println("it is receive msg");
        if (message.status == EMMessage.Status.INPROGRESS) {
            holder.pb.setVisibility(View.VISIBLE);
            System.err.println("!!!! back receive");
            ((FileMessageBody) message.getBody()).setDownloadCallback(new EMCallBack() {

                @Override
                public void onSuccess() {
                    activity.runOnUiThread(new Runnable() {

                        @Override
                        public void run() {
                            holder.pb.setVisibility(View.INVISIBLE);
                            notifyDataSetChanged();
                        }
                    });
                }

                @Override
                public void onProgress(int progress, String status) {
                }

                @Override
                public void onError(int code, String message) {
                    activity.runOnUiThread(new Runnable() {

                        @Override
                        public void run() {
                            holder.pb.setVisibility(View.INVISIBLE);
                        }
                    });
                }
            });
        } else {
            holder.pb.setVisibility(View.INVISIBLE);
        }
        return;
    }
    // until here, deal with send voice msg
    switch(message.status) {
        case SUCCESS:
            holder.pb.setVisibility(View.GONE);
            holder.staus_iv.setVisibility(View.GONE);
            break;
        case FAIL:
            holder.pb.setVisibility(View.GONE);
            holder.staus_iv.setVisibility(View.VISIBLE);
            break;
        case INPROGRESS:
            holder.pb.setVisibility(View.VISIBLE);
            holder.staus_iv.setVisibility(View.GONE);
            break;
        default:
            sendMsgInBackground(message, holder);
    }
}
Also used : VoiceMessageBody(com.easemob.chat.VoiceMessageBody) EMCallBack(com.easemob.EMCallBack) AnimationDrawable(android.graphics.drawable.AnimationDrawable) NormalFileMessageBody(com.easemob.chat.NormalFileMessageBody) FileMessageBody(com.easemob.chat.FileMessageBody) Intent(android.content.Intent) ContextMenu(com.juns.wechat.chat.ContextMenu) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) SuppressLint(android.annotation.SuppressLint) OnLongClickListener(android.view.View.OnLongClickListener)

Example 14 with OnLongClickListener

use of android.view.View.OnLongClickListener in project wechat by motianhuo.

the class MessageAdapter method handleLocationMessage.

/**
	 * 处理位置消息
	 * 
	 * @param message
	 * @param holder
	 * @param position
	 * @param convertView
	 */
private void handleLocationMessage(final EMMessage message, final ViewHolder holder, final int position, View convertView) {
    TextView locationView = ((TextView) convertView.findViewById(R.id.tv_location));
    LocationMessageBody locBody = (LocationMessageBody) message.getBody();
    locationView.setText(locBody.getAddress());
    LatLng loc = new LatLng(locBody.getLatitude(), locBody.getLongitude());
    locationView.setOnClickListener(new MapClickListener(loc, locBody.getAddress()));
    locationView.setOnLongClickListener(new OnLongClickListener() {

        @Override
        public boolean onLongClick(View v) {
            activity.startActivityForResult((new Intent(activity, ContextMenu.class)).putExtra("position", position).putExtra("type", EMMessage.Type.LOCATION.ordinal()), ChatActivity.REQUEST_CODE_CONTEXT_MENU);
            return false;
        }
    });
    if (message.direct == EMMessage.Direct.RECEIVE) {
        return;
    }
    // deal with send message
    switch(message.status) {
        case SUCCESS:
            holder.pb.setVisibility(View.GONE);
            holder.staus_iv.setVisibility(View.GONE);
            break;
        case FAIL:
            holder.pb.setVisibility(View.GONE);
            holder.staus_iv.setVisibility(View.VISIBLE);
            break;
        case INPROGRESS:
            holder.pb.setVisibility(View.VISIBLE);
            break;
        default:
            sendMsgInBackground(message, holder);
    }
}
Also used : OnLongClickListener(android.view.View.OnLongClickListener) TextView(android.widget.TextView) Intent(android.content.Intent) ContextMenu(com.juns.wechat.chat.ContextMenu) LatLng(com.easemob.util.LatLng) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) LocationMessageBody(com.easemob.chat.LocationMessageBody)

Example 15 with OnLongClickListener

use of android.view.View.OnLongClickListener in project android_frameworks_base by crdroidandroid.

the class DisabledLongpressTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    final Longpress a = getActivity();
    mSimpleView = a.findViewById(R.id.simple_view);
    mSimpleView.setOnLongClickListener(new OnLongClickListener() {

        public boolean onLongClick(View v) {
            mLongClicked = true;
            return true;
        }
    });
    // The View#setOnLongClickListener will ensure the View is long
    // clickable, we reverse that here
    mSimpleView.setLongClickable(false);
}
Also used : Longpress(android.view.Longpress) OnLongClickListener(android.view.View.OnLongClickListener) View(android.view.View)

Aggregations

OnLongClickListener (android.view.View.OnLongClickListener)34 View (android.view.View)33 TextView (android.widget.TextView)17 Longpress (android.view.Longpress)12 ImageView (android.widget.ImageView)12 OnClickListener (android.view.View.OnClickListener)10 Intent (android.content.Intent)9 ContextMenu (com.juns.wechat.chat.ContextMenu)4 RecyclerView (android.support.v7.widget.RecyclerView)3 LinearLayout (android.widget.LinearLayout)3 File (java.io.File)3 SuppressLint (android.annotation.SuppressLint)2 ViewGroup (android.view.ViewGroup)2 ListView (android.widget.ListView)2 RelativeLayout (android.widget.RelativeLayout)2 Timer (java.util.Timer)2 TimerTask (java.util.TimerTask)2 LayoutTransition (android.animation.LayoutTransition)1 AlertDialog (android.app.AlertDialog)1 ActivityNotFoundException (android.content.ActivityNotFoundException)1