酷狗概念版 v2.5.5版本的 MD5 值为:782d327088fca4e58310f35a56f41319

以下内容为反编译后的 n.java 源代码,内容仅作参考


package com.kugou.android.app.flexowebview;

import android.content.Context;
import android.os.Bundle;
import android.os.RemoteException;
import android.text.TextUtils;
import android.util.Pair;
import com.huawei.hms.push.constant.RemoteMessageConst;
import com.kugou.android.app.msgchat.ChatFragment;
import com.kugou.android.common.entity.KGMusic;
import com.kugou.android.musiccircle.MusicZoneUtils;
import com.kugou.common.app.KGCommonApplication;
import com.kugou.common.msgcenter.c.aa;
import com.kugou.common.msgcenter.c.z;
import com.kugou.common.msgcenter.entity.MsgEntity;
import com.kugou.common.push.f;
import com.kugou.common.utils.as;
import com.kugou.common.utils.br;
import com.kugou.common.utils.bv;
import com.kugou.common.utils.cw;
import com.kugou.common.utils.cz;
import com.kugou.framework.database.KGMusicDao;
import com.kugou.framework.database.ah;
import com.sina.weibo.sdk.auth.Oauth2AccessToken;
import com.tencent.open.SocialConstants;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

public class n {

    rx.l f9447a;

    private WeakReference<AbsFlexoLogicFragment> f9448b;

    public n(AbsFlexoLogicFragment absFlexoLogicFragment) {
        this.f9448b = new WeakReference<>(absFlexoLogicFragment);
    }

    public AbsFlexoLogicFragment a() {
        WeakReference<AbsFlexoLogicFragment> weakReference = this.f9448b;
        if (weakReference != null) {
            return weakReference.get();
        }
        return null;
    }

    public void a(String str) {
        if (TextUtils.isEmpty(str)) {
            return;
        }
        final c f = f(str);
        if (!f.a()) {
            bv.a(KGCommonApplication.getContext(), "emmm~网络有误,请移步到消息中心继续畅聊");
        } else {
            this.f9447a = rx.e.a(f).a(Schedulers.io()).d(new rx.b.e<c, Boolean>() {
                @Override
                public Boolean call(c cVar) {
                    List a2 = cz.a(cVar.f, 50);
                    if (com.kugou.framework.common.utils.f.a(a2)) {
                        Iterator it = a2.iterator();
                        while (it.hasNext()) {
                            if (!n.this.a(cVar.f9466d, cVar.f9465c, (List<MsgEntity>) it.next())) {
                                return false;
                            }
                        }
                    }
                    return true;
                }
            }).a(AndroidSchedulers.mainThread()).a((rx.b.b) new rx.b.b<Boolean>() {
                @Override
                public void call(Boolean bool) {
                    if (f.f9463a) {
                        n.this.a(f.f9467e, f.f9464b);
                    }
                }
            }, new rx.b.b<Throwable>() {
                @Override
                public void call(Throwable th) {
                    if (f.f9463a) {
                        n.this.a(f.f9467e, f.f9464b);
                    }
                }
            });
        }
    }

    public void a(com.kugou.common.msgcenter.commonui.a aVar, boolean z) {
        Bundle bundle = new Bundle();
        bundle.putSerializable("chat_depend_info", aVar);
        if (a() != null) {
            if (z) {
                a().replaceFragment(ChatFragment.class, bundle);
            } else {
                a().startFragment(ChatFragment.class, bundle);
            }
        }
    }

    private c f(String str) {
        c cVar = new c();
        try {
            JSONObject jSONObject = new JSONObject(str);
            boolean z = true;
            cVar.f9463a = jSONObject.optInt("jumpNativeChatPage", 1) == 1;
            if (jSONObject.optInt("closeWebview", 1) != 1) {
                z = false;
            }
            cVar.f9464b = z;
            cVar.f9466d = jSONObject.optString(RemoteMessageConst.Notification.TAG);
            cVar.f9465c = jSONObject.optString("key");
            JSONObject optJSONObject = jSONObject.optJSONObject("fan");
            if (optJSONObject != null) {
                com.kugou.common.msgcenter.commonui.a aVar = new com.kugou.common.msgcenter.commonui.a(null, com.kugou.common.environment.a.z(), optJSONObject.optInt("id", -1), 9);
                aVar.f49904e = optJSONObject.optString("nickname");
                aVar.f49903d = optJSONObject.optString("pic");
                cVar.f9467e = aVar;
            }
            JSONArray optJSONArray = jSONObject.optJSONArray("list");
            if (optJSONArray != null && optJSONArray.length() > 0) {
                cVar.f = new ArrayList();
                for (int i = 0; i < optJSONArray.length(); i++) {
                    MsgEntity msgEntity = new MsgEntity();
                    JSONObject optJSONObject2 = optJSONArray.optJSONObject(i);
                    msgEntity.uid = optJSONObject2.optLong(Oauth2AccessToken.KEY_UID);
                    msgEntity.msgid = cw.b(optJSONObject2.optString("msgid", "0"));
                    msgEntity.message = optJSONObject2.optJSONObject("message").toString();
                    msgEntity.addtime = optJSONObject2.optLong("addtime");
                    cVar.f.add(msgEntity);
                }
            }
        } catch (Exception e2) {
            e2.printStackTrace();
        }
        return cVar;
    }

