Search in sources :

Example 1 with LatLng

use of com.easemob.util.LatLng 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)

Aggregations

Intent (android.content.Intent)1 View (android.view.View)1 OnLongClickListener (android.view.View.OnLongClickListener)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 LocationMessageBody (com.easemob.chat.LocationMessageBody)1 LatLng (com.easemob.util.LatLng)1 ContextMenu (com.juns.wechat.chat.ContextMenu)1