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);
}
}
Aggregations