    public boolean a(String str, String str2, List<MsgEntity> list) {
        com.kugou.common.msgcenter.entity.m a2 = new aa().a(str, str2, list);
        return a2 != null && a2.f50116a == 1;
    }

    public void b(String str) {
        if (a() == null) {
            return;
        }
        if (!MusicZoneUtils.a((Context) a().getActivity(), true)) {
            JSONObject jSONObject = new JSONObject();
            try {
                jSONObject.put("status", 0);
            } catch (JSONException e2) {
                e2.printStackTrace();
            }
            a().loadUrl("javascript:KgWebMobileCall.snapChatSendMsgCallback(" + jSONObject.toString() + ")");
            return;
        }
        rx.e.a(str).b(Schedulers.io()).d(new rx.b.e<String, com.kugou.common.msgcenter.entity.m>() {
            @Override
            public com.kugou.common.msgcenter.entity.m call(String str2) {
                return new z().a(str2);
            }
        }).a(AndroidSchedulers.mainThread()).b(new rx.b.b<com.kugou.common.msgcenter.entity.m>() {
            @Override
            public void call(com.kugou.common.msgcenter.entity.m mVar) {
                if (n.this.a() == null || mVar == null) {
                    return;
                }
                JSONObject jSONObject2 = new JSONObject();
                try {
                    jSONObject2.put("status", mVar.f50116a);
                    jSONObject2.put("errcode", mVar.f50117b);
                    jSONObject2.put("error", mVar.f50118c);
                    if (mVar.f50119d != null) {
                        JSONObject jSONObject3 = new JSONObject();
                        jSONObject3.put(RemoteMessageConst.Notification.TAG, mVar.f50119d.tag);
                        jSONObject3.put("addtime", mVar.f50119d.addtime);
                        jSONObject3.put("msgid", mVar.f50119d.msgid);
                        jSONObject2.put("data", jSONObject3.toString());
                    }
                } catch (JSONException e3) {
                    e3.printStackTrace();
                }
                n.this.a().loadUrl("javascript:KgWebMobileCall.snapChatSendMsgCallback(" + jSONObject2.toString() + ")");
            }
        });
    }

    public void c(String str) {
        if (TextUtils.isEmpty(str)) {
            return;
        }
        try {
            int optInt = new JSONObject(str).optInt("status", -1);
            if (1 == optInt) {
                com.kugou.common.msgcenter.d.e("tchat", new b());
                c();
            } else if (optInt == 0) {
                com.kugou.common.msgcenter.d.f("tchat", new b());
            }
        } catch (Exception e2) {
            e2.printStackTrace();
        }
    }

    public void b() {
        try {
            JSONObject jSONObject = new JSONObject();
            jSONObject.put("height", br.A(KGCommonApplication.getContext()));
            if (a() != null) {
                a().loadUrl("javascript:KgWebMobileCall.getStatusBarHeightCallback(" + jSONObject.toString() + ")");
            }
        } catch (Exception e2) {
            e2.printStackTrace();
        }
    }

