i自然 v1.5.2版本的 MD5 值为:4186de3133535afd3ad8a76e7e4d0eff
以下内容为反编译后的 VoiceBroadcastUtils.java 源代码,内容仅作参考
package com.mnr.app.app;
import android.R;
import android.app.Activity;
import android.widget.FrameLayout;
import com.google.android.exoplayer2.text.ttml.TtmlNode;
import com.google.gson.Gson;
import com.mnr.app.base.AcManager;
import com.mnr.app.base.adpter.ActivityLifecycleAdapter;
import com.mnr.app.net.BaseObserver;
import com.mnr.app.net.HttpService;
import com.mnr.app.voice.TTSUtils;
import com.mnr.app.voice.bean.VoiceBean;
import com.mnr.app.voice.inter.Voice;
import com.mnr.app.voice.view.VoiceView;
import com.mnr.app.wedia.bean.MediaNewsListBean;
import com.mnr.dependencies.Utils.DisplayUtil;
import com.mnr.dependencies.Utils.Loger;
import com.mnr.dependencies.Utils.ToastUtils;
import com.umeng.socialize.net.dplus.CommonNetImpl;
import io.reactivex.rxjava3.core.Observable;
import io.reactivex.rxjava3.core.ObservableSource;
import io.reactivex.rxjava3.functions.Function;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Objects;
import kotlin.Metadata;
import kotlin.Unit;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.functions.Function2;
import kotlin.jvm.internal.Intrinsics;
import okhttp3.ResponseBody;
@Metadata(d1 = {"\u0000T\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\u0010\u000e\n\u0002\u0010\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\b\n\u0002\b\r\bÆ\u0002\u0018\u00002\u00020\u0001B\u0007\b\u0002¢\u0006\u0002\u0010\u0002J\u000e\u0010\u0013\u001a\u00020\u00142\u0006\u0010\u0015\u001a\u00020\u0016J2\u0010\u0017\u001a\u00020\u00142\"\u0010\u0003\u001a\u001e\u0012\u0004\u0012\u00020\u0005\u0012\u0004\u0012\u00020\u00060\u0004j\u000e\u0012\u0004\u0012\u00020\u0005\u0012\u0004\u0012\u00020\u0006`\u00072\u0006\u0010\u0018\u001a\u00020\u0019J\b\u0010\u001a\u001a\u00020\u0014H\u0016J*\u0010\u001b\u001a\u00020\u00142\"\u0010\u001c\u001a\u001e\u0012\u0004\u0012\u00020\u0005\u0012\u0004\u0012\u00020\u00060\u0004j\u000e\u0012\u0004\u0012\u00020\u0005\u0012\u0004\u0012\u00020\u0006`\u0007J\u0006\u0010\u001d\u001a\u00020\u0000J\u0010\u0010\u001e\u001a\u00020\u00142\u0006\u0010\u001f\u001a\u00020\tH\u0016J\b\u0010 \u001a\u00020\u0014H\u0016J\u0006\u0010!\u001a\u00020\u0014J\u0006\u0010\"\u001a\u00020\u0014J\b\u0010#\u001a\u00020\u0014H\u0016J,\u0010$\u001a\u00020\u00142\"\u0010\u001c\u001a\u001e\u0012\u0004\u0012\u00020\u0005\u0012\u0004\u0012\u00020\u00060\u0004j\u000e\u0012\u0004\u0012\u00020\u0005\u0012\u0004\u0012\u00020\u0006`\u0007H\u0016J\u000e\u0010%\u001a\u00020\u00142\u0006\u0010\u001f\u001a\u00020\tR.\u0010\u0003\u001a\"\u0012\u0004\u0012\u00020\u0005\u0012\u0004\u0012\u00020\u0006\u0018\u00010\u0004j\u0010\u0012\u0004\u0012\u00020\u0005\u0012\u0004\u0012\u00020\u0006\u0018\u0001`\u0007X\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\b\u001a\u0004\u0018\u00010\tX\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\n\u001a\u00020\u000bX\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\f\u001a\u00020\u000bX\u0082\u000e¢\u0006\u0002\n\u0000R\u001e\u0010\r\u001a\u0012\u0012\u0004\u0012\u00020\u00050\u000ej\b\u0012\u0004\u0012\u00020\u0005`\u000fX\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0010\u001a\u00020\u000bX\u0082\u000e¢\u0006\u0002\n\u0000R\u0014\u0010\u0011\u001a\u0004\u0018\u00010\u00128\u0002@\u0002X\u0083\u000e¢\u0006\u0002\n\u0000¨\u0006&"}, d2 = {"Lcom/mnr/app/app/VoiceBroadcastUtils;", "Lcom/mnr/app/voice/inter/Voice;", "()V", "currentDataMap", "Ljava/util/HashMap;", "", "", "Lkotlin/collections/HashMap;", "currentVoiceBean", "Lcom/mnr/app/voice/bean/VoiceBean;", "isAdd", "", "isBind", "list", "Ljava/util/ArrayList;", "Lkotlin/collections/ArrayList;", "mOpen", "voiceView", "Lcom/mnr/app/voice/view/VoiceView;", "addVoiceView", "", "activity", "Landroid/app/Activity;", "checkMediaData", "index", "", "close", "getNetData", "data", "init", "next", "bean", "pause", "registerActivityLifecycle", "resetTemp", "resume", TtmlNode.START, "updateView", "app_release"}, k = 1, mv = {1, 6, 0}, xi = 48)
public final class VoiceBroadcastUtils implements Voice {
private static HashMap<String, Object> currentDataMap;
private static VoiceBean currentVoiceBean;
private static boolean isAdd;
private static boolean isBind;
private static boolean mOpen;
private static VoiceView voiceView;
public static final VoiceBroadcastUtils INSTANCE = new VoiceBroadcastUtils();
private static ArrayList<String> list = new ArrayList<>();
public final VoiceBroadcastUtils init() {
return this;
}
private VoiceBroadcastUtils() {
}
public final void registerActivityLifecycle() {
if (isBind) {
return;
}
isBind = true;
Myapp.INSTANCE.getApp().registerActivityLifecycleCallbacks(new ActivityLifecycleAdapter() {
@Override
public void onStop(Activity activity) {
ArrayList arrayList;
Intrinsics.checkNotNullParameter(activity, "activity");
super.onStop(activity);
arrayList = VoiceBroadcastUtils.list;
arrayList.remove(activity.getClass().getSimpleName());
}
});
}
@Override
public void pause() {
TTSUtils companion = TTSUtils.INSTANCE.getInstance();
if (companion != null) {
companion.pause();
}
}
@Override
public void resume() {
TTSUtils companion = TTSUtils.INSTANCE.getInstance();
if (companion != null) {
companion.resume();
}
}
public final void getNetData(final HashMap<String, Object> data) {
Observable<ResponseBody> observable;
ObservableSource map;
Intrinsics.checkNotNullParameter(data, "data");
Object obj = data.get("type");
if (Intrinsics.areEqual(obj, (Object) 0)) {
HttpService httpService = HttpService.INSTANCE;
HashMap hashMap = new HashMap();
hashMap.put(CommonNetImpl.AID, String.valueOf(data.get(CommonNetImpl.AID)));
hashMap.put("cid", String.valueOf(data.get("cid")));
Unit unit = Unit.INSTANCE;
observable = httpService.get("getVoiceArticle", hashMap);
} else if (Intrinsics.areEqual(obj, (Object) 1)) {
HttpService httpService2 = HttpService.INSTANCE;
HashMap hashMap2 = new HashMap();
hashMap2.put("articleID", String.valueOf(data.get(CommonNetImpl.AID)));
Unit unit2 = Unit.INSTANCE;
observable = httpService2.get("https://api.iziran.net/media/getVoiceArticle", hashMap2);
} else {
observable = null;
}
if (observable == null || (map = observable.map(new Function() {
@Override
public final Object apply(Object obj2) {
VoiceBean m104getNetData$lambda2;
m104getNetData$lambda2 = VoiceBroadcastUtils.m104getNetData$lambda2((ResponseBody) obj2);
return m104getNetData$lambda2;
}
})) == null) {
return;
}
map.subscribe(new BaseObserver<VoiceBean>() {
@Override
public void onNextBase(VoiceBean t) {
Intrinsics.checkNotNullParameter(t, "t");
VoiceBroadcastUtils voiceBroadcastUtils = VoiceBroadcastUtils.INSTANCE;
VoiceBroadcastUtils.currentDataMap = data;
TTSUtils companion = TTSUtils.INSTANCE.getInstance();
if (companion != null) {
String content = t.getContent();
Intrinsics.checkNotNullExpressionValue(content, "t.content");
companion.start(content);
}
VoiceBroadcastUtils voiceBroadcastUtils2 = VoiceBroadcastUtils.INSTANCE;
VoiceBroadcastUtils.currentVoiceBean = t;
VoiceBroadcastUtils.INSTANCE.updateView(t);
}
});
}
public static final VoiceBean m104getNetData$lambda2(ResponseBody responseBody) {
return (VoiceBean) new Gson().fromJson(responseBody.string(), VoiceBean.class);
}
public final void updateView(VoiceBean bean) {
Intrinsics.checkNotNullParameter(bean, "bean");
VoiceView voiceView2 = voiceView;
if (voiceView2 != null || mOpen) {
if (voiceView2 != null) {
voiceView2.setCurrentVoiceBean(bean);
}
VoiceView voiceView3 = voiceView;
if (voiceView3 != null) {
HashMap<String, Object> hashMap = currentDataMap;
Intrinsics.checkNotNull(hashMap);
voiceView3.start(hashMap);
}
}
}
@Override
public void start(HashMap<String, Object> data) {
Intrinsics.checkNotNullParameter(data, "data");
Myapp.INSTANCE.getApp().initSpeechSDK();
if (mOpen) {
if (currentDataMap != null) {
Object obj = data.get("type");
HashMap<String, Object> hashMap = currentDataMap;
if (Intrinsics.areEqual(obj, hashMap != null ? hashMap.get("type") : null)) {
Object obj2 = data.get(CommonNetImpl.AID);
HashMap<String, Object> hashMap2 = currentDataMap;
if (Intrinsics.areEqual(obj2, hashMap2 != null ? hashMap2.get(CommonNetImpl.AID) : null)) {
Object obj3 = data.get("cid");
HashMap<String, Object> hashMap3 = currentDataMap;
if (Intrinsics.areEqual(obj3, hashMap3 != null ? hashMap3.get("cid") : null)) {
Loger.e("123", "点击的稿件跟正在播放的稿件为同一篇~~");
return;
}
}
}
}
Loger.e("123", "切换一个新的稿件!!");
getNetData(data);
return;
}
mOpen = true;
AcManager.INSTANCE.createDoOnAfter(new Function2<Activity, Activity, Unit>() {
@Override
public Unit invoke(Activity activity, Activity activity2) {
invoke2(activity, activity2);
return Unit.INSTANCE;
}
public final void invoke2(Activity a, Activity b) {
boolean z;
Intrinsics.checkNotNullParameter(a, "a");
Intrinsics.checkNotNullParameter(b, "b");
z = VoiceBroadcastUtils.mOpen;
if (z) {
Loger.e("123", "------createDoOnAfter--------");
FrameLayout frameLayout = (FrameLayout) a.getWindow().getDecorView().findViewById(R.id.content);
if (frameLayout.getChildAt(1) instanceof VoiceView) {
frameLayout.removeViewAt(1);
Loger.e("123", "-----remove------------");
}
VoiceBroadcastUtils.INSTANCE.addVoiceView(b);
}
}
});
AcManager.INSTANCE.destroyDoOnAfter(new Function1<Activity, Unit>() {
@Override
public Unit invoke(Activity activity) {
invoke2(activity);
return Unit.INSTANCE;
}
public final void invoke2(Activity it) {
boolean z;
Intrinsics.checkNotNullParameter(it, "it");
z = VoiceBroadcastUtils.mOpen;
if (z) {
Loger.e("123", "------destroyDoOnAfter--------");
VoiceBroadcastUtils.INSTANCE.addVoiceView(it);
}
}
});
if (mOpen && AcManager.INSTANCE.getCurrentActivity() != null && !isAdd) {
Activity currentActivity = AcManager.INSTANCE.getCurrentActivity();
Intrinsics.checkNotNull(currentActivity);
addVoiceView(currentActivity);
getNetData(data);
}
TTSUtils companion = TTSUtils.INSTANCE.getInstance();
if (companion != null) {
companion.setPlayViewState(new TTSUtils.PlayViewStateListener() {
@Override
public void start() {
}
@Override
public void end() {
VoiceView voiceView2;
voiceView2 = VoiceBroadcastUtils.voiceView;
if (voiceView2 != null) {
voiceView2.close();
}
}
});
}
}
@Override
public void next(VoiceBean bean) {
Intrinsics.checkNotNullParameter(bean, "bean");
HashMap<String, Object> hashMap = currentDataMap;
Object obj = hashMap != null ? hashMap.get("type") : null;
Objects.requireNonNull(obj, "null cannot be cast to non-null type kotlin.Int");
int intValue = ((Integer) obj).intValue();
if (intValue != 0) {
if (intValue != 1) {
return;
}
HashMap<String, Object> hashMap2 = currentDataMap;
Intrinsics.checkNotNull(hashMap2);
checkMediaData(hashMap2, 0);
return;
}
if (bean.getNextArticleID() == -1 || bean.getNextArticleID() == 0) {
ToastUtils.showShort("暂无下一曲!");
return;
}
HashMap<String, Object> hashMap3 = currentDataMap;
if (hashMap3 != null) {
hashMap3.put(CommonNetImpl.AID, Integer.valueOf(bean.getNextArticleID()));
}
HashMap<String, Object> hashMap4 = currentDataMap;
Intrinsics.checkNotNull(hashMap4);
getNetData(hashMap4);
}
public final void checkMediaData(HashMap<String, Object> currentDataMap2, int index) {
Intrinsics.checkNotNullParameter(currentDataMap2, "currentDataMap");
if (currentDataMap2.get("list") == null) {
return;
}
Object obj = currentDataMap2.get("list");
Objects.requireNonNull(obj, "null cannot be cast to non-null type java.util.ArrayList<com.mnr.app.wedia.bean.MediaNewsListBean.ListBean>{ kotlin.collections.TypeAliasesKt.ArrayList<com.mnr.app.wedia.bean.MediaNewsListBean.ListBean> }");
ArrayList arrayList = (ArrayList) obj;
if (index == 0) {
Object obj2 = currentDataMap2.get("index");
Objects.requireNonNull(obj2, "null cannot be cast to non-null type kotlin.Int");
index = ((Integer) obj2).intValue();
}
if (index < arrayList.size() - 1) {
int i = index + 1;
Object obj3 = arrayList.get(i);
Intrinsics.checkNotNullExpressionValue(obj3, "list[temp + 1]");
MediaNewsListBean.ListBean listBean = (MediaNewsListBean.ListBean) obj3;
if (listBean.getChild() == null) {
HashMap<String, Object> hashMap = currentDataMap;
if (hashMap != null) {
hashMap.put("index", Integer.valueOf(i));
}
HashMap<String, Object> hashMap2 = currentDataMap;
if (hashMap2 != null) {
hashMap2.put(CommonNetImpl.AID, Integer.valueOf(listBean.getArticleID()));
}
HashMap<String, Object> hashMap3 = currentDataMap;
Intrinsics.checkNotNull(hashMap3);
getNetData(hashMap3);
return;
}
checkMediaData(currentDataMap2, i);
return;
}
ToastUtils.showShort("暂无下一曲!");
}
@Override
public void close() {
mOpen = false;
for (Activity activity : AcManager.INSTANCE.getActivities()) {
FrameLayout frameLayout = (FrameLayout) activity.getWindow().getDecorView().findViewById(R.id.content);
if (frameLayout.getChildAt(1) instanceof VoiceView) {
frameLayout.removeViewAt(1);
list.remove(activity.getClass().getSimpleName());
}
}
TTSUtils companion = TTSUtils.INSTANCE.getInstance();
if (companion != null) {
companion.stop();
}
resetTemp();
}
public final void resetTemp() {
isAdd = false;
currentVoiceBean = null;
HashMap<String, Object> hashMap = currentDataMap;
if (hashMap != null) {
hashMap.clear();
}
}
public final void addVoiceView(final Activity activity) {
Intrinsics.checkNotNullParameter(activity, "activity");
Loger.e("123", "----------------------------addView");
activity.getWindow().getDecorView().post(new Runnable() {
@Override
public final void run() {
VoiceBroadcastUtils.m103addVoiceView$lambda6(activity);
}
});
}
public static final void m103addVoiceView$lambda6(Activity activity) {
Intrinsics.checkNotNullParameter(activity, "$activity");
FrameLayout frameLayout = (FrameLayout) activity.getWindow().getDecorView().findViewById(R.id.content);
VoiceBroadcastUtils voiceBroadcastUtils = INSTANCE;
voiceView = new VoiceView(activity);
if (!list.contains(activity.getClass().getSimpleName())) {
list.add(activity.getClass().getSimpleName());
VoiceView voiceView2 = voiceView;
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(-2, -2);
layoutParams.gravity = 83;
layoutParams.bottomMargin = (int) (DisplayUtil.getScreenHeight(activity) * 0.1d);
Unit unit = Unit.INSTANCE;
frameLayout.addView(voiceView2, layoutParams);
isAdd = true;
}
VoiceBean voiceBean = currentVoiceBean;
if (voiceBean != null) {
voiceBroadcastUtils.updateView(voiceBean);
Loger.e("123", "-----addView--------updateView----------");
}
}
}