CheetahGram v8.5.4版本的 MD5 值为:3d14e79cc242c314d3933620ff3ab030
以下内容为反编译后的 m9.java 源代码,内容仅作参考
package org.telegram.ui.Components;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.SurfaceTexture;
import android.media.AudioManager;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.text.Layout;
import android.text.StaticLayout;
import android.text.TextPaint;
import android.text.TextUtils;
import android.util.Base64;
import android.util.Property;
import android.view.MotionEvent;
import android.view.TextureView;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.webkit.JavascriptInterface;
import android.webkit.ValueCallback;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.FrameLayout;
import android.widget.ImageView;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.SocketException;
import java.net.SocketTimeoutException;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.net.UnknownHostException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.zip.GZIPInputStream;
import org.json.JSONArray;
import org.json.JSONObject;
import org.json.JSONTokener;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.Bitmaps;
import org.telegram.messenger.BuildVars;
import org.telegram.messenger.FileLoader;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.ImageLocation;
import org.telegram.messenger.ImageReceiver;
import org.telegram.messenger.R;
import org.telegram.messenger.Utilities;
import org.telegram.messenger.p110.a8;
import org.telegram.messenger.p110.g52;
import org.telegram.messenger.p110.pc5;
import org.telegram.messenger.p110.qc5;
import org.telegram.messenger.p110.tb;
import org.telegram.messenger.p110.wo7;
import org.telegram.ui.Components.e9;
import org.telegram.ui.Components.m9;
import org.webrtc.MediaStreamTrack;
import uk.co.chrisjenx.calligraphy.BuildConfig;
public class m9 extends ViewGroup implements e9.d, AudioManager.OnAudioFocusChangeListener {
private static int f0 = 4001;
private static final Pattern g0 = Pattern.compile("(?:youtube(?:-nocookie)?\\.com/(?:[^/\\n\\s]+/\\S+/|(?:v|e(?:mbed)?)/|\\S*?[?&]v=)|youtu\\.be/)([a-zA-Z0-9_-]{11})");
private static final Pattern h0 = Pattern.compile("https?://(?:(?:www|(player))\\.)?vimeo(pro)?\\.com/(?!(?:channels|album)/[^/?#]+/?(?:$|[?#])|[^/]+/review/|ondemand/)(?:.*?/)?(?:(?:play_redirect_hls|moogaloop\\.swf)\\?clip_id=)?(?:videos?/)?([0-9]+)(?:/[\\da-f]+)?/?(?:[?&].*)?(?:[#].*)?$");
private static final Pattern i0 = Pattern.compile("(?:coub:|https?://(?:coub\\.com/(?:view|embed|coubs)/|c-cdn\\.coub\\.com/fb-player\\.swf\\?.*\\bcoub(?:ID|id)=))([\\da-z]+)");
private static final Pattern j0 = Pattern.compile("^https?://(?:www\\.)?aparat\\.com/(?:v/|video/video/embed/videohash/)([a-zA-Z0-9]+)");
private static final Pattern k0 = Pattern.compile("https?://clips\\.twitch\\.tv/(?:[^/]+/)*([^/?#&]+)");
private static final Pattern l0 = Pattern.compile("https?://(?:(?:www\\.)?twitch\\.tv/|player\\.twitch\\.tv/\\?.*?\\bchannel=)([^/#?]+)");
private static final Pattern m0 = Pattern.compile("fileList\\s*=\\s*JSON\\.parse\\('([^']+)'\\)");
private static final Pattern n0 = Pattern.compile("clipInfo\\s*=\\s*(\\{[^']+\\});");
private static final Pattern o0 = Pattern.compile("\"sts\"\\s*:\\s*(\\d+)");
private static final Pattern p0 = Pattern.compile("\"assets\":.+?\"js\":\\s*(\"[^\"]+\")");
private static final Pattern q0 = Pattern.compile("\\.sig\\|\\|([a-zA-Z0-9$]+)\\(");
private static final Pattern r0 = Pattern.compile("[\"']signature[\"']\\s*,\\s*([a-zA-Z0-9$]+)\\(");
private static final Pattern s0 = Pattern.compile("var\\s");
private static final Pattern t0 = Pattern.compile("return(?:\\s+|$)");
private static final Pattern u0 = Pattern.compile("[()]");
private static final Pattern v0 = Pattern.compile(".*?-([a-zA-Z0-9_-]+)(?:/watch_as3|/html5player(?:-new)?|(?:/[a-z]{2}_[A-Z]{2})?/base)?\\.([a-z]+)$");
private boolean A;
private Paint B;
private AsyncTask G;
private boolean H;
private boolean I;
private boolean J;
private boolean Q;
private boolean R;
private RadialProgressView S;
private ImageView T;
private ImageView U;
private ImageView V;
private ImageView W;
private e9 a;
private AnimatorSet a0;
private WebView b;
private h b0;
private String c;
private Runnable c0;
private tb d;
private TextureView.SurfaceTextureListener d0;
private TextureView e;
private Runnable e0;
private ImageView f;
private ViewGroup g;
private Bitmap h;
private TextureView i;
private int j;
private boolean k;
private o l;
private boolean m;
private String n;
private String o;
private String p;
private String q;
private String r;
private boolean s;
private boolean t;
private boolean u;
private boolean v;
private long w;
private boolean x;
private float y;
private int z;
class a implements Runnable {
a() {
}
@Override
public void run() {
if (m9.this.a == null || !m9.this.a.s0()) {
return;
}
m9.this.b0.i((int) (m9.this.a.i0() / 1000));
m9.this.b0.g((int) (m9.this.a.h0() / 1000));
AndroidUtilities.runOnUIThread(m9.this.c0, 1000L);
}
}
public class b implements TextureView.SurfaceTextureListener {
public class a implements ViewTreeObserver.OnPreDrawListener {
a() {
}
public void b() {
m9.this.l.b();
}
@Override
public boolean onPreDraw() {
m9.this.i.getViewTreeObserver().removeOnPreDrawListener(this);
if (m9.this.f != null) {
m9.this.f.setVisibility(4);
m9.this.f.setImageDrawable(null);
if (m9.this.h != null) {
m9.this.h.recycle();
m9.this.h = null;
}
}
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
m9.b.a.this.b();
}
});
m9.this.j = 0;
return true;
}
}
b() {
}
@Override
public void onSurfaceTextureAvailable(SurfaceTexture surfaceTexture, int i, int i2) {
}
@Override
public boolean onSurfaceTextureDestroyed(SurfaceTexture surfaceTexture) {
if (!m9.this.H) {
return true;
}
if (m9.this.R) {
m9.this.j = 2;
}
m9.this.e.setSurfaceTexture(surfaceTexture);
m9.this.e.setVisibility(0);
m9.this.H = false;
return false;
}
@Override
public void onSurfaceTextureSizeChanged(SurfaceTexture surfaceTexture, int i, int i2) {
}
@Override
public void onSurfaceTextureUpdated(SurfaceTexture surfaceTexture) {
if (m9.this.j == 1) {
m9.this.i.getViewTreeObserver().addOnPreDrawListener(new a());
m9.this.i.invalidate();
}
}
}
class c implements Runnable {
c() {
}
@Override
public void run() {
m9.this.R = false;
if (m9.this.h != null) {
m9.this.h.recycle();
m9.this.h = null;
}
m9.this.H = true;
if (m9.this.f != null) {
try {
m9 m9Var = m9.this;
m9Var.h = Bitmaps.createBitmap(m9Var.e.getWidth(), m9.this.e.getHeight(), Bitmap.Config.ARGB_8888);
m9.this.e.getBitmap(m9.this.h);
} catch (Throwable th) {
if (m9.this.h != null) {
m9.this.h.recycle();
m9.this.h = null;
}
FileLog.e(th);
}
if (m9.this.h != null) {
m9.this.f.setVisibility(0);
m9.this.f.setImageBitmap(m9.this.h);
} else {
m9.this.f.setImageDrawable(null);
}
}
m9.this.J = true;
m9.this.N0();
m9.this.O0();
m9.this.K0();
m9.this.M0();
ViewGroup viewGroup = (ViewGroup) m9.this.b0.getParent();
if (viewGroup != null) {
viewGroup.removeView(m9.this.b0);
}
m9 m9Var2 = m9.this;
m9Var2.i = m9Var2.l.g(m9.this.b0, m9.this.J, m9.this.d.getAspectRatio(), m9.this.d.getVideoRotation(), m9.this.t);
m9.this.i.setVisibility(4);
ViewGroup viewGroup2 = (ViewGroup) m9.this.e.getParent();
if (viewGroup2 != null) {
viewGroup2.removeView(m9.this.e);
}
m9.this.b0.j(false, false);
}
}
class d extends tb {
d(Context context) {
super(context);
}
@Override
public void onMeasure(int i, int i2) {
super.onMeasure(i, i2);
if (m9.this.g != null) {
ViewGroup.LayoutParams layoutParams = m9.this.e.getLayoutParams();
layoutParams.width = getMeasuredWidth();
layoutParams.height = getMeasuredHeight();
if (m9.this.f != null) {
ViewGroup.LayoutParams layoutParams2 = m9.this.f.getLayoutParams();
layoutParams2.width = getMeasuredWidth();
layoutParams2.height = getMeasuredHeight();
}
}
}
}
public class e extends AnimatorListenerAdapter {
e() {
}
@Override
public void onAnimationEnd(Animator animator) {
m9.this.a0 = null;
}
}
public class f extends AsyncTask<Void, Void, String> {
private String a;
private String[] b = new String[2];
public f(String str) {
this.a = str;
}
@Override
public String doInBackground(Void... voidArr) {
String q0 = m9.this.q0(this, String.format(Locale.US, "http://www.aparat.com/video/video/embed/vt/frame/showvideo/yes/videohash/%s", this.a));
if (isCancelled()) {
return null;
}
try {
Matcher matcher = m9.m0.matcher(q0);
if (matcher.find()) {
JSONArray jSONArray = new JSONArray(matcher.group(1));
for (int i = 0; i < jSONArray.length(); i++) {
JSONArray jSONArray2 = jSONArray.getJSONArray(i);
if (jSONArray2.length() != 0) {
JSONObject jSONObject = jSONArray2.getJSONObject(0);
if (jSONObject.has("file")) {
this.b[0] = jSONObject.getString("file");
this.b[1] = "other";
}
}
}
}
} catch (Exception e) {
FileLog.e(e);
}
if (isCancelled()) {
return null;
}
return this.b[0];
}
@Override
public void onPostExecute(String str) {
if (str == null) {
if (isCancelled()) {
return;
}
m9.this.G0();
return;
}
m9.this.m = true;
m9.this.n = str;
m9.this.o = this.b[1];
if (m9.this.k) {
m9.this.I0();
}
m9.this.J0(false, true);
m9.this.b0.j(true, true);
}
}
public interface g {
void a(String str);
}
public class h extends FrameLayout {
private ImageReceiver a;
private boolean b;
private TextPaint c;
private StaticLayout d;
private StaticLayout e;
private Paint f;
private Paint g;
private Paint h;
private int i;
private int j;
private int k;
private int l;
private boolean m;
private AnimatorSet n;
private int o;
private int p;
private Runnable q;
public class a extends AnimatorListenerAdapter {
a() {
}
@Override
public void onAnimationEnd(Animator animator) {
h.this.n = null;
}
}
public class b extends AnimatorListenerAdapter {
b() {
}
@Override
public void onAnimationEnd(Animator animator) {
h.this.n = null;
}
}
public h(Context context) {
super(context);
this.m = true;
this.q = new Runnable() {
@Override
public final void run() {
m9.h.this.f();
}
};
setWillNotDraw(false);
TextPaint textPaint = new TextPaint(1);
this.c = textPaint;
textPaint.setColor(-1);
this.c.setTextSize(AndroidUtilities.dp(12.0f));
Paint paint = new Paint(1);
this.f = paint;
paint.setColor(-15095832);
Paint paint2 = new Paint();
this.g = paint2;
paint2.setColor(-6975081);
Paint paint3 = new Paint(1);
this.h = paint3;
paint3.setColor(-1);
this.a = new ImageReceiver(this);
}
public void e() {
AndroidUtilities.cancelRunOnUIThread(this.q);
if (this.m && m9.this.a.s0()) {
AndroidUtilities.runOnUIThread(this.q, 3000L);
}
}
public void f() {
j(false, true);
}
public void g(int i) {
this.l = i;
invalidate();
}
public void h(int i) {
if (this.j == i || i < 0 || m9.this.s) {
return;
}
this.j = i;
StaticLayout staticLayout = new StaticLayout(AndroidUtilities.formatShortDuration(this.j), this.c, AndroidUtilities.dp(1000.0f), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
this.d = staticLayout;
if (staticLayout.getLineCount() > 0) {
this.i = (int) Math.ceil(this.d.getLineWidth(0));
}
invalidate();
}
public void i(int i) {
if (this.b || i < 0 || m9.this.s) {
return;
}
this.k = i;
this.e = new StaticLayout(AndroidUtilities.formatShortDuration(this.k), this.c, AndroidUtilities.dp(1000.0f), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
invalidate();
}
public void j(boolean z, boolean z2) {
float f;
AnimatorSet animatorSet;
Animator.AnimatorListener bVar;
if (this.m == z) {
return;
}
this.m = z;
AnimatorSet animatorSet2 = this.n;
if (animatorSet2 != null) {
animatorSet2.cancel();
}
if (this.m) {
f = 1.0f;
if (z2) {
AnimatorSet animatorSet3 = new AnimatorSet();
this.n = animatorSet3;
animatorSet3.playTogether(ObjectAnimator.ofFloat(this, (Property<h, Float>) View.ALPHA, 1.0f));
this.n.setDuration(150L);
animatorSet = this.n;
bVar = new a();
animatorSet.addListener(bVar);
this.n.start();
}
setAlpha(f);
} else {
f = 0.0f;
if (z2) {
AnimatorSet animatorSet4 = new AnimatorSet();
this.n = animatorSet4;
animatorSet4.playTogether(ObjectAnimator.ofFloat(this, (Property<h, Float>) View.ALPHA, 0.0f));
this.n.setDuration(150L);
animatorSet = this.n;
bVar = new b();
animatorSet.addListener(bVar);
this.n.start();
}
setAlpha(f);
}
e();
}
@Override
protected void onDraw(Canvas canvas) {
int dp;
int dp2;
int dp3;
int dp4;
int i;
int i2;
int i3;
int i4;
if (m9.this.A) {
if (m9.this.x && m9.this.y != 0.0f) {
long currentTimeMillis = System.currentTimeMillis();
long j = currentTimeMillis - m9.this.w;
m9.this.w = currentTimeMillis;
m9.d0(m9.this, ((float) j) / 150.0f);
if (m9.this.y < 0.0f) {
m9.this.y = 0.0f;
}
invalidate();
}
this.a.setAlpha(m9.this.y);
this.a.draw(canvas);
}
if (!m9.this.a.r0() || m9.this.s) {
return;
}
int measuredWidth = getMeasuredWidth();
int measuredHeight = getMeasuredHeight();
if (!m9.this.J) {
if (this.d != null) {
canvas.save();
canvas.translate((measuredWidth - AndroidUtilities.dp(58.0f)) - this.i, measuredHeight - AndroidUtilities.dp((m9.this.I ? 6 : 10) + 29));
this.d.draw(canvas);
canvas.restore();
}
if (this.e != null) {
canvas.save();
canvas.translate(AndroidUtilities.dp(18.0f), measuredHeight - AndroidUtilities.dp((m9.this.I ? 6 : 10) + 29));
this.e.draw(canvas);
canvas.restore();
}
}
if (this.j == 0) {
return;
}
if (m9.this.J) {
dp = measuredHeight - AndroidUtilities.dp(3.0f);
dp2 = AndroidUtilities.dp(7.0f);
} else {
if (m9.this.I) {
int dp5 = measuredHeight - AndroidUtilities.dp(29.0f);
int dp6 = AndroidUtilities.dp(36.0f) + this.i;
dp3 = (measuredWidth - AndroidUtilities.dp(76.0f)) - this.i;
dp4 = measuredHeight - AndroidUtilities.dp(28.0f);
i = dp5;
i2 = dp6;
if (m9.this.I) {
canvas.drawRect(i2, i, dp3, AndroidUtilities.dp(3.0f) + i, this.g);
}
int i5 = !this.b ? this.p : ((int) ((dp3 - i2) * (this.k / this.j))) + i2;
i3 = this.l;
if (i3 != 0 && (i4 = this.j) != 0) {
float f = i2;
canvas.drawRect(f, i, ((dp3 - i2) * (i3 / i4)) + f, AndroidUtilities.dp(3.0f) + i, !m9.this.I ? this.h : this.g);
}
float f2 = i5;
canvas.drawRect(i2, i, f2, i + AndroidUtilities.dp(3.0f), this.f);
if (m9.this.J) {
canvas.drawCircle(f2, dp4, AndroidUtilities.dp(this.b ? 7.0f : 5.0f), this.f);
return;
}
return;
}
dp = measuredHeight - AndroidUtilities.dp(13.0f);
dp2 = AndroidUtilities.dp(12.0f);
}
dp3 = measuredWidth;
dp4 = measuredHeight - dp2;
i = dp;
i2 = 0;
if (m9.this.I) {
}
int i52 = !this.b ? this.p : ((int) ((dp3 - i2) * (this.k / this.j))) + i2;
i3 = this.l;
if (i3 != 0) {
float f3 = i2;
canvas.drawRect(f3, i, ((dp3 - i2) * (i3 / i4)) + f3, AndroidUtilities.dp(3.0f) + i, !m9.this.I ? this.h : this.g);
}
float f22 = i52;
canvas.drawRect(i2, i, f22, i + AndroidUtilities.dp(3.0f), this.f);
if (m9.this.J) {
}
}
@Override
public boolean onInterceptTouchEvent(MotionEvent motionEvent) {
if (motionEvent.getAction() != 0) {
return super.onInterceptTouchEvent(motionEvent);
}
if (this.m) {
onTouchEvent(motionEvent);
return this.b;
}
j(true, true);
return true;
}
@Override
public boolean onTouchEvent(MotionEvent motionEvent) {
int measuredWidth;
int measuredHeight;
int i;
if (m9.this.I) {
i = AndroidUtilities.dp(36.0f) + this.i;
measuredWidth = (getMeasuredWidth() - AndroidUtilities.dp(76.0f)) - this.i;
measuredHeight = getMeasuredHeight() - AndroidUtilities.dp(28.0f);
} else {
measuredWidth = getMeasuredWidth();
measuredHeight = getMeasuredHeight() - AndroidUtilities.dp(12.0f);
i = 0;
}
int i2 = this.j;
int i3 = (i2 != 0 ? (int) ((measuredWidth - i) * (this.k / i2)) : 0) + i;
if (motionEvent.getAction() == 0) {
if (!this.m || m9.this.J || m9.this.s) {
j(true, true);
} else if (this.j != 0) {
int x = (int) motionEvent.getX();
int y = (int) motionEvent.getY();
if (x >= i3 - AndroidUtilities.dp(10.0f) && x <= AndroidUtilities.dp(10.0f) + i3 && y >= measuredHeight - AndroidUtilities.dp(10.0f) && y <= measuredHeight + AndroidUtilities.dp(10.0f)) {
this.b = true;
this.o = x;
this.p = i3;
getParent().requestDisallowInterceptTouchEvent(true);
invalidate();
}
}
AndroidUtilities.cancelRunOnUIThread(this.q);
} else if (motionEvent.getAction() == 1 || motionEvent.getAction() == 3) {
if (m9.this.m && m9.this.a.s0()) {
AndroidUtilities.runOnUIThread(this.q, 3000L);
}
if (this.b) {
this.b = false;
if (m9.this.m) {
this.k = (int) (this.j * ((this.p - i) / (measuredWidth - i)));
m9.this.a.z0(this.k * 1000);
}
}
} else if (motionEvent.getAction() == 2 && this.b) {
int x2 = (int) motionEvent.getX();
int i4 = this.p - (this.o - x2);
this.p = i4;
this.o = x2;
if (i4 < i) {
this.p = i;
} else if (i4 > measuredWidth) {
this.p = measuredWidth;
}
i((int) (this.j * 1000 * ((this.p - i) / (measuredWidth - i))));
invalidate();
}
super.onTouchEvent(motionEvent);
return true;
}
@Override
public void requestDisallowInterceptTouchEvent(boolean z) {
super.requestDisallowInterceptTouchEvent(z);
e();
}
}
public class i extends AsyncTask<Void, Void, String> {
private String a;
private String[] b = new String[4];
public i(String str) {
this.a = str;
}
@Override
public String doInBackground(Void... voidArr) {
String q0 = m9.this.q0(this, String.format(Locale.US, "https://coub.com/api/v2/coubs/%s.json", this.a));
if (isCancelled()) {
return null;
}
try {
JSONObject jSONObject = new JSONObject(q0).getJSONObject("file_versions").getJSONObject("mobile");
String string = jSONObject.getString(MediaStreamTrack.VIDEO_TRACK_KIND);
String string2 = jSONObject.getJSONArray(MediaStreamTrack.AUDIO_TRACK_KIND).getString(0);
if (string != null && string2 != null) {
String[] strArr = this.b;
strArr[0] = string;
strArr[1] = "other";
strArr[2] = string2;
strArr[3] = "other";
}
} catch (Exception e) {
FileLog.e(e);
}
if (isCancelled()) {
return null;
}
return this.b[0];
}
@Override
public void onPostExecute(String str) {
if (str == null) {
if (isCancelled()) {
return;
}
m9.this.G0();
return;
}
m9.this.m = true;
m9.this.n = str;
m9.this.o = this.b[1];
m9.this.p = this.b[2];
m9.this.q = this.b[3];
if (m9.this.k) {
m9.this.I0();
}
m9.this.J0(false, true);
m9.this.b0.j(true, true);
}
}
public static class j {
private String b;
ArrayList<String> a = new ArrayList<>();
private String[] c = {"|", "^", "&", ">>", "<<", "-", "+", "%", "/", "*"};
private String[] d = {"|=", "^=", "&=", ">>=", "<<=", "-=", "+=", "%=", "/=", "*=", "="};
public j(String str) {
this.b = str;
}
private void b(String[] strArr, String str) {
HashMap<String, String> hashMap = new HashMap<>();
for (String str2 : strArr) {
hashMap.put(str2, BuildConfig.FLAVOR);
}
String[] split = str.split(";");
boolean[] zArr = new boolean[1];
for (String str3 : split) {
f(str3, hashMap, zArr, 100);
if (zArr[0]) {
return;
}
}
}
public String c(String str) {
try {
String quote = Pattern.quote(str);
Matcher matcher = Pattern.compile(String.format(Locale.US, "(?x)(?:function\\s+%s|[{;,]\\s*%s\\s*=\\s*function|var\\s+%s\\s*=\\s*function)\\s*\\(([^)]*)\\)\\s*\\{([^}]+)\\}", quote, quote, quote)).matcher(this.b);
if (matcher.find()) {
String group = matcher.group();
if (!this.a.contains(group)) {
this.a.add(group + ";");
}
b(matcher.group(1).split(","), matcher.group(2));
}
} catch (Exception e) {
this.a.clear();
FileLog.e(e);
}
return TextUtils.join(BuildConfig.FLAVOR, this.a);
}
private HashMap<String, Object> d(String str) {
HashMap<String, Object> hashMap = new HashMap<>();
Matcher matcher = Pattern.compile(String.format(Locale.US, "(?:var\\s+)?%s\\s*=\\s*\\{\\s*((%s\\s*:\\s*function\\(.*?\\)\\s*\\{.*?\\}(?:,\\s*)?)*)\\}\\s*;", Pattern.quote(str), "(?:[a-zA-Z$0-9]+|\"[a-zA-Z$0-9]+\"|'[a-zA-Z$0-9]+')")).matcher(this.b);
String str2 = null;
while (true) {
if (!matcher.find()) {
break;
}
String group = matcher.group();
String group2 = matcher.group(2);
if (TextUtils.isEmpty(group2)) {
str2 = group2;
} else {
if (!this.a.contains(group)) {
this.a.add(matcher.group());
}
str2 = group2;
}
}
Matcher matcher2 = Pattern.compile(String.format("(%s)\\s*:\\s*function\\(([a-z,]+)\\)\\{([^}]+)\\}", "(?:[a-zA-Z$0-9]+|\"[a-zA-Z$0-9]+\"|'[a-zA-Z$0-9]+')")).matcher(str2);
while (matcher2.find()) {
b(matcher2.group(2).split(","), matcher2.group(3));
}
return hashMap;
}
private void e(String str, HashMap<String, String> hashMap, int i) {
String group;
String trim = str.trim();
if (TextUtils.isEmpty(trim)) {
return;
}
if (trim.charAt(0) == '(') {
Matcher matcher = m9.u0.matcher(trim);
int i2 = 0;
while (true) {
if (!matcher.find()) {
break;
}
if (matcher.group(0).indexOf(48) == 40) {
i2++;
} else {
i2--;
if (i2 == 0) {
e(trim.substring(1, matcher.start()), hashMap, i);
trim = trim.substring(matcher.end()).trim();
if (TextUtils.isEmpty(trim)) {
return;
}
}
}
}
if (i2 != 0) {
throw new Exception(String.format("Premature end of parens in %s", trim));
}
}
int i3 = 0;
while (true) {
String[] strArr = this.d;
if (i3 >= strArr.length) {
try {
Integer.parseInt(trim);
return;
} catch (Exception unused) {
if (Pattern.compile(String.format(Locale.US, "(?!if|return|true|false)(%s)$", "[a-zA-Z_$][a-zA-Z_$0-9]*")).matcher(trim).find()) {
return;
}
if (trim.charAt(0) == '\"' && trim.charAt(trim.length() - 1) == '\"') {
return;
}
try {
new JSONObject(trim).toString();
return;
} catch (Exception unused2) {
Locale locale = Locale.US;
Matcher matcher2 = Pattern.compile(String.format(locale, "(%s)\\[(.+)\\]$", "[a-zA-Z_$][a-zA-Z_$0-9]*")).matcher(trim);
if (matcher2.find()) {
matcher2.group(1);
group = matcher2.group(2);
} else {
Matcher matcher3 = Pattern.compile(String.format(locale, "(%s)(?:\\.([^(]+)|\\[([^]]+)\\])\\s*(?:\\(+([^()]*)\\))?$", "[a-zA-Z_$][a-zA-Z_$0-9]*")).matcher(trim);
if (matcher3.find()) {
String group2 = matcher3.group(1);
String group3 = matcher3.group(2);
String group4 = matcher3.group(3);
if (TextUtils.isEmpty(group3)) {
group3 = group4;
}
group3.replace("\"", BuildConfig.FLAVOR);
String group5 = matcher3.group(4);
if (hashMap.get(group2) == null) {
d(group2);
}
if (group5 == null) {
return;
}
if (trim.charAt(trim.length() - 1) != ')') {
throw new Exception("last char not ')'");
}
if (group5.length() != 0) {
for (String str2 : group5.split(",")) {
e(str2, hashMap, i);
}
return;
}
return;
}
Matcher matcher4 = Pattern.compile(String.format(locale, "(%s)\\[(.+)\\]$", "[a-zA-Z_$][a-zA-Z_$0-9]*")).matcher(trim);
if (matcher4.find()) {
hashMap.get(matcher4.group(1));
group = matcher4.group(2);
} else {
int i4 = 0;
while (true) {
String[] strArr2 = this.c;
if (i4 >= strArr2.length) {
Matcher matcher5 = Pattern.compile(String.format(Locale.US, "^(%s)\\(([a-zA-Z0-9_$,]*)\\)$", "[a-zA-Z_$][a-zA-Z_$0-9]*")).matcher(trim);
if (matcher5.find()) {
c(matcher5.group(1));
}
throw new Exception(String.format("Unsupported JS expression %s", trim));
}
String str3 = strArr2[i4];
Matcher matcher6 = Pattern.compile(String.format(Locale.US, "(.+?)%s(.+)", Pattern.quote(str3))).matcher(trim);
if (matcher6.find()) {
boolean[] zArr = new boolean[1];
int i5 = i - 1;
f(matcher6.group(1), hashMap, zArr, i5);
if (zArr[0]) {
throw new Exception(String.format("Premature left-side return of %s in %s", str3, trim));
}
f(matcher6.group(2), hashMap, zArr, i5);
if (zArr[0]) {
throw new Exception(String.format("Premature right-side return of %s in %s", str3, trim));
}
}
i4++;
}
}
}
e(group, hashMap, i - 1);
return;
}
}
}
Matcher matcher7 = Pattern.compile(String.format(Locale.US, "(?x)(%s)(?:\\[([^\\]]+?)\\])?\\s*%s(.*)$", "[a-zA-Z_$][a-zA-Z_$0-9]*", Pattern.quote(strArr[i3]))).matcher(trim);
if (matcher7.find()) {
e(matcher7.group(3), hashMap, i - 1);
String group6 = matcher7.group(2);
if (TextUtils.isEmpty(group6)) {
hashMap.put(matcher7.group(1), BuildConfig.FLAVOR);
return;
} else {
e(group6, hashMap, i);
return;
}
}
i3++;
}
}
private void f(String str, HashMap<String, String> hashMap, boolean[] zArr, int i) {
if (i < 0) {
throw new Exception("recursion limit reached");
}
zArr[0] = false;
String trim = str.trim();
Matcher matcher = m9.s0.matcher(trim);
if (matcher.find()) {
trim = trim.substring(matcher.group(0).length());
} else {
Matcher matcher2 = m9.t0.matcher(trim);
if (matcher2.find()) {
trim = trim.substring(matcher2.group(0).length());
zArr[0] = true;
}
}
e(trim, hashMap, i);
}
}
public static class k {
private final g a;
public k(g gVar) {
this.a = gVar;
}
@JavascriptInterface
public void returnResultToJava(String str) {
this.a.a(str);
}
}
public class l extends AsyncTask<Void, Void, String> {
private String a;
private String[] b = new String[2];
public l(String str, String str2) {
this.a = str;
}
@Override
public String doInBackground(Void... voidArr) {
String r0 = m9.this.r0(this, this.a, null, false);
if (isCancelled()) {
return null;
}
try {
Matcher matcher = m9.n0.matcher(r0);
if (matcher.find()) {
this.b[0] = new JSONObject(matcher.group(1)).getJSONArray("quality_options").getJSONObject(0).getString("source");
this.b[1] = "other";
}
} catch (Exception e) {
FileLog.e(e);
}
if (isCancelled()) {
return null;
}
return this.b[0];
}
@Override
public void onPostExecute(String str) {
if (str == null) {
if (isCancelled()) {
return;
}
m9.this.G0();
return;
}
m9.this.m = true;
m9.this.n = str;
m9.this.o = this.b[1];
if (m9.this.k) {
m9.this.I0();
}
m9.this.J0(false, true);
m9.this.b0.j(true, true);
}
}
public class m extends AsyncTask<Void, Void, String> {
private String a;
private String[] b = new String[2];
public m(String str, String str2) {
this.a = str2;
}
@Override
public String doInBackground(Void... voidArr) {
HashMap<String, String> hashMap = new HashMap<>();
hashMap.put("Client-ID", "jzkbprff40iqj646a697cyrvl0zt2m6");
int indexOf = this.a.indexOf(38);
if (indexOf > 0) {
this.a = this.a.substring(0, indexOf);
}
m9 m9Var = m9.this;
Locale locale = Locale.US;
String r0 = m9Var.r0(this, String.format(locale, "https://api.twitch.tv/kraken/streams/%s?stream_type=all", this.a), hashMap, false);
if (isCancelled()) {
return null;
}
try {
new JSONObject(r0).getJSONObject("stream");
JSONObject jSONObject = new JSONObject(m9.this.r0(this, String.format(locale, "https://api.twitch.tv/api/channels/%s/access_token", this.a), hashMap, false));
String encode = URLEncoder.encode(jSONObject.getString("sig"), com.batch.android.core.a.a);
String encode2 = URLEncoder.encode(jSONObject.getString("token"), com.batch.android.core.a.a);
URLEncoder.encode("https://youtube.googleapis.com/v/" + this.a, com.batch.android.core.a.a);
String format = String.format(locale, "https://usher.ttvnw.net/api/channel/hls/%s.m3u8?%s", this.a, "allow_source=true&allow_audio_only=true&allow_spectre=true&player=twitchweb&segment_preference=4&p=" + ((int) (Math.random() * 1.0E7d)) + "&sig=" + encode + "&token=" + encode2);
String[] strArr = this.b;
strArr[0] = format;
strArr[1] = "hls";
} catch (Exception e) {
FileLog.e(e);
}
if (isCancelled()) {
return null;
}
return this.b[0];
}
@Override
public void onPostExecute(String str) {
if (str == null) {
if (isCancelled()) {
return;
}
m9.this.G0();
return;
}
m9.this.m = true;
m9.this.n = str;
m9.this.o = this.b[1];
if (m9.this.k) {
m9.this.I0();
}
m9.this.J0(false, true);
m9.this.b0.j(true, true);
}
}
public class n extends AsyncTask<Void, Void, String> {
private String a;
private String[] b = new String[2];
public n(String str) {
this.a = str;
}
@Override
public String doInBackground(Void... voidArr) {
String q0 = m9.this.q0(this, String.format(Locale.US, "https://player.vimeo.com/video/%s/config", this.a));
if (isCancelled()) {
return null;
}
try {
JSONObject jSONObject = new JSONObject(q0).getJSONObject("request").getJSONObject("files");
if (jSONObject.has("hls")) {
JSONObject jSONObject2 = jSONObject.getJSONObject("hls");
try {
this.b[0] = jSONObject2.getString("url");
} catch (Exception unused) {
this.b[0] = jSONObject2.getJSONObject("cdns").getJSONObject(jSONObject2.getString("default_cdn")).getString("url");
}
this.b[1] = "hls";
} else if (jSONObject.has("progressive")) {
this.b[1] = "other";
this.b[0] = jSONObject.getJSONArray("progressive").getJSONObject(0).getString("url");
}
} catch (Exception e) {
FileLog.e(e);
}
if (isCancelled()) {
return null;
}
return this.b[0];
}
@Override
public void onPostExecute(String str) {
if (str == null) {
if (isCancelled()) {
return;
}
m9.this.G0();
return;
}
m9.this.m = true;
m9.this.n = str;
m9.this.o = this.b[1];
if (m9.this.k) {
m9.this.I0();
}
m9.this.J0(false, true);
m9.this.b0.j(true, true);
}
}
public interface o {
TextureView a(View view, boolean z, float f, int i, boolean z2);
void b();
void c(float f, int i);
void d();
void e(m9 m9Var, boolean z);
void f();
TextureView g(View view, boolean z, float f, int i, boolean z2);
ViewGroup h();
boolean i();
void j(boolean z, Runnable runnable, float f, boolean z2);
}
public class p extends AsyncTask<Void, Void, String[]> {
private String a;
private CountDownLatch b = new CountDownLatch(1);
private String[] c = new String[2];
private String d;
public p(String str) {
this.a = str;
}
public void e(String str) {
String[] strArr = this.c;
strArr[0] = strArr[0].replace(this.d, "/signature/" + str.substring(1, str.length() - 1));
this.b.countDown();
}
public void f(String str) {
if (Build.VERSION.SDK_INT >= 21) {
m9.this.b.evaluateJavascript(str, new ValueCallback() {
@Override
public final void onReceiveValue(Object obj) {
m9.p.this.e((String) obj);
}
});
return;
}
try {
String encodeToString = Base64.encodeToString(("<script>" + str + "</script>").getBytes(StandardCharsets.UTF_8), 0);
m9.this.b.loadUrl("data:text/html;charset=utf-8;base64," + encodeToString);
} catch (Exception e) {
FileLog.e(e);
}
}
public void g(String str) {
String[] strArr = this.c;
strArr[0] = strArr[0].replace(this.d, "/signature/" + str);
this.b.countDown();
}
@Override
public String[] doInBackground(Void... voidArr) {
String[] strArr;
boolean z;
String str;
String str2;
String str3;
String str4;
StringBuilder sb;
String str5;
StringBuilder sb2;
String str6;
int i;
String str7;
String str8;
boolean z2;
boolean z3;
String str9;
String q0 = m9.this.q0(this, "https://www.youtube.com/embed/" + this.a);
String[] strArr2 = null;
if (isCancelled()) {
return null;
}
String str10 = "video_id=" + this.a + "&ps=default&gl=US&hl=en";
try {
StringBuilder sb3 = new StringBuilder();
sb3.append(str10);
sb3.append("&eurl=");
sb3.append(URLEncoder.encode("https://youtube.googleapis.com/v/" + this.a, com.batch.android.core.a.a));
str10 = sb3.toString();
} catch (Exception e) {
FileLog.e(e);
}
if (q0 != null) {
Matcher matcher = m9.o0.matcher(q0);
if (matcher.find()) {
str10 = str10 + "&sts=" + q0.substring(matcher.start() + 6, matcher.end());
} else {
str10 = str10 + "&sts=";
}
}
char c = 1;
this.c[1] = "dash";
int i2 = 5;
char c2 = 0;
int i3 = 2;
String[] strArr3 = {BuildConfig.FLAVOR, "&el=leanback", "&el=embedded", "&el=detailpage", "&el=vevo"};
String str11 = null;
boolean z4 = false;
int i4 = 0;
while (i4 < i2) {
String q02 = m9.this.q0(this, "https://www.youtube.com/get_video_info?" + str10 + strArr3[i4]);
if (isCancelled()) {
return strArr2;
}
if (q02 != null) {
String[] split = q02.split("&");
boolean z5 = z4;
Object obj = strArr2;
int i5 = 0;
z2 = false;
z3 = false;
while (i5 < split.length) {
if (split[i5].startsWith("dashmpd")) {
String[] split2 = split[i5].split("=");
if (split2.length == i3) {
try {
this.c[c2] = URLDecoder.decode(split2[c], com.batch.android.core.a.a);
} catch (Exception e2) {
FileLog.e(e2);
}
}
str9 = str10;
z3 = true;
} else if (split[i5].startsWith("url_encoded_fmt_stream_map")) {
String[] split3 = split[i5].split("=");
if (split3.length == i3) {
try {
String[] split4 = URLDecoder.decode(split3[c], com.batch.android.core.a.a).split("[&,]");
String str12 = null;
int i6 = 0;
boolean z6 = false;
while (i6 < split4.length) {
String[] split5 = split4[i6].split("=");
String[] strArr4 = split4;
str9 = str10;
try {
if (split5[0].startsWith("type")) {
if (URLDecoder.decode(split5[1], com.batch.android.core.a.a).contains("video/mp4")) {
z6 = true;
}
} else if (split5[0].startsWith("url")) {
str12 = URLDecoder.decode(split5[1], com.batch.android.core.a.a);
} else if (split5[0].startsWith("itag")) {
str12 = null;
z6 = false;
}
if (z6 && str12 != null) {
str11 = str12;
break;
}
i6++;
split4 = strArr4;
str10 = str9;
} catch (Exception e3) {
e = e3;
FileLog.e(e);
i5++;
str10 = str9;
c = 1;
c2 = 0;
i3 = 2;
}
}
} catch (Exception e4) {
e = e4;
str9 = str10;
}
}
str9 = str10;
} else {
str9 = str10;
if (split[i5].startsWith("use_cipher_signature")) {
String[] split6 = split[i5].split("=");
if (split6.length == 2 && split6[1].toLowerCase().equals("true")) {
z5 = true;
}
} else if (split[i5].startsWith("hlsvp")) {
String[] split7 = split[i5].split("=");
if (split7.length == 2) {
obj = URLDecoder.decode(split7[1], com.batch.android.core.a.a);
}
} else if (split[i5].startsWith("livestream")) {
String[] split8 = split[i5].split("=");
if (split8.length == 2 && split8[1].toLowerCase().equals("1")) {
z2 = true;
}
}
}
i5++;
str10 = str9;
c = 1;
c2 = 0;
i3 = 2;
}
str7 = str10;
z4 = z5;
str8 = obj;
} else {
str7 = str10;
str8 = 0;
z2 = false;
z3 = false;
}
if (z2) {
if (str8 == 0 || z4 || str8.contains("/s/")) {
return null;
}
String[] strArr5 = this.c;
strArr5[0] = str8;
strArr5[1] = "hls";
}
if (z3) {
break;
}
i4++;
str10 = str7;
strArr2 = null;
i2 = 5;
c = 1;
c2 = 0;
i3 = 2;
}
String[] strArr6 = this.c;
if (strArr6[0] == null && str11 != null) {
strArr6[0] = str11;
strArr6[1] = "other";
}
if (strArr6[0] == null || (!(z4 || strArr6[0].contains("/s/")) || q0 == null)) {
strArr = null;
z = z4;
} else {
int indexOf = this.c[0].indexOf("/s/");
int indexOf2 = this.c[0].indexOf(47, indexOf + 10);
if (indexOf != -1) {
if (indexOf2 == -1) {
indexOf2 = this.c[0].length();
}
this.d = this.c[0].substring(indexOf, indexOf2);
Matcher matcher2 = m9.p0.matcher(q0);
if (matcher2.find()) {
try {
Object nextValue = new JSONTokener(matcher2.group(1)).nextValue();
str = nextValue instanceof String ? (String) nextValue : null;
} catch (Exception e5) {
FileLog.e(e5);
}
if (str != null) {
Matcher matcher3 = m9.v0.matcher(str);
if (matcher3.find()) {
str2 = matcher3.group(1) + matcher3.group(2);
} else {
str2 = null;
}
SharedPreferences sharedPreferences = ApplicationLoader.applicationContext.getSharedPreferences("youtubecode", 0);
if (str2 != null) {
str3 = sharedPreferences.getString(str2, null);
str4 = sharedPreferences.getString(str2 + "n", null);
} else {
str3 = null;
str4 = null;
}
if (str3 == null) {
if (str.startsWith("//")) {
sb2 = new StringBuilder();
str6 = "https:";
} else {
if (str.startsWith("/")) {
sb2 = new StringBuilder();
str6 = "https://www.youtube.com";
}
String q03 = m9.this.q0(this, str);
if (!isCancelled()) {
return null;
}
strArr = null;
if (q03 != null) {
Matcher matcher4 = m9.q0.matcher(q03);
if (matcher4.find()) {
i = 1;
} else {
i = 1;
matcher4 = m9.r0.matcher(q03);
}
str4 = matcher4.group(i);
if (str4 != null) {
try {
str3 = new j(q03).c(str4);
if (!TextUtils.isEmpty(str3) && str2 != null) {
sharedPreferences.edit().putString(str2, str3).putString(str2 + "n", str4).commit();
}
} catch (Exception e6) {
FileLog.e(e6);
}
}
if (!TextUtils.isEmpty(str3)) {
if (Build.VERSION.SDK_INT >= 21) {
sb = new StringBuilder();
sb.append(str3);
sb.append(str4);
sb.append("('");
sb.append(this.d.substring(3));
str5 = "');";
} else {
sb = new StringBuilder();
sb.append(str3);
sb.append("window.");
sb.append(m9.this.c);
sb.append(".returnResultToJava(");
sb.append(str4);
sb.append("('");
sb.append(this.d.substring(3));
str5 = "'));";
}
sb.append(str5);
final String sb4 = sb.toString();
try {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
m9.p.this.f(sb4);
}
});
this.b.await();
z = false;
} catch (Exception e7) {
FileLog.e(e7);
}
}
z = true;
}
}
sb2.append(str6);
sb2.append(str);
str = sb2.toString();
String q032 = m9.this.q0(this, str);
if (!isCancelled()) {
}
} else {
strArr = null;
}
if (!TextUtils.isEmpty(str3)) {
}
z = true;
}
}
str = null;
if (str != null) {
}
}
strArr = null;
z = true;
}
return (isCancelled() || z) ? strArr : this.c;
}
@Override
public void onPostExecute(String[] strArr) {
if (strArr[0] == null) {
if (isCancelled()) {
return;
}
m9.this.G0();
return;
}
if (BuildVars.LOGS_ENABLED) {
FileLog.d("start play youtube video " + strArr[1] + " " + strArr[0]);
}
m9.this.m = true;
m9.this.n = strArr[0];
m9.this.o = strArr[1];
if (m9.this.o.equals("hls")) {
m9.this.s = true;
}
if (m9.this.k) {
m9.this.I0();
}
m9.this.J0(false, true);
m9.this.b0.j(true, true);
}
}
@SuppressLint({"SetJavaScriptEnabled", "AddJavascriptInterface"})
public m9(Context context, boolean z, boolean z2, o oVar) {
super(context);
f0++;
this.t = Build.VERSION.SDK_INT >= 21;
this.B = new Paint();
this.c0 = new a();
this.d0 = new b();
this.e0 = new c();
setWillNotDraw(false);
this.l = oVar;
this.B.setColor(com.batch.android.messaging.view.roundimage.b.v);
d dVar = new d(context);
this.d = dVar;
addView(dVar, g52.c(-1, -1, 17));
this.c = "JavaScriptInterface";
WebView webView = new WebView(context);
this.b = webView;
webView.addJavascriptInterface(new k(new g() {
@Override
public final void a(String str) {
org.telegram.ui.Components.m9.this.z0(str);
}
}), this.c);
WebSettings settings = this.b.getSettings();
settings.setJavaScriptEnabled(true);
settings.setDefaultTextEncodingName("utf-8");
this.g = this.l.h();
TextureView textureView = new TextureView(context);
this.e = textureView;
textureView.setPivotX(0.0f);
this.e.setPivotY(0.0f);
ViewGroup viewGroup = this.g;
if (viewGroup != null) {
viewGroup.addView(this.e);
} else {
this.d.addView(this.e, g52.c(-1, -1, 17));
}
if (this.t && this.g != null) {
ImageView imageView = new ImageView(context);
this.f = imageView;
imageView.setBackgroundColor(-65536);
this.f.setPivotX(0.0f);
this.f.setPivotY(0.0f);
this.f.setVisibility(4);
this.g.addView(this.f);
}
e9 e9Var = new e9();
this.a = e9Var;
e9Var.B0(this);
this.a.I0(this.e);
h hVar = new h(context);
this.b0 = hVar;
ViewGroup viewGroup2 = this.g;
if (viewGroup2 != null) {
viewGroup2.addView(hVar);
} else {
addView(hVar, g52.a(-1, -1.0f));
}
RadialProgressView radialProgressView = new RadialProgressView(context);
this.S = radialProgressView;
radialProgressView.setProgressColor(-1);
addView(this.S, g52.c(48, 48, 17));
ImageView imageView2 = new ImageView(context);
this.T = imageView2;
imageView2.setScaleType(ImageView.ScaleType.CENTER);
this.b0.addView(this.T, g52.b(56, 56.0f, 85, 0.0f, 0.0f, 0.0f, 5.0f));
this.T.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
org.telegram.ui.Components.m9.this.A0(view);
}
});
ImageView imageView3 = new ImageView(context);
this.U = imageView3;
imageView3.setScaleType(ImageView.ScaleType.CENTER);
this.b0.addView(this.U, g52.c(48, 48, 17));
this.U.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
org.telegram.ui.Components.m9.this.B0(view);
}
});
if (z) {
ImageView imageView4 = new ImageView(context);
this.V = imageView4;
imageView4.setScaleType(ImageView.ScaleType.CENTER);
this.b0.addView(this.V, g52.c(56, 48, 53));
this.V.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
org.telegram.ui.Components.m9.this.C0(view);
}
});
}
if (z2) {
ImageView imageView5 = new ImageView(context);
this.W = imageView5;
imageView5.setScaleType(ImageView.ScaleType.CENTER);
this.W.setImageResource(R.drawable.ic_share_video);
this.b0.addView(this.W, g52.c(56, 48, 53));
this.W.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
org.telegram.ui.Components.m9.this.D0(view);
}
});
}
N0();
K0();
M0();
O0();
}
public void A0(View view) {
if (!this.m || this.H || this.R || !this.x) {
return;
}
this.I = !this.I;
L0(true);
}
public void B0(View view) {
if (!this.m || this.n == null) {
return;
}
if (!this.a.r0()) {
I0();
}
if (this.a.s0()) {
this.a.u0();
} else {
this.Q = false;
this.a.v0();
}
N0();
}
public void C0(View view) {
if (this.e == null || !this.l.i() || this.H || this.R || !this.x) {
return;
}
this.R = true;
if (!this.J) {
this.I = false;
this.l.j(true, this.e0, this.d.getAspectRatio(), this.t);
return;
}
ViewGroup viewGroup = (ViewGroup) this.d.getParent();
if (viewGroup != this) {
if (viewGroup != null) {
viewGroup.removeView(this.d);
}
addView(this.d, 0, g52.c(-1, -1, 17));
this.d.measure(View.MeasureSpec.makeMeasureSpec(getMeasuredWidth(), 1073741824), View.MeasureSpec.makeMeasureSpec(getMeasuredHeight() - AndroidUtilities.dp(10.0f), 1073741824));
}
Bitmap bitmap = this.h;
if (bitmap != null) {
bitmap.recycle();
this.h = null;
}
this.H = true;
this.J = false;
N0();
O0();
K0();
M0();
this.e.setVisibility(4);
ViewGroup viewGroup2 = this.g;
if (viewGroup2 != null) {
viewGroup2.addView(this.e);
} else {
this.d.addView(this.e);
}
ViewGroup viewGroup3 = (ViewGroup) this.b0.getParent();
if (viewGroup3 != this) {
if (viewGroup3 != null) {
viewGroup3.removeView(this.b0);
}
ViewGroup viewGroup4 = this.g;
if (viewGroup4 != null) {
viewGroup4.addView(this.b0);
} else {
addView(this.b0, 1);
}
}
this.b0.j(false, false);
this.l.j(false, null, this.d.getAspectRatio(), this.t);
}
public void D0(View view) {
o oVar = this.l;
if (oVar != null) {
oVar.f();
}
}
public void E0(int i2) {
if (i2 == -1) {
if (this.a.s0()) {
this.a.u0();
N0();
}
this.u = false;
return;
}
if (i2 == 1) {
if (this.v) {
this.v = false;
this.a.v0();
return;
}
return;
}
if (i2 != -3 && i2 == -2 && this.a.s0()) {
this.v = true;
this.a.u0();
N0();
}
}
public void G0() {
if (this.b0.getParent() != this) {
this.b0.setVisibility(8);
}
this.l.d();
}
public void I0() {
String str = this.n;
if (str == null) {
return;
}
if (str == null || this.p == null) {
this.a.w0(Uri.parse(str), this.o);
} else {
this.a.x0(Uri.parse(str), this.o, Uri.parse(this.p), this.q);
}
this.a.E0(this.k);
long k02 = this.a.k0();
h hVar = this.b0;
if (k02 != -9223372036854775807L) {
hVar.h((int) (this.a.k0() / 1000));
} else {
hVar.h(0);
}
K0();
O0();
M0();
this.b0.invalidate();
if (this.z != -1) {
this.a.z0(r0 * 1000);
}
}
public void J0(boolean z, boolean z2) {
if (!z2) {
this.S.setAlpha(z ? 1.0f : 0.0f);
return;
}
AnimatorSet animatorSet = this.a0;
if (animatorSet != null) {
animatorSet.cancel();
}
AnimatorSet animatorSet2 = new AnimatorSet();
this.a0 = animatorSet2;
Animator[] animatorArr = new Animator[1];
RadialProgressView radialProgressView = this.S;
float[] fArr = new float[1];
fArr[0] = z ? 1.0f : 0.0f;
animatorArr[0] = ObjectAnimator.ofFloat(radialProgressView, "alpha", fArr);
animatorSet2.playTogether(animatorArr);
this.a0.setDuration(150L);
this.a0.addListener(new e());
this.a0.start();
}
public void K0() {
ImageView imageView;
int i2;
float f2;
int i3;
float f3;
float f4;
float f5;
float f6;
if (!this.a.r0() || this.J) {
this.T.setVisibility(8);
return;
}
this.T.setVisibility(0);
if (this.I) {
this.T.setImageResource(R.drawable.ic_outfullscreen);
imageView = this.T;
i2 = 56;
f2 = 56.0f;
i3 = 85;
f3 = 0.0f;
f4 = 0.0f;
f5 = 0.0f;
f6 = 1.0f;
} else {
this.T.setImageResource(R.drawable.ic_gofullscreen);
imageView = this.T;
i2 = 56;
f2 = 56.0f;
i3 = 85;
f3 = 0.0f;
f4 = 0.0f;
f5 = 0.0f;
f6 = 5.0f;
}
imageView.setLayoutParams(g52.b(i2, f2, i3, f3, f4, f5, f6));
}
private void L0(boolean z) {
ViewGroup viewGroup;
if (this.e == null) {
return;
}
K0();
ViewGroup viewGroup2 = this.g;
if (viewGroup2 != null) {
if (this.I) {
ViewGroup viewGroup3 = (ViewGroup) this.d.getParent();
if (viewGroup3 != null) {
viewGroup3.removeView(this.d);
}
} else {
ViewGroup viewGroup4 = (ViewGroup) this.d.getParent();
if (viewGroup4 != this) {
if (viewGroup4 != null) {
viewGroup4.removeView(this.d);
}
addView(this.d, 0);
}
}
this.l.a(this.b0, this.I, this.d.getAspectRatio(), this.d.getVideoRotation(), z);
return;
}
this.H = true;
if (!this.I) {
if (viewGroup2 != null) {
viewGroup2.addView(this.e);
} else {
this.d.addView(this.e);
}
}
if (this.I) {
ViewGroup viewGroup5 = (ViewGroup) this.b0.getParent();
if (viewGroup5 != null) {
viewGroup5.removeView(this.b0);
}
} else {
ViewGroup viewGroup6 = (ViewGroup) this.b0.getParent();
if (viewGroup6 != this) {
if (viewGroup6 != null) {
viewGroup6.removeView(this.b0);
}
ViewGroup viewGroup7 = this.g;
if (viewGroup7 != null) {
viewGroup7.addView(this.b0);
} else {
addView(this.b0, 1);
}
}
}
TextureView a2 = this.l.a(this.b0, this.I, this.d.getAspectRatio(), this.d.getVideoRotation(), z);
this.i = a2;
a2.setVisibility(4);
if (this.I && this.i != null && (viewGroup = (ViewGroup) this.e.getParent()) != null) {
viewGroup.removeView(this.e);
}
this.b0.e();
}
public void M0() {
ImageView imageView;
FrameLayout.LayoutParams c2;
ImageView imageView2 = this.V;
if (imageView2 == null) {
return;
}
imageView2.setImageResource(this.J ? R.drawable.ic_goinline : R.drawable.ic_outinline);
this.V.setVisibility(this.a.r0() ? 0 : 8);
if (this.J) {
imageView = this.V;
c2 = g52.c(40, 40, 53);
} else {
imageView = this.V;
c2 = g52.c(56, 50, 53);
}
imageView.setLayoutParams(c2);
}
public void N0() {
ImageView imageView;
int i2;
this.b0.e();
AndroidUtilities.cancelRunOnUIThread(this.c0);
if (this.a.s0()) {
this.U.setImageResource(this.J ? R.drawable.ic_pauseinline : R.drawable.ic_pause);
AndroidUtilities.runOnUIThread(this.c0, 500L);
o0();
} else {
if (this.Q) {
imageView = this.U;
i2 = this.J ? R.drawable.ic_againinline : R.drawable.ic_again;
} else {
imageView = this.U;
i2 = this.J ? R.drawable.ic_playinline : R.drawable.ic_play;
}
imageView.setImageResource(i2);
}
}
public void O0() {
ImageView imageView = this.W;
if (imageView == null) {
return;
}
imageView.setVisibility((this.J || !this.a.r0()) ? 8 : 0);
}
static float d0(m9 m9Var, float f2) {
float f3 = m9Var.y - f2;
m9Var.y = f3;
return f3;
}
private View getControlView() {
return this.b0;
}
private View getProgressView() {
return this.S;
}
private void o0() {
if (this.u) {
return;
}
AudioManager audioManager = (AudioManager) ApplicationLoader.applicationContext.getSystemService(MediaStreamTrack.AUDIO_TRACK_KIND);
this.u = true;
audioManager.requestAudioFocus(this, 3, 1);
}
public static String v0(String str) {
Matcher matcher = g0.matcher(str);
if (matcher.find()) {
return matcher.group(1);
}
return null;
}
public void z0(String str) {
AsyncTask asyncTask = this.G;
if (asyncTask == null || asyncTask.isCancelled()) {
return;
}
AsyncTask asyncTask2 = this.G;
if (asyncTask2 instanceof p) {
((p) asyncTask2).g(str);
}
}
public boolean F0(String str, pc5 pc5Var, Object obj, String str2, boolean z) {
String str3;
String str4;
String str5;
String str6;
String str7;
String str8;
AsyncTask asyncTask;
AnimatorSet animatorSet;
AsyncTask fVar;
String u02 = u0(str);
if (u02 == null) {
u02 = u0(str2);
}
this.z = -1;
if (u02 != null || str == null) {
str3 = null;
str4 = null;
} else {
if (!str.endsWith(".mp4")) {
try {
if (str2 != null) {
try {
Uri parse = Uri.parse(str2);
String queryParameter = parse.getQueryParameter("t");
if (queryParameter == null) {
queryParameter = parse.getQueryParameter("time_continue");
}
if (queryParameter != null) {
if (queryParameter.contains("m")) {
String[] split = queryParameter.split("m");
this.z = (Utilities.parseInt(split[0]).intValue() * 60) + Utilities.parseInt(split[1]).intValue();
} else {
this.z = Utilities.parseInt(queryParameter).intValue();
}
}
} catch (Exception e2) {
FileLog.e(e2);
}
}
Matcher matcher = g0.matcher(str);
String group = matcher.find() ? matcher.group(1) : null;
if (group == null) {
group = null;
}
str4 = group;
} catch (Exception e3) {
FileLog.e(e3);
str4 = null;
}
if (str4 == null) {
try {
Matcher matcher2 = h0.matcher(str);
String group2 = matcher2.find() ? matcher2.group(3) : null;
if (group2 == null) {
group2 = null;
}
str8 = group2;
} catch (Exception e4) {
FileLog.e(e4);
}
if (str8 == null) {
try {
Matcher matcher3 = j0.matcher(str);
String group3 = matcher3.find() ? matcher3.group(1) : null;
if (group3 == null) {
group3 = null;
}
str7 = group3;
} catch (Exception e5) {
FileLog.e(e5);
}
if (str7 == null) {
try {
Matcher matcher4 = k0.matcher(str);
String group4 = matcher4.find() ? matcher4.group(1) : null;
if (group4 == null) {
group4 = null;
}
str6 = group4;
} catch (Exception e6) {
FileLog.e(e6);
}
if (str6 == null) {
try {
Matcher matcher5 = l0.matcher(str);
String group5 = matcher5.find() ? matcher5.group(1) : null;
if (group5 == null) {
group5 = null;
}
str5 = group5;
} catch (Exception e7) {
FileLog.e(e7);
}
if (str5 == null) {
try {
Matcher matcher6 = i0.matcher(str);
String group6 = matcher6.find() ? matcher6.group(1) : null;
if (group6 != null) {
u02 = group6;
}
} catch (Exception e8) {
FileLog.e(e8);
}
}
str3 = null;
this.m = false;
this.Q = false;
this.k = z;
this.n = null;
this.p = null;
p0();
this.x = false;
this.y = 1.0f;
asyncTask = this.G;
if (asyncTask != null) {
asyncTask.cancel(true);
this.G = null;
}
K0();
O0();
M0();
N0();
if (pc5Var == null) {
qc5 closestPhotoSizeWithSize = FileLoader.getClosestPhotoSizeWithSize(pc5Var.g, 80, true);
if (closestPhotoSizeWithSize != null) {
this.b0.a.setImage(null, null, ImageLocation.getForPhoto(closestPhotoSizeWithSize, pc5Var), "80_80_b", 0, null, obj, 1);
this.A = true;
}
} else {
this.A = false;
}
animatorSet = this.a0;
if (animatorSet != null) {
animatorSet.cancel();
this.a0 = null;
}
this.b0.i(0);
if (str4 != null) {
this.r = str4;
str4 = null;
}
if (str3 == null) {
this.m = true;
this.n = str3;
this.o = "other";
if (this.k) {
I0();
}
J0(false, false);
this.b0.j(true, true);
} else {
if (str4 != null) {
fVar = new p(str4);
fVar.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, null, null, null);
} else if (str8 != null) {
fVar = new n(str8);
fVar.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, null, null, null);
} else {
if (u02 != null) {
i iVar = new i(u02);
iVar.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, null, null, null);
this.G = iVar;
} else if (str7 != null) {
fVar = new f(str7);
fVar.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, null, null, null);
} else {
if (str6 != null) {
l lVar = new l(str, str6);
lVar.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, null, null, null);
this.G = lVar;
} else if (str5 != null) {
m mVar = new m(str, str5);
mVar.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, null, null, null);
this.G = mVar;
}
this.b0.j(false, false);
J0(true, false);
}
this.s = true;
this.b0.j(false, false);
J0(true, false);
}
this.G = fVar;
this.b0.j(false, false);
J0(true, false);
}
if (str4 != null && str8 == null && u02 == null && str7 == null && str3 == null && str6 == null && str5 == null) {
this.b0.setVisibility(8);
return false;
}
this.b0.setVisibility(0);
return true;
}
str5 = null;
if (str5 == null) {
}
str3 = null;
this.m = false;
this.Q = false;
this.k = z;
this.n = null;
this.p = null;
p0();
this.x = false;
this.y = 1.0f;
asyncTask = this.G;
if (asyncTask != null) {
}
K0();
O0();
M0();
N0();
if (pc5Var == null) {
}
animatorSet = this.a0;
if (animatorSet != null) {
}
this.b0.i(0);
if (str4 != null) {
}
if (str3 == null) {
}
if (str4 != null) {
}
this.b0.setVisibility(0);
return true;
}
str6 = null;
if (str6 == null) {
}
str5 = null;
if (str5 == null) {
}
str3 = null;
this.m = false;
this.Q = false;
this.k = z;
this.n = null;
this.p = null;
p0();
this.x = false;
this.y = 1.0f;
asyncTask = this.G;
if (asyncTask != null) {
}
K0();
O0();
M0();
N0();
if (pc5Var == null) {
}
animatorSet = this.a0;
if (animatorSet != null) {
}
this.b0.i(0);
if (str4 != null) {
}
if (str3 == null) {
}
if (str4 != null) {
}
this.b0.setVisibility(0);
return true;
}
str7 = null;
if (str7 == null) {
}
str6 = null;
if (str6 == null) {
}
str5 = null;
if (str5 == null) {
}
str3 = null;
this.m = false;
this.Q = false;
this.k = z;
this.n = null;
this.p = null;
p0();
this.x = false;
this.y = 1.0f;
asyncTask = this.G;
if (asyncTask != null) {
}
K0();
O0();
M0();
N0();
if (pc5Var == null) {
}
animatorSet = this.a0;
if (animatorSet != null) {
}
this.b0.i(0);
if (str4 != null) {
}
if (str3 == null) {
}
if (str4 != null) {
}
this.b0.setVisibility(0);
return true;
}
str8 = null;
if (str8 == null) {
}
str7 = null;
if (str7 == null) {
}
str6 = null;
if (str6 == null) {
}
str5 = null;
if (str5 == null) {
}
str3 = null;
this.m = false;
this.Q = false;
this.k = z;
this.n = null;
this.p = null;
p0();
this.x = false;
this.y = 1.0f;
asyncTask = this.G;
if (asyncTask != null) {
}
K0();
O0();
M0();
N0();
if (pc5Var == null) {
}
animatorSet = this.a0;
if (animatorSet != null) {
}
this.b0.i(0);
if (str4 != null) {
}
if (str3 == null) {
}
if (str4 != null) {
}
this.b0.setVisibility(0);
return true;
}
str3 = str;
str4 = null;
}
str8 = str4;
str7 = str8;
str6 = str7;
str5 = str6;
this.m = false;
this.Q = false;
this.k = z;
this.n = null;
this.p = null;
p0();
this.x = false;
this.y = 1.0f;
asyncTask = this.G;
if (asyncTask != null) {
}
K0();
O0();
M0();
N0();
if (pc5Var == null) {
}
animatorSet = this.a0;
if (animatorSet != null) {
}
this.b0.i(0);
if (str4 != null) {
}
if (str3 == null) {
}
if (str4 != null) {
}
this.b0.setVisibility(0);
return true;
}
public void H0() {
this.a.u0();
N0();
this.b0.j(true, true);
}
public void P0() {
if (this.f == null) {
return;
}
try {
Bitmap createBitmap = Bitmaps.createBitmap(this.e.getWidth(), this.e.getHeight(), Bitmap.Config.ARGB_8888);
this.h = createBitmap;
this.i.getBitmap(createBitmap);
} catch (Throwable th) {
Bitmap bitmap = this.h;
if (bitmap != null) {
bitmap.recycle();
this.h = null;
}
FileLog.e(th);
}
if (this.h == null) {
this.f.setImageDrawable(null);
} else {
this.f.setVisibility(0);
this.f.setImageBitmap(this.h);
}
}
public void Q0() {
this.b0.setVisibility(4);
this.b0.j(false, false);
J0(true, false);
}
public View getAspectRatioView() {
return this.d;
}
public View getControlsView() {
return this.b0;
}
public ImageView getTextureImageView() {
return this.f;
}
public TextureView getTextureView() {
return this.e;
}
public String getYoutubeId() {
return this.r;
}
public boolean n0(String str) {
if (str == null) {
return false;
}
if (str.endsWith(".mp4")) {
return true;
}
try {
Matcher matcher = g0.matcher(str);
if ((matcher.find() ? matcher.group(1) : null) != null) {
return true;
}
} catch (Exception e2) {
FileLog.e(e2);
}
try {
Matcher matcher2 = h0.matcher(str);
if ((matcher2.find() ? matcher2.group(3) : null) != null) {
return true;
}
} catch (Exception e3) {
FileLog.e(e3);
}
try {
Matcher matcher3 = j0.matcher(str);
if ((matcher3.find() ? matcher3.group(1) : null) != null) {
return true;
}
} catch (Exception e4) {
FileLog.e(e4);
}
try {
Matcher matcher4 = k0.matcher(str);
if ((matcher4.find() ? matcher4.group(1) : null) != null) {
return true;
}
} catch (Exception e5) {
FileLog.e(e5);
}
try {
Matcher matcher5 = l0.matcher(str);
if ((matcher5.find() ? matcher5.group(1) : null) != null) {
return true;
}
} catch (Exception e6) {
FileLog.e(e6);
}
try {
Matcher matcher6 = i0.matcher(str);
return (matcher6.find() ? matcher6.group(1) : null) != null;
} catch (Exception e7) {
FileLog.e(e7);
return false;
}
}
@Override
public void onAudioFocusChange(final int i2) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
org.telegram.ui.Components.m9.this.E0(i2);
}
});
}
@Override
protected void onDraw(Canvas canvas) {
canvas.drawRect(0.0f, 0.0f, getMeasuredWidth(), getMeasuredHeight() - AndroidUtilities.dp(10.0f), this.B);
}
@Override
public void onError(e9 e9Var, Exception exc) {
FileLog.e(exc);
G0();
}
@Override
protected void onLayout(boolean z, int i2, int i3, int i4, int i5) {
int i6 = i4 - i2;
int measuredWidth = (i6 - this.d.getMeasuredWidth()) / 2;
int i7 = i5 - i3;
int dp = ((i7 - AndroidUtilities.dp(10.0f)) - this.d.getMeasuredHeight()) / 2;
tb tbVar = this.d;
tbVar.layout(measuredWidth, dp, tbVar.getMeasuredWidth() + measuredWidth, this.d.getMeasuredHeight() + dp);
if (this.b0.getParent() == this) {
h hVar = this.b0;
hVar.layout(0, 0, hVar.getMeasuredWidth(), this.b0.getMeasuredHeight());
}
int measuredWidth2 = (i6 - this.S.getMeasuredWidth()) / 2;
int measuredHeight = (i7 - this.S.getMeasuredHeight()) / 2;
RadialProgressView radialProgressView = this.S;
radialProgressView.layout(measuredWidth2, measuredHeight, radialProgressView.getMeasuredWidth() + measuredWidth2, this.S.getMeasuredHeight() + measuredHeight);
this.b0.a.setImageCoords(0.0f, 0.0f, getMeasuredWidth(), getMeasuredHeight() - AndroidUtilities.dp(10.0f));
}
@Override
protected void onMeasure(int i2, int i3) {
int size = View.MeasureSpec.getSize(i2);
int size2 = View.MeasureSpec.getSize(i3);
this.d.measure(View.MeasureSpec.makeMeasureSpec(size, 1073741824), View.MeasureSpec.makeMeasureSpec(size2 - AndroidUtilities.dp(10.0f), 1073741824));
if (this.b0.getParent() == this) {
this.b0.measure(View.MeasureSpec.makeMeasureSpec(size, 1073741824), View.MeasureSpec.makeMeasureSpec(size2, 1073741824));
}
this.S.measure(View.MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(44.0f), 1073741824), View.MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(44.0f), 1073741824));
setMeasuredDimension(size, size2);
}
@Override
public void onRenderedFirstFrame() {
this.x = true;
this.w = System.currentTimeMillis();
this.b0.invalidate();
}
@Override
public void onRenderedFirstFrame(a8.a aVar) {
wo7.a(this, aVar);
}
@Override
public void onSeekFinished(a8.a aVar) {
wo7.b(this, aVar);
}
@Override
public void onSeekStarted(a8.a aVar) {
wo7.c(this, aVar);
}
@Override
public void onStateChanged(boolean z, int i2) {
if (i2 != 2) {
long k02 = this.a.k0();
h hVar = this.b0;
if (k02 != -9223372036854775807L) {
hVar.h((int) (this.a.k0() / 1000));
} else {
hVar.h(0);
}
}
if (i2 == 4 || i2 == 1 || !this.a.s0()) {
this.l.e(this, false);
} else {
this.l.e(this, true);
}
if (this.a.s0() && i2 != 4) {
N0();
return;
}
if (i2 == 4) {
this.Q = true;
this.a.u0();
this.a.z0(0L);
N0();
this.b0.j(true, true);
}
}
@Override
public boolean onSurfaceDestroyed(SurfaceTexture surfaceTexture) {
if (this.H) {
this.H = false;
if (this.I || this.J) {
if (this.J) {
this.j = 1;
}
this.i.setSurfaceTexture(surfaceTexture);
this.i.setSurfaceTextureListener(this.d0);
this.i.setVisibility(0);
return true;
}
}
return false;
}
@Override
public void onSurfaceTextureUpdated(SurfaceTexture surfaceTexture) {
if (this.j == 2) {
ImageView imageView = this.f;
if (imageView != null) {
imageView.setVisibility(4);
this.f.setImageDrawable(null);
Bitmap bitmap = this.h;
if (bitmap != null) {
bitmap.recycle();
this.h = null;
}
}
this.R = false;
this.l.g(this.b0, false, this.d.getAspectRatio(), this.d.getVideoRotation(), this.t);
this.j = 0;
}
}
@Override
public void onVideoSizeChanged(int i2, int i3, int i4, float f2) {
tb tbVar = this.d;
if (tbVar != null) {
if (i4 != 90 && i4 != 270) {
i3 = i2;
i2 = i3;
}
float f3 = i2 == 0 ? 1.0f : (i3 * f2) / i2;
tbVar.c(f3, i4);
if (this.I) {
this.l.c(f3, i4);
}
}
}
public void p0() {
this.a.y0(false);
AsyncTask asyncTask = this.G;
if (asyncTask != null) {
asyncTask.cancel(true);
this.G = null;
}
this.b.stopLoading();
}
protected String q0(AsyncTask asyncTask, String str) {
return r0(asyncTask, str, null, true);
}
protected String r0(AsyncTask asyncTask, String str, HashMap<String, String> hashMap, boolean z) {
URLConnection uRLConnection;
boolean z2;
InputStream inputStream;
StringBuilder sb;
boolean z3;
URL url;
InputStream gZIPInputStream;
boolean z4 = true;
try {
url = new URL(str);
uRLConnection = url.openConnection();
try {
uRLConnection.addRequestProperty("User-Agent", "Mozilla/5.0 (X11; Linux x86_64; rv:10.0) Gecko/20150101 Firefox/47.0 (Chrome)");
if (z) {
uRLConnection.addRequestProperty("Accept-Encoding", "gzip, deflate");
}
uRLConnection.addRequestProperty("Accept-Language", "en-us,en;q=0.5");
uRLConnection.addRequestProperty("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
uRLConnection.addRequestProperty("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7");
if (hashMap != null) {
for (Map.Entry<String, String> entry : hashMap.entrySet()) {
uRLConnection.addRequestProperty(entry.getKey(), entry.getValue());
}
}
uRLConnection.setConnectTimeout(5000);
uRLConnection.setReadTimeout(5000);
if (uRLConnection instanceof HttpURLConnection) {
HttpURLConnection httpURLConnection = (HttpURLConnection) uRLConnection;
httpURLConnection.setInstanceFollowRedirects(true);
int responseCode = httpURLConnection.getResponseCode();
if (responseCode == 302 || responseCode == 301 || responseCode == 303) {
String headerField = httpURLConnection.getHeaderField("Location");
String headerField2 = httpURLConnection.getHeaderField("Set-Cookie");
url = new URL(headerField);
uRLConnection = url.openConnection();
uRLConnection.setRequestProperty("Cookie", headerField2);
uRLConnection.addRequestProperty("User-Agent", "Mozilla/5.0 (X11; Linux x86_64; rv:10.0) Gecko/20150101 Firefox/47.0 (Chrome)");
if (z) {
uRLConnection.addRequestProperty("Accept-Encoding", "gzip, deflate");
}
uRLConnection.addRequestProperty("Accept-Language", "en-us,en;q=0.5");
uRLConnection.addRequestProperty("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
uRLConnection.addRequestProperty("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7");
if (hashMap != null) {
for (Map.Entry<String, String> entry2 : hashMap.entrySet()) {
uRLConnection.addRequestProperty(entry2.getKey(), entry2.getValue());
}
}
}
}
uRLConnection.connect();
} catch (Throwable th) {
th = th;
boolean z5 = !(th instanceof SocketTimeoutException) ? !(!(th instanceof UnknownHostException) && (!(th instanceof SocketException) ? (th instanceof FileNotFoundException) : !(th.getMessage() == null || !th.getMessage().contains("ECONNRESET")))) : ApplicationLoader.isNetworkOnline();
FileLog.e(th);
z2 = z5;
inputStream = null;
if (z2) {
}
if (z3) {
}
}
} catch (Throwable th2) {
th = th2;
uRLConnection = null;
}
if (z) {
try {
gZIPInputStream = new GZIPInputStream(uRLConnection.getInputStream());
} catch (Exception unused) {
uRLConnection = url.openConnection();
uRLConnection.connect();
}
inputStream = gZIPInputStream;
z2 = true;
if (z2) {
try {
if (uRLConnection instanceof HttpURLConnection) {
((HttpURLConnection) uRLConnection).getResponseCode();
}
} catch (Exception e2) {
FileLog.e(e2);
}
if (inputStream != null) {
try {
byte[] bArr = new byte[32768];
sb = null;
while (true) {
try {
if (asyncTask.isCancelled()) {
break;
}
try {
int read = inputStream.read(bArr);
if (read > 0) {
if (sb == null) {
sb = new StringBuilder();
}
try {
try {
sb.append(new String(bArr, 0, read, StandardCharsets.UTF_8));
} catch (Throwable th3) {
th = th3;
FileLog.e(th);
z3 = false;
if (inputStream != null) {
}
if (z3) {
}
}
} catch (Exception e3) {
e = e3;
FileLog.e(e);
z4 = false;
z3 = z4;
if (inputStream != null) {
}
if (z3) {
}
}
}
} catch (Exception e4) {
e = e4;
}
} catch (Throwable th4) {
th = th4;
}
}
z3 = z4;
} catch (Throwable th5) {
th = th5;
sb = null;
}
if (inputStream != null) {
try {
inputStream.close();
} catch (Throwable th6) {
FileLog.e(th6);
}
}
} else {
sb = null;
}
z3 = false;
if (inputStream != null) {
}
} else {
sb = null;
z3 = false;
}
if (z3) {
return sb.toString();
}
return null;
}
gZIPInputStream = uRLConnection.getInputStream();
inputStream = gZIPInputStream;
z2 = true;
if (z2) {
}
if (z3) {
}
}
public void s0() {
if (this.I) {
return;
}
this.I = true;
M0();
L0(false);
}
public void t0() {
if (this.I) {
this.I = false;
M0();
L0(false);
}
}
public String u0(String str) {
String group;
if (TextUtils.isEmpty(str)) {
return null;
}
try {
Matcher matcher = i0.matcher(str);
group = matcher.find() ? matcher.group(1) : null;
} catch (Exception e2) {
FileLog.e(e2);
}
if (group != null) {
return group;
}
return null;
}
public boolean w0() {
return this.I;
}
public boolean x0() {
return this.m;
}
public boolean y0() {
return this.J || this.R;
}
}