Search in sources :

Example 1 with User

use of com.juns.wechat.bean.User in project wechat by motianhuo.

the class FromContactAdapter method getView.

@Override
public View getView(final int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
        convertView = LayoutInflater.from(context).inflate(R.layout.layout_item_newfriend, parent, false);
    }
    ImageView img_avar = ViewHolder.get(convertView, R.id.img_photo);
    TextView txt_name = ViewHolder.get(convertView, R.id.txt_name);
    TextView txt_msg = ViewHolder.get(convertView, R.id.txt_msg);
    final TextView txt_add = ViewHolder.get(convertView, R.id.txt_add);
    final User user = UserInfos.get(position);
    txt_name.setText(user.getUserName());
    txt_add.setText("添加");
    txt_msg.setText("微信号:" + user.getTelephone() + "   " + user.getUserName());
    txt_add.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
        }
    });
    convertView.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent intent = new Intent(context, FriendMsgActivity.class);
            intent.putExtra(Constants.NAME, user.getUserName());
            intent.putExtra(Constants.TYPE, ChatActivity.CHATTYPE_SINGLE);
            intent.putExtra(Constants.User_ID, user.getTelephone());
            context.startActivity(intent);
        }
    });
    return convertView;
}
Also used : User(com.juns.wechat.bean.User) OnClickListener(android.view.View.OnClickListener) TextView(android.widget.TextView) Intent(android.content.Intent) ImageView(android.widget.ImageView) FriendMsgActivity(com.juns.wechat.view.activity.FriendMsgActivity) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View)

Example 2 with User

use of com.juns.wechat.bean.User in project wechat by motianhuo.

the class NewFriendsAdapter method getView.

@Override
public View getView(final int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
        convertView = LayoutInflater.from(context).inflate(R.layout.layout_item_newfriend, parent, false);
    }
    ImageView img_avar = ViewHolder.get(convertView, R.id.img_photo);
    TextView txt_name = ViewHolder.get(convertView, R.id.txt_name);
    final TextView txt_add = ViewHolder.get(convertView, R.id.txt_add);
    final User user = GloableParams.UserInfos.get(position);
    txt_name.setText(user.getUserName());
    txt_add.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            txt_add.setTextColor(context.getResources().getColor(R.color.black1));
            txt_add.setBackgroundResource(R.drawable.btn_bg_gray1);
            txt_add.setText("已添加");
            Utils.showLongToast(context, "添加好友成功,等待对方同意");
            try {
                EMContactManager.getInstance().addContact(user.getTelephone(), "请求添加你为朋友");
            } catch (EaseMobException e) {
                e.printStackTrace();
            }
        }
    });
    convertView.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent intent = new Intent(context, FriendMsgActivity.class);
            intent.putExtra(Constants.NAME, user.getUserName());
            intent.putExtra(Constants.TYPE, ChatActivity.CHATTYPE_SINGLE);
            intent.putExtra(Constants.User_ID, user.getTelephone());
            context.startActivity(intent);
        }
    });
    return convertView;
}
Also used : User(com.juns.wechat.bean.User) EaseMobException(com.easemob.exceptions.EaseMobException) OnClickListener(android.view.View.OnClickListener) TextView(android.widget.TextView) Intent(android.content.Intent) ImageView(android.widget.ImageView) FriendMsgActivity(com.juns.wechat.view.activity.FriendMsgActivity) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View)

Example 3 with User

use of com.juns.wechat.bean.User in project wechat by motianhuo.

the class NewMsgAdpter method getMessageDigest.

/**
	 * 根据消息内容和消息类型获取消息内容提示
	 * 
	 * @param message
	 * @param context
	 * @return
	 */
