i自然 v1.5.2版本的 MD5 值为:4186de3133535afd3ad8a76e7e4d0eff
以下内容为反编译后的 LiveNet.java 源代码,内容仅作参考
package com.qukan.demo.ui.net;
import android.text.TextUtils;
import android.util.Log;
import android.widget.Toast;
import com.google.gson.Gson;
import com.mnr.dependencies.Utils.Loger;
import com.mnr.dependencies.Utils.ToastUtils;
import com.mnr.dependencies.bean.PushMsgBean;
import com.qukan.demo.ui.activity.LiveActivity;
import com.qukan.demo.ui.net.LiveNet;
import java.io.IOException;
import java.util.Objects;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import org.json.JSONException;
import org.json.JSONObject;
public class LiveNet {
public void beginLiveNet(int liveID, String code, LiveActivity context) {
String str = "https://api.iziran.net/live/beginLive?id=" + liveID + "&code=" + code;
Log.e("123", "推流-------beginLiveNet=====url======" + str);
new OkHttpClient().newCall(new Request.Builder().url(str).build()).enqueue(new AnonymousClass1(context));
}
public class AnonymousClass1 implements Callback {
final LiveActivity val$context;
AnonymousClass1(final LiveActivity val$context) {
this.val$context = val$context;
}
@Override
public void onFailure(Call call, IOException e) {
LiveActivity liveActivity = this.val$context;
if (liveActivity == null || liveActivity.isDestroyed()) {
return;
}
final LiveActivity liveActivity2 = this.val$context;
liveActivity2.runOnUiThread(new Runnable() {
@Override
public final void run() {
Toast.makeText(LiveActivity.this, "无法获取到推流地址的状态,请稍后重试!!", 0).show();
}
});
}
@Override
public void onResponse(Call call, Response response) throws IOException {
if (response.body() == null) {
onFailure(call, new IOException("推流-------加载失败"));
return;
}
String string = response.body().string();
Log.e("123", "推流-------beginLiveNet==请求到的数据========" + string);
try {
try {
if (new JSONObject(string).getBoolean("success")) {
final LiveActivity liveActivity = this.val$context;
liveActivity.runOnUiThread(new Runnable() {
@Override
public final void run() {
LiveActivity.this.startLive();
}
});
} else {
onFailure(call, new IOException("推流-------开始直播异常,请稍后重试.."));
}
} catch (JSONException e) {
e.printStackTrace();
Log.e("123", "解析错误=========");
}
} finally {
Log.e("123", "返回=============");
}
}
}
public void stopLiveNet(int liveID, String code, LiveActivity context) {
String str = "https://api.iziran.net/live/stopLive?id=" + liveID + "&code=" + code;
Log.e("123", "stopLiveNet=====url======" + str);
new OkHttpClient().newCall(new Request.Builder().url(str).build()).enqueue(new AnonymousClass2(context));
}
class AnonymousClass2 implements Callback {
final LiveActivity val$context;
AnonymousClass2(final LiveActivity val$context) {
this.val$context = val$context;
}
@Override
public void onFailure(Call call, final IOException e) {
final LiveActivity liveActivity = this.val$context;
liveActivity.runOnUiThread(new Runnable() {
@Override
public final void run() {
LiveNet.AnonymousClass2.lambda$onFailure$0(e, liveActivity);
}
});
}
public static void lambda$onFailure$0(IOException iOException, LiveActivity liveActivity) {
String message = iOException.getMessage();
if (TextUtils.isEmpty(message)) {
Toast.makeText(liveActivity, "请求失败,请稍后重试!!", 0).show();
} else {
Toast.makeText(liveActivity, message, 0).show();
liveActivity.stopRtmp();
}
}
@Override
public void onResponse(Call call, Response response) throws IOException {
if (response.body() == null) {
onFailure(call, new IOException("加载失败"));
return;
}
String string = response.body().string();
Log.e("123", "stopLiveNet==请求到的数据========" + string);
try {
try {
JSONObject jSONObject = new JSONObject(string);
if (!jSONObject.getBoolean("success")) {
onFailure(call, new IOException(jSONObject.getString("msg")));
}
final LiveActivity liveActivity = this.val$context;
Objects.requireNonNull(liveActivity);
liveActivity.runOnUiThread(new Runnable() {
@Override
public final void run() {
LiveActivity.this.finish();
}
});
} catch (JSONException e) {
e.printStackTrace();
Log.e("123", "解析错误=========");
}
} finally {
Log.e("123", "返回=============");
}
}
}
public void getPushUrl(final String code, LiveActivity activity) {
String str = "https://api.iziran.net/live/getLiveByCode?code=" + code;
Log.e("123", "getPushUrl=====url======" + str);
new OkHttpClient().newCall(new Request.Builder().url(str).build()).enqueue(new AnonymousClass3(activity, code));
}
public class AnonymousClass3 implements Callback {
final LiveActivity val$activity;
final String val$code;
AnonymousClass3(final LiveActivity val$activity, final String val$code) {
this.val$activity = val$activity;
this.val$code = val$code;
}
@Override
public void onFailure(Call call, IOException e) {
Log.e("123", e.toString());
}
@Override
public void onResponse(Call call, Response response) throws IOException {
if (response.body() == null) {
onFailure(call, new IOException("推流-------加载失败"));
return;
}
String string = response.body().string();
Log.e("123", "推流-------getPushUrl==请求到的数据========" + string);
PushMsgBean pushMsgBean = (PushMsgBean) new Gson().fromJson(string, PushMsgBean.class);
if (pushMsgBean.isSuccess()) {
final int liveStatus = pushMsgBean.getLiveStatus();
final int liveID = pushMsgBean.getLiveID();
final LiveActivity liveActivity = this.val$activity;
final String str = this.val$code;
liveActivity.runOnUiThread(new Runnable() {
@Override
public final void run() {
LiveNet.AnonymousClass3.this.lambda$onResponse$0$LiveNet$3(liveStatus, liveID, str, liveActivity);
}
});
}
}
public void lambda$onResponse$0$LiveNet$3(int i, int i2, String str, LiveActivity liveActivity) {
if (i == 0) {
Log.e("123", "推流:当前直播状态为:直播即将开始");
LiveNet.this.beginLiveNet(i2, str, liveActivity);
return;
}
if (i == 1) {
Loger.e("123", "推流:当前直播状态为:正在直播");
liveActivity.startLive();
} else if (i == 2) {
Loger.e("123", "推流:当前直播状态为:直播结束");
ToastUtils.showShort(liveActivity, "该直播间已经结束,直接退出即可");
} else if (i == 3) {
Loger.e("123", "推流:当前直播状态为:暂停直播");
}
}
}
}