TIM v2.3.1版本的 MD5 值为:d6957e3ee7ce901ccc491cefdea0da8c
以下内容为反编译后的 MusicPendantManager.java 源代码,内容仅作参考
package com.tencent.mobileqq.musicpendant;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Message;
import android.text.TextUtils;
import com.tencent.common.app.AppInterface;
import com.tencent.mobileqq.activity.QQBrowserActivity;
import com.tencent.mobileqq.app.CardHandler;
import com.tencent.mobileqq.app.FriendsManager;
import com.tencent.mobileqq.app.QQAppInterface;
import com.tencent.mobileqq.app.ThreadManager;
import com.tencent.mobileqq.data.Card;
import com.tencent.mobileqq.music.QQPlayerService;
import com.tencent.mobileqq.music.SongInfo;
import com.tencent.mobileqq.musicgene.MusicGeneWebViewPlugin;
import com.tencent.mobileqq.vaswebviewplugin.VasWebviewConstants;
import com.tencent.qphone.base.util.BaseApplication;
import com.tencent.qphone.base.util.QLog;
import com.tencent.util.WeakReferenceHandler;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Iterator;
public class MusicPendantManager implements Handler.Callback {
public static final int f90854a = 10000;
private static MusicPendantManager f25234a = null;
private static final int f90855b = 1000;
private static final String f25237b = "MusicPendantManager";
private static WeakReference f25238b = null;
private static final int f90856c = 1001;
private Handler f25239a;
private HandlerThread f25240a = new HandlerThread(f25237b);
private QQPlayerService.QQPlayerCallback f25241a = new snp(this);
public WeakReference f25242a;
private boolean f25243a;
private SongInfo[] f25244a;
private String f25245c;
private static ArrayList f25236a = new ArrayList();
public static String f25235a = "";
private MusicPendantManager() {
this.f25240a.start();
this.f25239a = new WeakReferenceHandler(this.f25240a.getLooper(), this);
}
public static String m7078a() {
if (TextUtils.isEmpty(f25235a)) {
try {
f25235a = QQPlayerService.a(6, f25237b);
} catch (Exception e) {
QLog.e(f25237b, 1, "MusicPendantManager() exception", e);
}
}
return f25235a;
}
public static MusicPendantManager a() {
if (f25234a == null) {
f25234a = new MusicPendantManager();
}
return f25234a;
}
public void a(MusicPendantListener musicPendantListener) {
boolean z;
synchronized (f25236a) {
if (musicPendantListener != null) {
Iterator it = f25236a.iterator();
while (true) {
if (!it.hasNext()) {
z = false;
break;
}
WeakReference weakReference = (WeakReference) it.next();
if (weakReference != null && weakReference.get() == musicPendantListener) {
z = true;
break;
}
}
if (!z) {
f25236a.add(new WeakReference(musicPendantListener));
}
}
}
}
public void b(MusicPendantListener musicPendantListener) {
synchronized (f25236a) {
if (musicPendantListener != null) {
for (int size = (f25236a != null ? f25236a.size() : 0) - 1; size >= 0; size--) {
WeakReference weakReference = (WeakReference) f25236a.get(size);
if (weakReference != null && (weakReference.get() == null || weakReference.get() == musicPendantListener)) {
f25236a.remove(weakReference);
}
}
}
}
}
public void m7083a() {
synchronized (f25236a) {
f25236a.clear();
}
}
public void m7086b() {
try {
if (this.f25244a != null) {
Bundle m7018a = QQPlayerService.m7018a();
String str = m7018a != null ? m7018a.getLong(MusicGeneWebViewPlugin.p) + "" : "";
if (!TextUtils.isEmpty(this.f25245c) && this.f25245c.equalsIgnoreCase(str) && f25235a.equalsIgnoreCase(QQPlayerService.m7021a())) {
int a2 = QQPlayerService.a();
if (a2 == 2 || a2 == 1) {
if (!a(this.f25244a, QQPlayerService.m7033a())) {
a(0);
return;
}
return;
} else if (a2 == 3) {
QQPlayerService.b(m7080a());
return;
} else {
a(0);
return;
}
}
a(0);
return;
}
QLog.e(f25237b, 1, "play() mMusicPendantSongs is null!");
} catch (Exception e) {
QLog.e(f25237b, 1, "play() exception", e);
}
}
private void a(int i) {
try {
if (this.f25244a != null) {
try {
if (4 < QQPlayerService.a()) {
QLog.e(f25237b, 1, "playImmediately() mService 异常 需要杀掉重启 " + QQPlayerService.a());
QQPlayerService.c(m7080a());
}
} catch (Exception e) {
QLog.e(f25237b, 1, "playImmediately() mService.stop() exception", e);
}
Bundle bundle = new Bundle();
long j = 0;
try {
if (!TextUtils.isEmpty(this.f25245c)) {
j = Long.valueOf(this.f25245c).longValue();
}
} catch (Exception e2) {
e2.printStackTrace();
}
bundle.putLong(MusicGeneWebViewPlugin.p, j);
bundle.putInt(MusicGeneWebViewPlugin.v, 1);
QQPlayerService.a(bundle);
Intent a2 = a(false);
if (a2 != null) {
QQPlayerService.a(a2);
}
QQPlayerService.m7024a(102);
if (i < 0 || i > this.f25244a.length) {
i = 0;
}
QQPlayerService.a(this.f25241a);
QQPlayerService.a(m7080a(), f25235a, this.f25244a, i);
return;
}
QLog.e(f25237b, 1, "playImmediately() mMusicPendantSongs is null!");
} catch (Exception e3) {
QLog.e(f25237b, 1, "playImmediately() exception", e3);
}
}
@Override
public boolean handleMessage(Message message) {
int i = 0;
if (message != null) {
try {
i = message.what;
} catch (Exception e) {
QLog.e(f25237b, 1, "CallBack.handleMessage() exception", e);
}
}
switch (i) {
case 1000:
a(0);
break;
case 1001:
g();
break;
}
return true;
}
public void c() {
try {
if (this.f25244a != null) {
Bundle m7018a = QQPlayerService.m7018a();
String str = m7018a != null ? m7018a.getLong(MusicGeneWebViewPlugin.p) + "" : "";
if (!TextUtils.isEmpty(this.f25245c) && this.f25245c.equalsIgnoreCase(str) && f25235a.equalsIgnoreCase(QQPlayerService.m7021a())) {
int a2 = QQPlayerService.a();
if (a2 == 2 || a2 == 1) {
QQPlayerService.a(m7080a());
return;
} else if (a2 == 3) {
QQPlayerService.b(m7080a());
return;
} else {
a(0);
return;
}
}
a(0);
return;
}
QLog.e(f25237b, 1, "playOrPause() mMusicPendantSongs is null!");
} catch (Exception e) {
QLog.e(f25237b, 1, "playOrPause() exception", e);
}
}
public void d() {
try {
Bundle m7018a = QQPlayerService.m7018a();
String str = m7018a != null ? m7018a.getLong(MusicGeneWebViewPlugin.p) + "" : "";
if (!TextUtils.isEmpty(this.f25245c) && this.f25245c.equalsIgnoreCase(str) && f25235a.equalsIgnoreCase(QQPlayerService.m7021a())) {
QQPlayerService.a(m7080a());
}
} catch (Exception e) {
QLog.e(f25237b, 1, "pause() exception", e);
}
}
public SongInfo[] m7085a() {
return this.f25244a;
}
public void a(SongInfo[] songInfoArr) {
int length;
boolean z = false;
if (songInfoArr == null) {
length = -1;
} else {
try {
length = songInfoArr.length;
} catch (Exception e) {
QLog.e(f25237b, 1, "setMusicPendantSongList(SongInfo) exception", e);
return;
}
}
if (this.f25244a == null || length != this.f25244a.length) {
z = true;
} else {
int i = 0;
while (true) {
if (i >= length) {
break;
} else if (songInfoArr[i].f25176a != this.f25244a[i].f25176a) {
z = true;
break;
} else {
i++;
}
}
}
this.f25244a = songInfoArr;
if (z) {
ThreadManager.a(new snq(this), 8, null, true);
} else {
QLog.i(f25237b, 1, "setMusicPendantSongList(SongInfo) isPlayListChanged:false.");
}
}
public void a(String str) {
QQAppInterface qQAppInterface;
boolean z;
try {
} catch (Exception e) {
QLog.e(f25237b, 1, "setUin() exception", e);
}
if (this.f25242a != null && (qQAppInterface = (QQAppInterface) this.f25242a.get()) != null) {
if (!TextUtils.isEmpty(str)) {
if (str.equalsIgnoreCase((this.f25242a == null || qQAppInterface == null) ? "" : qQAppInterface.getCurrentAccountUin())) {
z = true;
this.f25243a = z;
if (!TextUtils.isEmpty(str) && !str.equalsIgnoreCase(this.f25245c)) {
this.f25244a = null;
}
this.f25245c = str;
}
}
z = false;
this.f25243a = z;
if (!TextUtils.isEmpty(str)) {
this.f25244a = null;
}
this.f25245c = str;
}
}
public void a(Card card) {
try {
Iterator it = f25236a.iterator();
while (it.hasNext()) {
MusicPendantListener musicPendantListener = (MusicPendantListener) ((WeakReference) it.next()).get();
if (musicPendantListener != null) {
musicPendantListener.b(card);
}
}
} catch (Exception e) {
QLog.e(f25237b, 1, "setUin() exception", e);
}
}
public String b() {
return this.f25245c;
}
public void e() {
try {
try {
if (this.f25239a != null) {
this.f25239a.removeCallbacksAndMessages(null);
this.f25239a.removeMessages(0);
}
Iterator it = f25236a.iterator();
while (it.hasNext()) {
MusicPendantListener musicPendantListener = (MusicPendantListener) ((WeakReference) it.next()).get();
if (musicPendantListener != null) {
musicPendantListener.a();
}
}
m7083a();
} catch (Exception e) {
QLog.e(f25237b, 1, "destroy() exception1", e);
}
if (this.f25242a != null) {
this.f25242a.clear();
this.f25242a = null;
}
if (f25238b != null) {
f25238b.clear();
f25238b = null;
}
} catch (Exception e2) {
QLog.e(f25237b, 1, "destroy() exception2", e2);
}
}
public void a(String str, QQAppInterface qQAppInterface, Activity activity) {
try {
if (activity != null) {
f25238b = new WeakReference(activity);
} else {
f25238b = null;
}
if (qQAppInterface != null) {
this.f25242a = new WeakReference(qQAppInterface);
} else {
this.f25242a = null;
}
a(str);
f();
if (this.f25239a != null) {
this.f25239a.sendEmptyMessageDelayed(1001, 100L);
}
} catch (Exception e) {
QLog.e(f25237b, 1, "init(uinString) exception", e);
}
}
public QQAppInterface m7081a() {
if (this.f25242a != null) {
return (QQAppInterface) this.f25242a.get();
}
return null;
}
public void f() {
QQAppInterface qQAppInterface;
try {
if (this.f25242a != null && (qQAppInterface = (QQAppInterface) this.f25242a.get()) != null) {
if (this.f25242a != null && qQAppInterface != null) {
CardHandler cardHandler = (CardHandler) qQAppInterface.getBusinessHandler(2);
if (cardHandler != null) {
cardHandler.c(qQAppInterface.getCurrentAccountUin(), b());
}
} else {
QLog.e(f25237b, 1, "request4MusicPendantSongList() mAppInterface is null!");
}
}
} catch (Exception e) {
QLog.e(f25237b, 1, "request4MusicPendantSongList() exception", e);
}
}
public void g() {
QQAppInterface qQAppInterface;
try {
if (this.f25242a != null && (qQAppInterface = (QQAppInterface) this.f25242a.get()) != null) {
if (this.f25242a != null && qQAppInterface != null) {
CardHandler cardHandler = (CardHandler) qQAppInterface.getBusinessHandler(2);
if (cardHandler != null) {
cardHandler.b(qQAppInterface.getCurrentAccountUin(), b());
}
} else {
QLog.e(f25237b, 1, "request4MusicPendantSettings() mAppInterface is null!");
}
}
} catch (Exception e) {
QLog.e(f25237b, 1, "request4MusicPendantSettings() exception", e);
}
}
public void a(int i, int i2) {
QQAppInterface qQAppInterface;
try {
if (this.f25242a != null && (qQAppInterface = (QQAppInterface) this.f25242a.get()) != null) {
if (this.f25242a != null && qQAppInterface != null) {
CardHandler cardHandler = (CardHandler) qQAppInterface.getBusinessHandler(2);
if (cardHandler != null) {
cardHandler.a(b(), i, i2);
}
} else {
QLog.e(f25237b, 1, "request4MusicPendantSettings() mAppInterface is null!");
}
}
} catch (Exception e) {
QLog.e(f25237b, 1, "request4MusicPendantSettings() exception", e);
}
}
public boolean m7084a() {
return this.f25243a;
}
public Intent a(boolean z) {
return a(f25238b != null ? (Activity) f25238b.get() : null, this.f25242a != null ? (QQAppInterface) this.f25242a.get() : null, this.f25245c, z);
}
public static Intent a(Context context, AppInterface appInterface, String str, boolean z) {
Intent intent;
Exception e;
String str2;
if (context == null) {
try {
context = BaseApplication.getContext();
} catch (Exception e2) {
intent = null;
e = e2;
QLog.e(f25237b, 1, "getPlayBarIntent() exception", e);
return intent;
}
}
intent = new Intent(context, QQBrowserActivity.class);
String str3 = "http://y.qq.com/m/personal_music/index.html?_wv=3&_bid=2032";
try {
if (appInterface != null) {
str3 = "http://y.qq.com/m/personal_music/index.html?_wv=3&_bid=2032&uin=" + appInterface.getCurrentAccountUin();
} else {
QLog.e(f25237b, 1, "openMusicPendantSettingPage() app is null.");
}
if (!TextUtils.isEmpty(str)) {
str3 = str3 + "&guestuin=" + str;
}
if (z) {
str2 = str3 + "&ADTAG=GXYY_GUAJIAN";
} else {
str2 = str3 + "&ADTAG=GXYY_TOPCELL";
}
intent.putExtra("url", str2);
intent.putExtra(VasWebviewConstants.KEY_OPEN_PAGE_TIME, System.currentTimeMillis());
} catch (Exception e3) {
e = e3;
QLog.e(f25237b, 1, "getPlayBarIntent() exception", e);
return intent;
}
return intent;
}
public Card m7082a() {
try {
if (this.f25242a != null && this.f25242a.get() != null) {
String currentAccountUin = ((QQAppInterface) this.f25242a.get()).getCurrentAccountUin();
FriendsManager friendsManager = (FriendsManager) ((QQAppInterface) this.f25242a.get()).getManager(50);
if (friendsManager != null) {
if (!TextUtils.isEmpty(currentAccountUin)) {
return friendsManager.m4345b(currentAccountUin);
}
QLog.e(f25237b, 1, "localUserUinString is empty");
return null;
}
QLog.e(f25237b, 1, "FriendsManager is null");
} else {
QLog.e(f25237b, 1, "mAppInterface is null");
}
} catch (Exception e) {
QLog.e(f25237b, 1, "getLocalUserCard() exception", e);
}
return null;
}
public static boolean a(SongInfo[] songInfoArr, SongInfo[] songInfoArr2) {
if (songInfoArr == null || songInfoArr2 == null) {
return false;
}
if (songInfoArr == songInfoArr2) {
return true;
}
int length = songInfoArr.length;
int length2 = songInfoArr2.length;
if (length != length2 || length == 0) {
return false;
}
for (int i = 0; i < length2; i++) {
if (songInfoArr[i].f25176a != songInfoArr2[i].f25176a) {
return false;
}
}
return true;
}
public Context m7080a() {
Activity activity = f25238b != null ? (Activity) f25238b.get() : null;
if (activity == null) {
return BaseApplication.getContext();
}
return activity;
}
}