private String getMessageDigest(EMMessage message, Context context) {
    String digest = "";
    switch(message.getType()) {
        case // 位置消息
        LOCATION:
            if (message.direct == EMMessage.Direct.RECEIVE) {
                digest = getStrng(context, R.string.location_recv);
                String name = message.getFrom();
                if (GloableParams.UserInfos != null) {
                    User user = GloableParams.Users.get(message.getFrom());
                    if (user != null && null != user.getUserName())
                        name = user.getUserName();
                }
                digest = String.format(digest, name);
                return digest;
            } else {
                digest = getStrng(context, R.string.location_prefix);
            }
            break;
        case // 图片消息
        IMAGE:
            ImageMessageBody imageBody = (ImageMessageBody) message.getBody();
            digest = getStrng(context, R.string.picture) + imageBody.getFileName();
            break;
        case // 语音消息
        VOICE:
            digest = getStrng(context, R.string.voice_msg);
            break;
        case // 视频消息
        VIDEO:
            digest = getStrng(context, R.string.video);
            break;
        case // 文本消息
        TXT:
            if (!message.getBooleanAttribute(Constant.MESSAGE_ATTR_IS_VOICE_CALL, false)) {
                TextMessageBody txtBody = (TextMessageBody) message.getBody();
                digest = txtBody.getMessage();
            } else {
                TextMessageBody txtBody = (TextMessageBody) message.getBody();
                digest = getStrng(context, R.string.voice_call) + txtBody.getMessage();
            }
            break;
        case // 普通文件消息
        FILE:
            digest = getStrng(context, R.string.file);
            break;
        default:
            System.err.println("error, unknow type");
            return "";
    }
    return digest;
}
Also used : User(com.juns.wechat.bean.User) ImageMessageBody(com.easemob.chat.ImageMessageBody) TextMessageBody(com.easemob.chat.TextMessageBody)

Example 4 with User

use of com.juns.wechat.bean.User in project wechat by motianhuo.

the class SplashActivity method initData.

private void initData() {
    GloableParams.UserInfos = new ArrayList<User>();
    GloableParams.Users = new HashMap<String, User>();
    GloableParams.ListGroupInfos = new ArrayList<GroupInfo>();
    GloableParams.GroupInfos = new HashMap<String, GroupInfo>();
    FinalDb db = FinalDb.create(this, Constants.DB_NAME, false);
    GloableParams.ListGroupInfos = db.findAll(GroupInfo.class);
    GloableParams.UserInfos = db.findAll(User.class);
}
Also used : User(com.juns.wechat.bean.User) GroupInfo(com.juns.wechat.bean.GroupInfo) FinalDb(net.tsz.afinal.FinalDb)

Example 5 with User

use of com.juns.wechat.bean.User in project wechat by motianhuo.

the class SetMoneyActivity method initView.

@Override
protected void initView() {
    String UserId = getIntent().getStringExtra(Constants.User_ID);
    String money = getIntent().getStringExtra(Constants.NAME);
    User user = GloableParams.Users.get(UserId);
    String strname = "您正在向 " + user.getUserName() + "<br/>微信号:" + UserId + " 付钱";
    tv_msg.setText(Html.fromHtml(strname));
    String strmoney = "¥<font color='#ff11aca6'>" + money + "<small>元</small></font> ";
    tv_money.setText(Html.fromHtml(strmoney));
}
Also used : User(com.juns.wechat.bean.User)

Aggregations

User (com.juns.wechat.bean.User)23 Intent (android.content.Intent)5 ImageView (android.widget.ImageView)5 GroupInfo (com.juns.wechat.bean.GroupInfo)5 TextView (android.widget.TextView)4 FinalDb (net.tsz.afinal.FinalDb)4 View (android.view.View)3 OnClickListener (android.view.View.OnClickListener)3 EaseMobException (com.easemob.exceptions.EaseMobException)3 BaseJsonRes (com.juns.wechat.net.BaseJsonRes)3 List (java.util.List)3 EMConversation (com.easemob.chat.EMConversation)2 RequestParams (com.juns.health.net.loopj.android.http.RequestParams)2 FriendMsgActivity (com.juns.wechat.view.activity.FriendMsgActivity)2 Bitmap (android.graphics.Bitmap)1 Editable (android.text.Editable)1 TextWatcher (android.text.TextWatcher)1 EMGroup (com.easemob.chat.EMGroup)1 EMMessage (com.easemob.chat.EMMessage)1 ImageMessageBody (com.easemob.chat.ImageMessageBody)1