    public void c() {
        final long currentTimeMillis = System.currentTimeMillis() - 2592000000L;
        rx.e.a((Object) null).b(Schedulers.io()).d(new rx.b.e<Object, List<a>>() {
            @Override
            public List<a> call(Object obj) {
                Map<Long, KGMusic> map;
                KGMusic kGMusic;
                List<com.kugou.android.common.entity.q> b2 = ah.b(100);
                if (b2 != null && b2.size() > 0) {
                    ArrayList arrayList = new ArrayList();
                    for (com.kugou.android.common.entity.q qVar : b2) {
                        if (qVar != null) {
                            long a2 = qVar.a();
                            if (a2 > 0 && qVar.c() >= currentTimeMillis) {
                                arrayList.add(Pair.create(Long.valueOf(a2), Long.valueOf(qVar.c())));
                            }
                        }
                    }
                    if (arrayList.size() > 0) {
                        long[] jArr = new long[arrayList.size()];
                        int size = arrayList.size();
                        for (int i = 0; i < size; i++) {
                            jArr[i] = ((Long) ((Pair) arrayList.get(i)).first).longValue();
                        }
                        map = KGMusicDao.getKGMusicByIds(jArr);
                    } else {
                        map = null;
                    }
                    ArrayList arrayList2 = new ArrayList();
                    if (map != null) {
                        Iterator it = arrayList.iterator();
                        while (it.hasNext()) {
                            Pair pair = (Pair) it.next();
                            if (pair != null && (kGMusic = map.get(pair.first)) != null) {
                                a aVar = new a();
                                aVar.f9459a = String.valueOf(kGMusic.Q());
                                aVar.f9460b = kGMusic.r();
                                aVar.f9461c = String.valueOf(kGMusic.au());
                                aVar.f9462d = ((Long) pair.second).longValue();
                                arrayList2.add(aVar);
                            }
                        }
                    }
                    return arrayList2;
                }
                return new ArrayList();
            }
        }).a(Schedulers.io()).b(new rx.b.b<List<a>>() {
            @Override
            public void call(List<a> list) {
                if (com.kugou.framework.common.utils.f.a(list)) {
                    try {
                        JSONObject jSONObject = new JSONObject();
                        JSONArray jSONArray = new JSONArray();
                        for (a aVar : list) {
                            JSONObject jSONObject2 = new JSONObject();
                            jSONObject2.put("album_audio_id", aVar.f9459a);
                            jSONObject2.put("audio_hash", aVar.f9460b);
                            jSONObject2.put("audio_id", aVar.f9461c);
                            jSONObject2.put("time", aVar.f9462d / 1000);
                            jSONArray.put(jSONObject2);
                        }
                        jSONObject.put("songs", jSONArray);
                        if (n.this.a() != null) {
                            n.this.a().loadUrl("javascript:KgWebMobileCall.getRecentSongs(" + jSONObject.toString() + ")");
                        }
                    } catch (JSONException e2) {
                        e2.printStackTrace();
                    }
                }
            }
        });
    }

    public void d(String str) {
        if (TextUtils.isEmpty(str) || a() == null) {
            return;
        }
        try {
            JSONObject jSONObject = new JSONObject(str);
            int optInt = jSONObject.optInt("id");
            String optString = jSONObject.optString("pic");
            String optString2 = jSONObject.optString("name");
            int optInt2 = jSONObject.optInt(SocialConstants.PARAM_SOURCE);
            int optInt3 = jSONObject.optInt("closeWebview", 0);
            com.kugou.common.msgcenter.commonui.a aVar = new com.kugou.common.msgcenter.commonui.a(null, com.kugou.common.environment.a.z(), optInt, optInt2);
            aVar.f49904e = optString2;
            aVar.f49903d = optString;
            boolean z = true;
            if (optInt3 != 1) {
                z = false;
            }
            a(aVar, z);
        } catch (Exception e2) {
            e2.printStackTrace();
        }
    }

    public String e(String str) {
        String optString;
        JSONObject jSONObject = new JSONObject();
        if (TextUtils.isEmpty(str) || a() == null) {
            return jSONObject.toString();
        }
        try {
            optString = new JSONObject(str).optString(RemoteMessageConst.Notification.TAG);
        } catch (Exception e2) {
            e2.printStackTrace();
        }
        if (TextUtils.isEmpty(optString)) {
            jSONObject.put("status", 0);
            return jSONObject.toString();
        }
        jSONObject.put("status", com.kugou.common.msgcenter.a.g.d(optString, com.kugou.common.environment.a.Y()) ? 1 : 0);
        return jSONObject.toString();
    }

    public static class a {

        public String f9459a;

        public String f9460b;

        public String f9461c;

        public long f9462d;

        private a() {
        }
    }

    public static class c {

        public boolean f9463a;

        public boolean f9464b;

        public String f9465c;

        public String f9466d;

        public com.kugou.common.msgcenter.commonui.a f9467e;
        public List<MsgEntity> f;

        private c() {
        }

        public boolean a() {
            com.kugou.common.msgcenter.commonui.a aVar;
            return (TextUtils.isEmpty(this.f9465c) || TextUtils.isEmpty(this.f9466d) || (aVar = this.f9467e) == null || aVar.i <= 0) ? false : true;
        }
    }

    public static class b extends f.a {
        private b() {
        }

        @Override
        public void a(boolean z, String str) throws RemoteException {
            if (as.f54365e) {
                as.b("snapchat", "snapchat: onTagResponsed " + z + ", " + str);
            }
        }

        @Override
        public void a() throws RemoteException {
            if (as.f54365e) {
                as.b("snapchat", "snapchat: onCancelled ");
            }
        }
    }

    public void d() {
        rx.l lVar = this.f9447a;
        if (lVar != null) {
            com.kugou.android.app.fanxing.live.e.b.a(lVar);
        }
    }
}