抖音自定义可以自定义标题,打开链接,和展示图片
效果
主要代码
public void sendMessage(String conversationId, Object aBaseContent) throws Exception {
Object HOa = ReflectionUtil.invokeMethod(ReflectionUtil.getStaticFieldValue("X.2u5", mClassLoader, "LIZIZ"), "LIZ");
HOa = ReflectionUtil.invokeMethod(HOa, "LIZIZ", String.class, conversationId);
HOa = ReflectionUtil.invokeMethod(HOa, "LIZ", Map.class, new HashMap());
HOa = ReflectionUtil.invokeMethod(HOa, "LIZ", "X.HEq", aBaseContent);
Class<?> aClasseat7 = mClassLoader.loadClass("X.HHc");
Object proxy = ProxyUtil.createProxy(null, aClasseat7, new ProxyUtil.ProxyCallback() {
@Override
public Object overrideMethod(Object proxy, Method method, Object[] args, boolean[] isOverride) {
switch (method.getName()) {
case "onSendFailed":
MLog.log("onSendFailed");
MLog.log(gsonToJsonString(args[0]));
MLog.log(gsonToJsonString(args[1]));
MLog.log(gsonToJsonString(args[2]));
isOverride[0] = true;
break;
case "onSendSuccess":
isOverride[0] = true;
MLog.log("onSendSuccess");
MLog.log(gsonToJsonString(args[0]));
MLog.log(gsonToJsonString(args[1]));
break;
case "onAdd":
case "onAddFinished":
case "onSendFinished":
isOverride[0] = true;
MLog.log(method.getName());
break;
}
return null;
}
});
ReflectionUtil.invokeMethod(HOa, "LIZ", aClasseat7, proxy);
}
发送逻辑
public void startTask(Activity activity) {
try {
final String id = ReflectionUtil.getFieldValue(activity.getIntent().getSerializableExtra("key_enter_chat_params"), "sessionId");
MLog.log("id: " + id);
int sendBtnId = 2131175609;
int editTextId = 2131180296;
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 title = jSONObject.getString("title");
String imageUrl = jSONObject.getString("imageUrl");
String url = jSONObject.getString("url");
send(id, url, title, imageUrl);
}
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);
}
}
本文仅供学习交流,严禁用于商业用途
|