50度灰 v5.8.2版本的 MD5 值为:9fe3d350fdc75fa1a3ec45509fa0107e
以下内容为反编译后的 ChatActivity.java 源代码,内容仅作参考
package com.tencent.mm.im;
import ajdrhg.adgfxm.gbuhji.R;
import android.app.NotificationManager;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.IBinder;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.SimpleItemAnimator;
import android.text.TextUtils;
import android.util.Log;
import android.view.KeyEvent;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.asm.Opcodes;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.coremedia.iso.boxes.UserBox;
import com.fynnjason.utils.p;
import com.google.android.exoplayer2.C;
import com.luck.picture.lib.entity.LocalMedia;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.callback.StringCallback;
import com.lzy.okgo.model.Progress;
import com.lzy.okgo.model.Response;
import com.lzy.okgo.request.PostRequest;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.b.l;
import com.tencent.mm.adapter.NewChatAdapter;
import com.tencent.mm.bean.ChatSetBean;
import com.tencent.mm.database.ChatDataBeanDao;
import com.tencent.mm.database.IMDataBeanDao;
import com.tencent.mm.i.s;
import com.tencent.mm.i.t;
import com.tencent.mm.im.adapter.SimpleAppsGridView;
import com.tencent.mm.im.websocket.JWebSocketClientService;
import com.tencent.mm.l.k;
import com.tencent.mm.m.o;
import com.tencent.mm.ui.ChatSetActivity;
import com.tencent.mm.ui.OtherInfoActivity;
import com.tencent.mm.uitls.o1;
import com.tencent.mm.viewModel.ChatSetModel;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import org.greenrobot.greendao.l.m;
import sj.keyboard.XhsEmoticonsKeyBoard;
import sj.keyboard.widget.EmoticonsEditText;
import sj.keyboard.widget.FuncLayout;
public class ChatActivity extends AppCompatActivity implements FuncLayout.b, com.scwang.smartrefresh.layout.e.d, View.OnClickListener, o {
private SimpleAppsGridView E;
private TextView F;
private JWebSocketClientService.f G;
private JWebSocketClientService H;
private ServiceConnection I;
private String J;
private String K;
private String L;
private j M;
private TextView O;
private SmartRefreshLayout Q;
private ChatSetModel R;
private LinearLayout S;
private TextView f7797a;
private RecyclerView f7798b;
private XhsEmoticonsKeyBoard f7799c;
private NewChatAdapter s;
private String N = "离线";
private int P = 0;
private boolean T = false;
sj.keyboard.d.a U = new g();
public class a implements View.OnClickListener {
a() {
}
@Override
public void onClick(View v) {
ChatActivity.this.f7799c.D();
}
}
public class b implements ServiceConnection {
b() {
}
@Override
public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
Log.e("ChatActivity", "服务与活动成功绑定");
ChatActivity.this.G = (JWebSocketClientService.f) iBinder;
ChatActivity chatActivity = ChatActivity.this;
chatActivity.H = chatActivity.G.a();
ChatActivity.this.H.m(ChatActivity.this.J);
}
@Override
public void onServiceDisconnected(ComponentName componentName) {
Log.e("ChatActivity", "服务与活动成功断开");
}
}
public class c implements BaseQuickAdapter.h {
c() {
}
@Override
public void a(BaseQuickAdapter adapter, View view, int position) {
switch (view.getId()) {
case R.id.content_view:
ChatActivity.this.f7799c.D();
return;
case R.id.head_thumb_image:
OtherInfoActivity.B6(view.getContext(), k.j().f().info.uuid);
return;
case R.id.head_thumb_image_l:
OtherInfoActivity.B6(view.getContext(), ((com.tencent.mm.database.bean.a) ChatActivity.this.s.getItem(position)).f7525c);
return;
default:
return;
}
}
}
public class d implements RecyclerView.OnItemTouchListener {
d() {
}
@Override
public boolean onInterceptTouchEvent(@NonNull RecyclerView recyclerView, @NonNull MotionEvent motionEvent) {
if (motionEvent.getActionMasked() == 0) {
View findChildViewUnder = recyclerView.findChildViewUnder(motionEvent.getX(), motionEvent.getY());
if (findChildViewUnder == null) {
ChatActivity.this.f7799c.D();
return false;
}
View findViewById = findChildViewUnder.findViewById(R.id.content_view);
if (findViewById == null) {
ChatActivity.this.f7799c.D();
return false;
} else if (!ChatActivity.t6(findViewById, motionEvent)) {
ChatActivity.this.f7799c.D();
}
}
return false;
}
@Override
public void onRequestDisallowInterceptTouchEvent(boolean b2) {
}
@Override
public void onTouchEvent(@NonNull RecyclerView recyclerView, @NonNull MotionEvent motionEvent) {
}
}
public class e implements View.OnClickListener {
e() {
}
@Override
public void onClick(View v) {
if (k.j().t()) {
if (!ChatActivity.this.T) {
String obj = ChatActivity.this.f7799c.getEtChat().getText().toString();
if (obj.trim().equals("")) {
p.a(ChatActivity.this, "请输入你要发送的消息");
return;
}
com.tencent.mm.database.bean.a aVar = new com.tencent.mm.database.bean.a();
aVar.G = ChatActivity.this.K;
aVar.H = ChatActivity.this.L;
aVar.J = obj;
aVar.K = "text";
aVar.s = ChatActivity.this.J;
aVar.O = 21;
aVar.P = 1;
aVar.M = Long.valueOf(System.currentTimeMillis());
ChatActivity.this.s.j(aVar);
ChatActivity.this.H.H(aVar);
ChatActivity.this.f7799c.getEtChat().setText("");
ChatActivity.this.A6();
return;
}
p.a(ChatActivity.this, "你已经拉黑该好友!");
return;
}
p.a(ChatActivity.this, "私聊功能指对VIP用户开放!");
}
}
public class f implements sj.keyboard.d.d {
f() {
}
@Override
public void a(String message) {
}
@Override
public void b(String audioFilePath, long recordTime) {
}
@Override
public void c() {
ChatActivity.this.C6();
}
@Override
public void d(boolean status) {
ChatActivity.this.H.Q(ChatActivity.this.J, status);
}
@Override
public void e(String photoPath) {
}
}
class g implements sj.keyboard.d.a {
g() {
}
@Override
public void a(Object o, int actionType, boolean isDelBtn) {
if (isDelBtn) {
com.tencent.mm.im.d.e.g(ChatActivity.this.f7799c.getEtChat());
} else if (o == null) {
} else {
if (actionType == com.tencent.mm.im.d.a.m) {
boolean z = o instanceof sj.keyboard.data.a;
return;
}
String str = null;
if (o instanceof com.sj.emoji.c) {
str = ((com.sj.emoji.c) o).f5709b;
} else if (o instanceof sj.keyboard.data.a) {
str = ((sj.keyboard.data.a) o).a();
}
if (TextUtils.isEmpty(str)) {
return;
}
ChatActivity.this.f7799c.getEtChat().getText().insert(ChatActivity.this.f7799c.getEtChat().getSelectionStart(), str);
}
}
}
public class h implements Runnable {
h() {
}
@Override
public void run() {
ChatActivity.this.f7798b.smoothScrollToPosition(ChatActivity.this.s.N().size());
}
}
public class i extends StringCallback {
final com.tencent.mm.database.bean.a f7808a;
i(final com.tencent.mm.database.bean.a val$sendBean) {
this.f7808a = val$sendBean;
}
@Override
public void onError(Response<String> response) {
com.tencent.mm.database.bean.a aVar = this.f7808a;
aVar.P = 7;
ChatActivity.this.z6(aVar.M.longValue(), this.f7808a.P);
}
@Override
public void onSuccess(Response<String> response) {
Log.e(Progress.REQUEST, "response=" + response.body());
JSONObject parseObject = JSON.parseObject(response.body());
if (parseObject != null && parseObject.containsKey("code") && parseObject.getInteger("code").intValue() == 1) {
String str = com.tencent.mm.l.h.c().h().imgUrl;
if (TextUtils.isEmpty(str)) {
str = "http://imgpublic.ycomesc.com/";
}
if (!str.endsWith("/")) {
str = str + "/";
}
String str2 = str + "img.im/" + parseObject.getString("msg");
com.tencent.mm.database.bean.a aVar = this.f7808a;
aVar.J = str2;
aVar.P = 6;
ChatActivity.this.H.H(this.f7808a);
return;
}
com.tencent.mm.database.bean.a aVar2 = this.f7808a;
aVar2.P = 7;
ChatActivity.this.z6(aVar2.M.longValue(), this.f7808a.P);
}
}
public class j extends BroadcastReceiver {
private j() {
}
@Override
public void onReceive(Context context, Intent intent) {
com.tencent.mm.database.bean.a aVar;
String stringExtra = intent.getStringExtra("message");
if (TextUtils.isEmpty(stringExtra)) {
return;
}
Log.e("ChatMessageReceiver:", stringExtra);
JSONObject parseObject = JSON.parseObject(stringExtra);
if (parseObject.containsKey("message_type")) {
String string = parseObject.getString("message_type");
JSONObject jSONObject = parseObject.containsKey("data") ? parseObject.getJSONObject("data") : null;
string.hashCode();
char c2 = 65535;
switch (string.hashCode()) {
case -2039726571:
if (string.equals("replySendMessage")) {
c2 = 0;
break;
}
break;
case -1427675770:
if (string.equals("isTypingMessage")) {
c2 = 1;
break;
}
break;
case -1381300933:
if (string.equals("queryOnline")) {
c2 = 2;
break;
}
break;
case -1369370225:
if (string.equals("chatMessage")) {
c2 = 3;
break;
}
break;
case -1065805512:
if (string.equals("unReadMessage")) {
c2 = 4;
break;
}
break;
case 96784904:
if (string.equals("error")) {
c2 = 5;
break;
}
break;
}
switch (c2) {
case 0:
if (jSONObject != null) {
ChatActivity.this.z6(jSONObject.getLong("id").longValue(), jSONObject.getInteger("status").intValue());
s sVar = new s();
sVar.f7788a = 1;
org.greenrobot.eventbus.c.f().o(sVar);
return;
}
return;
case 1:
if (jSONObject == null || !jSONObject.containsKey("from_uuid")) {
return;
}
String string2 = jSONObject.getString("from_uuid");
String string3 = jSONObject.getString("action");
if (string2.equals(ChatActivity.this.J)) {
if (string3.equals("isTyping")) {
ChatActivity.this.F.setText("对方正在输入...");
return;
} else {
ChatActivity.this.F.setText(ChatActivity.this.N);
return;
}
}
return;
case 2:
if (jSONObject == null || !jSONObject.containsKey("query_uuid")) {
return;
}
String string4 = jSONObject.getString("query_uuid");
int intValue = jSONObject.getInteger("online_time").intValue();
if (string4.equals(ChatActivity.this.J)) {
if (intValue == 0) {
ChatActivity.this.N = "离线";
ChatActivity.this.O.setBackgroundResource(R.drawable.shape_unonline_tag);
} else {
ChatActivity.this.N = "在线";
ChatActivity.this.O.setBackgroundResource(R.drawable.shape_online_tag);
}
ChatActivity.this.F.setText(ChatActivity.this.N);
return;
}
return;
case 3:
case 4:
if (jSONObject == null || (aVar = (com.tencent.mm.database.bean.a) JSON.parseObject(jSONObject.toJSONString(), com.tencent.mm.database.bean.a.class)) == null || !aVar.f7525c.equals(ChatActivity.this.J)) {
return;
}
ChatActivity.this.s.j(aVar);
ChatActivity.this.A6();
return;
case 5:
if (jSONObject == null || !jSONObject.containsKey("msg")) {
return;
}
o1.c(jSONObject.getString("msg"));
return;
default:
return;
}
}
}
j(ChatActivity chatActivity, a aVar) {
this();
}
}
public void A6() {
this.f7798b.requestLayout();
this.f7798b.post(new h());
}
private void B6(LocalMedia localMedia) {
com.tencent.mm.database.bean.a aVar = new com.tencent.mm.database.bean.a();
aVar.G = this.K;
aVar.H = this.L;
aVar.J = localMedia.a();
aVar.K = "photos";
aVar.s = this.J;
aVar.O = 22;
aVar.P = 5;
aVar.M = Long.valueOf(System.currentTimeMillis());
aVar.L = localMedia.a();
this.s.j(aVar);
E6(aVar);
A6();
}
private void D6() {
if (k.j().p()) {
JWebSocketClientService.N(this, com.tencent.mm.l.h.c().h().wsUrl, k.j().f().info);
}
}
private void E6(com.tencent.mm.database.bean.a sendBean) {
((PostRequest) OkGo.post(com.tencent.mm.network.d.G1().F1()).params(com.tencent.mm.network.d.G1().E4(sendBean.L))).execute(new i(sendBean));
}
private void m6() {
bindService(new Intent(this, JWebSocketClientService.class), this.I, 1);
}
private void n6(int id) {
((NotificationManager) getSystemService("notification")).cancel(id);
}
private void o6() {
this.M = new j(this, null);
registerReceiver(this.M, new IntentFilter(com.tencent.mm.c.C));
}
private void p6(boolean isScroll) {
if (TextUtils.isEmpty(this.J)) {
return;
}
com.tencent.mm.database.c.b().c().u();
com.tencent.mm.database.bean.d K = com.tencent.mm.database.c.b().c().z().b0().M(IMDataBeanDao.Properties.UserUuid.b(k.j().f().info.uuid), IMDataBeanDao.Properties.ChatUuid.b(this.J)).K();
if (K != null) {
n6(K.f7535a.intValue());
K.i = 0;
t tVar = new t();
tVar.f7790b = 1;
org.greenrobot.eventbus.c.f().o(tVar);
com.tencent.mm.database.c.b().c().z().o0(K);
List<com.tencent.mm.database.bean.a> v = com.tencent.mm.database.c.b().c().v().b0().M(ChatDataBeanDao.Properties.ImDataId.b(Integer.valueOf(K.f7535a.intValue())), new m[0]).E(ChatDataBeanDao.Properties.Id).z(this.P * 20).u(20).v();
Collections.reverse(v);
this.s.i(0, v);
if (isScroll) {
A6();
s sVar = new s();
sVar.f7788a = 1;
org.greenrobot.eventbus.c.f().o(sVar);
}
if (v.size() < 20) {
this.Q.e0(false);
return;
}
this.Q.e0(true);
this.P++;
}
}
private void q6() {
com.tencent.mm.im.d.e.n(this.f7799c.getEtChat());
this.f7799c.setAdapter(com.tencent.mm.im.d.e.h(this, this.U));
this.f7799c.addOnFuncKeyBoardListener(this);
SimpleAppsGridView simpleAppsGridView = new SimpleAppsGridView(this);
this.E = simpleAppsGridView;
simpleAppsGridView.setOnClick(new AdapterView.OnItemClickListener() {
@Override
public final void onItemClick(AdapterView adapterView, View view, int i2, long j2) {
ChatActivity.this.v6(adapterView, view, i2, j2);
}
});
this.f7799c.s(this.E);
this.f7799c.getEtChat().setOnSizeChangedListener(new EmoticonsEditText.b() {
@Override
public final void a(int i2, int i3, int i4, int i5) {
ChatActivity.this.x6(i2, i3, i4, i5);
}
});
this.f7799c.getBtnSend().setOnClickListener(new e());
this.f7799c.setOnOperationListener(new f());
}
private void r6() {
this.f7798b.setLayoutManager(new LinearLayoutManager(this));
this.s = new NewChatAdapter(new ArrayList());
((SimpleItemAnimator) this.f7798b.getItemAnimator()).setSupportsChangeAnimations(false);
this.s.setOnItemChildClickListener(new c());
this.f7798b.setAdapter(this.s);
this.f7798b.addOnItemTouchListener(new d());
p6(true);
}
private void s6() {
this.Q = (SmartRefreshLayout) findViewById(R.id.srl_index_content);
this.f7797a = (TextView) findViewById(R.id.title_tv);
this.F = (TextView) findViewById(R.id.text_chat_status);
this.O = (TextView) findViewById(R.id.text_online_tag);
this.f7798b = (RecyclerView) findViewById(R.id.rcv_msg_list);
this.S = (LinearLayout) findViewById(R.id.linear_friend);
this.f7799c = (XhsEmoticonsKeyBoard) findViewById(R.id.ek_bar);
findViewById(R.id.toolbar_back).setOnClickListener(this);
findViewById(R.id.text_black).setOnClickListener(this);
findViewById(R.id.text_more).setOnClickListener(this);
findViewById(R.id.relative_close).setOnClickListener(this);
findViewById(R.id.text_addfriend).setOnClickListener(this);
this.Q.x0(this);
this.Q.M(false);
this.Q.setOnClickListener(new a());
this.J = getIntent().getStringExtra(UserBox.TYPE);
this.K = getIntent().getStringExtra("nickName");
this.L = getIntent().getStringExtra("thumb");
if (this.R == null) {
this.R = new ChatSetModel(this);
}
this.R.j(this.J);
this.f7797a.setText(this.K);
q6();
r6();
A6();
if (this.I == null) {
this.I = new b();
}
D6();
m6();
o6();
}
public static boolean t6(View view, MotionEvent event) {
if (view == null) {
return false;
}
int[] iArr = new int[2];
view.getLocationOnScreen(iArr);
int i2 = iArr[0];
int i3 = iArr[1];
return ((float) i2) < event.getRawX() && event.getRawX() < ((float) (i2 + view.getWidth())) && ((float) i3) < event.getRawY() && event.getRawY() < ((float) (i3 + view.getHeight()));
}
public void v6(AdapterView adapterView, View view, int i2, long j2) {
this.E.getmAppBeanList().get(i2).b();
}
public void x6(int i2, int i3, int i4, int i5) {
this.f7798b.requestLayout();
}
public static void y6(Context activity, String nickName, String uuid, String thumb) {
Intent intent = new Intent(activity, ChatActivity.class);
intent.putExtra("nickName", nickName);
intent.putExtra(UserBox.TYPE, uuid);
intent.putExtra("thumb", thumb);
intent.setFlags(C.ENCODING_PCM_MU_LAW);
activity.startActivity(intent);
}
@Override
public void A4(l refreshLayout) {
p6(false);
if (refreshLayout != null && refreshLayout.W()) {
refreshLayout.w();
}
}
public void C6() {
if (!k.j().t()) {
p.a(this, "私聊功能指对VIP用户开放!");
} else if (this.T) {
p.a(this, "你已经拉黑该好友!");
} else {
com.luck.picture.lib.c.a(this).l(com.luck.picture.lib.config.b.o()).K(2131821084).r(1).s(1).m(4).E(1).y(true).z(true).g(false).n(true).q(true).f(false).b(true).J(true).j(Opcodes.IF_ICMPNE, Opcodes.IF_ICMPNE).p(false).i(true).a(false).G(false).H(false).u(false).M(10).t(100).h(188);
}
}
@Override
public void F3(String msg) {
o1.c(msg);
}
@Override
public void J0() {
}
@Override
public void O4(String data) {
JSONObject parseObject = JSON.parseObject(data);
if (parseObject.containsKey("isfriend")) {
if (parseObject.getBoolean("isfriend").booleanValue()) {
this.S.setVisibility(8);
} else {
this.S.setVisibility(0);
}
}
if (parseObject.containsKey("black")) {
if (parseObject.getBoolean("black").booleanValue()) {
this.T = true;
} else {
this.T = false;
}
}
}
@Override
public void S0(String msg) {
}
@Override
public void T0(int clickTag) {
}
@Override
public void V2(ChatSetBean msg) {
}
@Override
public void d3(String msg) {
}
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
if (sj.keyboard.e.a.i(this)) {
boolean u = this.f7799c.u(event);
return u ? u : super.dispatchKeyEvent(event);
}
return super.dispatchKeyEvent(event);
}
@Override
public void g0(String msg) {
o1.c("添加成功!");
this.S.setVisibility(8);
}
@Override
public void i4(String msg) {
}
@Override
public void l2() {
}
@Override
public void l3(int clickTag) {
}
@Override
public void o2(ChatSetBean msg) {
this.T = true;
o1.c(msg.msg);
this.S.setVisibility(8);
}
@Override
public void o5(String msg) {
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == -1 && requestCode == 188) {
List<LocalMedia> i2 = com.luck.picture.lib.c.i(data);
if (data == null || i2.size() <= 0) {
return;
}
B6(i2.get(0));
}
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.relative_close:
this.S.setVisibility(8);
return;
case R.id.text_addfriend:
ChatSetModel chatSetModel = this.R;
if (chatSetModel != null) {
chatSetModel.f(this.J);
return;
}
return;
case R.id.text_black:
ChatSetModel chatSetModel2 = this.R;
if (chatSetModel2 != null) {
chatSetModel2.g(this.J);
return;
}
return;
case R.id.text_more:
ChatSetActivity.w6(this, this.K, this.J);
return;
case R.id.toolbar_back:
onBackPressed();
return;
default:
return;
}
}
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_chat_friend);
org.greenrobot.eventbus.c.f().t(this);
s6();
}
@Override
public void onDestroy() {
super.onDestroy();
JWebSocketClientService jWebSocketClientService = this.H;
if (jWebSocketClientService != null) {
jWebSocketClientService.R();
}
unbindService(this.I);
unregisterReceiver(this.M);
org.greenrobot.eventbus.c.f().y(this);
}
@Override
public void onNewIntent(Intent intent) {
super.onNewIntent(intent);
this.J = intent.getStringExtra(UserBox.TYPE);
this.K = intent.getStringExtra("nickName");
this.L = intent.getStringExtra("thumb");
this.f7797a.setText(this.K);
this.T = false;
this.R.j(this.J);
p6(true);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == 16908332) {
finish();
return true;
}
return super.onOptionsItemSelected(item);
}
@Override
public void onPause() {
super.onPause();
com.tencent.mm.l.e.a().d(false);
this.f7799c.D();
}
@Override
public void onResume() {
super.onResume();
com.tencent.mm.l.e.a().d(true);
}
@Override
public void u0(String msg) {
o1.c(msg);
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void userInfoChange(com.tencent.mm.i.f event) {
int i2 = event.f7734a;
if (i2 == 2) {
this.S.setVisibility(8);
this.T = true;
JWebSocketClientService jWebSocketClientService = this.H;
if (jWebSocketClientService != null) {
jWebSocketClientService.k();
}
} else if (i2 != 3) {
} else {
this.T = false;
JWebSocketClientService jWebSocketClientService2 = this.H;
if (jWebSocketClientService2 != null) {
jWebSocketClientService2.q();
}
}
}
@Override
public void x2(int height) {
A6();
}
public void z6(long id, int status) {
for (int i2 = 0; i2 < this.s.N().size(); i2++) {
com.tencent.mm.database.bean.a aVar = (com.tencent.mm.database.bean.a) this.s.getItem(i2);
if (aVar.N.booleanValue() && aVar.M.longValue() == id) {
aVar.P = status;
this.s.notifyItemChanged(i2);
}
}
}
}