陌陌自定义卡片链接

效果在这里插入图片描述

主要代码

public void mo131684a(String str, String str2, String str3, String str4, String str5, String str6, String str7, String str8, String str9) throws Exception {
        HashMap hashMap = new HashMap();
        hashMap.put("sync_type", str);
        hashMap.put("url", str4);
        if (!TextUtils.isEmpty(str7)) {
            hashMap.put("title", str7);
        }
        if (!C29341by.m140686a((CharSequence) str2)) {
            hashMap.put("content", str2);
        }
        if (!C29341by.m140686a((CharSequence) str3)) {
            hashMap.put("pic_path", str3);
        }
        if (!C29341by.m140686a((CharSequence) str6)) {
            hashMap.put("token", str6);
        }
        if ("momo_friend".equals(str)) {
            hashMap.put("remoteid", str5);
        } else if ("momo_group".equals(str)) {
            hashMap.put("gid", str5);
        } else if ("momo_discuss".equals(str)) {
            hashMap.put("did", str5);
        }
        if (!C29341by.m140686a((CharSequence) str8)) {
            hashMap.put("src", str8);
        }
        if (!C29341by.m140686a((CharSequence) str9)) {
            hashMap.put("web_source", str9);
        }
        doPost("https://api.immomo.com/api/webapp/share/send", hashMap);
    }
public static void startTask(Activity activity) {
        try {
            ClassLoader classLoader = activity.getClass().getClassLoader();
            //是否是群
            final String id;
            final boolean isGroup;
            if (activity.getClass().getName().equals("com.immomo.momo.message.activity.ChatActivity")) {
                isGroup = false;
                id = ReflectionUtil.getFieldChainValue(activity, "ay", "h");
            } else {
                //private Group f76484ax;
                isGroup = true;
                id = ReflectionUtil.getFieldChainValue(activity, "ax", "a");
            }
            MLog.log("id: " + id);
            //<public type="id" name="message_btn_sendtext" id="2131303262" />
            int sendBtnId = 2131303262;
            // <public type="id" name="message_ed_msgeditor" id="2131303270" />
            int editTextId = 2131303270;
            View sendBtn = activity.findViewById(sendBtnId);
            EditText editView = (EditText) activity.findViewById(editTextId);
            View.OnClickListener orginaSendBtnClickListenr = ViewUtil.getViewClickListener(sendBtn);
            sendBtn.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    try {
                        CharSequence clipbardText = Utility.getClipbardText(activity);
                        MLog.log("剪贴板内容: " + clipbardText);
                        if (TextUtils.isEmpty(clipbardText) || !clipbardText.toString().startsWith("{") || !clipbardText.toString().endsWith("}")) {
                            orginaSendBtnClickListenr.onClick(v);
                            return;
                        }

                        JSONObject jSONObject = new JSONObject(clipbardText.toString());
                        String type = jSONObject.getString("type");
                        switch (type) {
                            case "1": {
                                String content = jSONObject.getString("content");
                                String imageUrl =  Utility.getJSONString(jSONObject,"imageUrl");
                                String url = jSONObject.getString("url");
                                send(classLoader, isGroup, id, content, imageUrl, url);
                            }
                            break;
                        }
                        editView.setText("");
                    } catch (Exception e) {
                        Toast.makeText(activity, "代码有误,请检查代码", Toast.LENGTH_SHORT).show();
                        MLog.log(e);
                    }
                }
            });
        } catch (Exception e) {
            Toast.makeText(activity, "请检查版本", Toast.LENGTH_SHORT).show();
            MLog.log(e);
        }
    }

本文仅供学习交流,严禁用于商业用途

  • 7
    点赞
  • 30
    收藏
    觉得还不错? 一键收藏
  • 33
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 33
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值