翰林优商.apk(点击下载) / MBDownloadProgressBar.java
package com.mbridge.msdk.widget;
import android.content.Context;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.constraintlayout.core.motion.utils.TypedValues;
import com.mbridge.msdk.foundation.db.e;
import com.mbridge.msdk.foundation.db.i;
import com.mbridge.msdk.foundation.tools.ag;
import com.mbridge.msdk.foundation.tools.q;
import com.mbridge.msdk.out.IDownloadListener;
import com.mbridge.msdk.playercommon.exoplayer2.text.ttml.TtmlNode;
import java.lang.reflect.InvocationTargetException;
public class MBDownloadProgressBar extends RelativeLayout {
public static final int PROGRESS_STATUS_DEFAULT = 0;
public static final int PROGRESS_STATUS_DOING = 1;
public static final int PROGRESS_STATUS_INT = 3;
public static final int PROGRESS_STATUS_OPEN = 4;
public static final int PROGRESS_STATUS_PAUSE = 2;
private int a;
private int b;
private int c;
private ProgressBar d;
private ImageView e;
private TextView f;
private String g;
private String h;
private int i;
private int j;
private IDownloadListener k;
public MBDownloadProgressBar(Context context) {
this(context, null);
}
public MBDownloadProgressBar(Context context, AttributeSet attributeSet) {
this(context, attributeSet, 0);
}
public MBDownloadProgressBar(Context context, AttributeSet attributeSet, int i2) {
super(context, attributeSet, i2);
ViewGroup viewGroup = (ViewGroup) LayoutInflater.from(context).inflate(q.a(context, "mbridge_same_download_progress_bar_layout", TtmlNode.TAG_LAYOUT), (ViewGroup) null);
addView(viewGroup);
this.d = (ProgressBar) viewGroup.findViewById(q.a(context, "mbridge_same_download_mbprogress_progress", "id"));
this.e = (ImageView) viewGroup.findViewById(q.a(context, "mbridge_same_download_mbprogress_status_icon", "id"));
this.f = (TextView) viewGroup.findViewById(q.a(context, "mbridge_same_download_mbprogress_status_desc", "id"));
b();
}
/* access modifiers changed from: protected */
public void onAttachedToWindow() {
super.onAttachedToWindow();
if (this.a != 0 && this.j == 1) {
e();
}
}
/* access modifiers changed from: protected */
public void onDetachedFromWindow() {
super.onDetachedFromWindow();
if (!TextUtils.isEmpty(this.h)) {
try {
Class<?> cls = Class.forName("com.mbridge.msdk.mbdownload.manager.ADownloadManager");
Object invoke = cls.getMethod("getInstance", new Class[0]).invoke(null, new Object[0]);
cls.getMethod("deleteDownloadListener", String.class, IDownloadListener.class).invoke(invoke, this.h, this.k);
this.k = null;
} catch (ClassNotFoundException e2) {
e2.printStackTrace();
} catch (NoSuchMethodException e3) {
e3.printStackTrace();
} catch (IllegalAccessException e4) {
e4.printStackTrace();
} catch (InvocationTargetException e5) {
e5.printStackTrace();
}
}
}
public void setProgress(int i2) {
this.c = i2;
if (this.b == 2) {
a(1);
}
}
private void a(final int i2) {
this.a = i2;
if (this.j == 1 || i2 == 0) {
post(new Runnable() {
/* class com.mbridge.msdk.widget.MBDownloadProgressBar.AnonymousClass1 */
public final void run() {
int i = i2;
if (i == 1) {
MBDownloadProgressBar.b(MBDownloadProgressBar.this);
} else if (i == 2) {
MBDownloadProgressBar.c(MBDownloadProgressBar.this);
} else if (i == 3) {
MBDownloadProgressBar.d(MBDownloadProgressBar.this);
} else if (i != 4) {
MBDownloadProgressBar.this.a();
} else {
MBDownloadProgressBar.e(MBDownloadProgressBar.this);
}
}
});
}
}
/* access modifiers changed from: private */
/* access modifiers changed from: public */
private void a() {
ImageView imageView = this.e;
if (!(imageView == null || imageView.getVisibility() == 8)) {
this.e.setVisibility(8);
}
ProgressBar progressBar = this.d;
if (progressBar != null) {
progressBar.setProgress(0);
}
if (this.f == null) {
return;
}
if (TextUtils.isEmpty(this.g)) {
this.f.setText(q.a(getContext(), "mbridge_cm_progress_status_descri_default", TypedValues.Custom.S_STRING));
} else {
this.f.setText(this.g);
}
}
public int getmStatus() {
return this.a;
}
public void setText(String str) {
this.g = str;
a();
}
public void setTextSize(float f2) {
this.f.setTextSize(f2);
}
public void setLinkType(int i2) {
this.i = i2;
}
public void setUniqueKey(String str) {
this.h = str;
b();
}
public void setCtaldtypeUrl(String str) {
if (TextUtils.isEmpty(str)) {
return;
}
if ("1".equals(ag.a(str, "ctaldtype"))) {
this.j = 1;
e();
return;
}
this.j = 0;
}
public boolean NotProgressBarInterceptedClick() {
if (this.i == 3) {
b();
if (this.a == 2) {
c();
}
}
return true;
}
public boolean performClick() {
if (this.i == 3) {
e();
b();
if (this.a == 2) {
c();
}
}
return super.performClick();
}
private void b() {
b(d());
}
/* access modifiers changed from: private */
/* access modifiers changed from: public */
private void b(int i2) {
if (i2 == -1) {
this.a = 0;
} else if (i2 == 9) {
this.a = 4;
} else if (i2 == 1) {
this.a = 3;
} else if (i2 == 2) {
this.a = 1;
} else if (i2 == 3) {
this.a = 0;
} else if (i2 == 5 || i2 == 6) {
this.a = 2;
}
a(this.a);
}
private void c() {
if (!TextUtils.isEmpty(this.h)) {
try {
String b2 = e.a(i.a(getContext())).b(this.h);
Class<?> cls = Class.forName("com.mbridge.msdk.mbdownload.manager.ADownloadManager");
Object invoke = cls.getMethod("getInstance", new Class[0]).invoke(null, new Object[0]);
cls.getMethod("start", String.class, String.class).invoke(invoke, this.h, b2);
} catch (ClassNotFoundException e2) {
e2.printStackTrace();
} catch (NoSuchMethodException e3) {
e3.printStackTrace();
} catch (IllegalAccessException e4) {
e4.printStackTrace();
} catch (InvocationTargetException e5) {
e5.printStackTrace();
}
}
}
private int d() {
if (!TextUtils.isEmpty(this.h)) {
try {
Class<?> cls = Class.forName("com.mbridge.msdk.mbdownload.manager.ADownloadManager");
Object invoke = cls.getMethod("getInstance", new Class[0]).invoke(null, new Object[0]);
return ((Integer) cls.getMethod("getTaskStatusByUniqueKey", String.class).invoke(invoke, this.h)).intValue();
} catch (ClassNotFoundException e2) {
e2.printStackTrace();
} catch (NoSuchMethodException e3) {
e3.printStackTrace();
} catch (IllegalAccessException e4) {
e4.printStackTrace();
} catch (InvocationTargetException e5) {
e5.printStackTrace();
}
}
return -1;
}
private void e() {
if (this.k == null) {
this.k = new IDownloadListener() {
/* class com.mbridge.msdk.widget.MBDownloadProgressBar.AnonymousClass2 */
@Override // com.mbridge.msdk.out.IDownloadListener
public final void onEnd(int i, int i2, String str) {
}
@Override // com.mbridge.msdk.out.IDownloadListener
public final void onStart() {
}
@Override // com.mbridge.msdk.out.IDownloadListener
public final void onProgressUpdate(int i) {
MBDownloadProgressBar.this.setProgress(i);
}
@Override // com.mbridge.msdk.out.IDownloadListener
public final void onStatus(int i) {
if (MBDownloadProgressBar.this.b != i) {
MBDownloadProgressBar.this.b = i;
MBDownloadProgressBar.this.b((MBDownloadProgressBar) i);
}
}
};
f();
}
}
private void f() {
if (!TextUtils.isEmpty(this.h)) {
try {
Class<?> cls = Class.forName("com.mbridge.msdk.mbdownload.manager.ADownloadManager");
Object invoke = cls.getMethod("getInstance", new Class[0]).invoke(null, new Object[0]);
cls.getMethod("addDownloadListener", String.class, IDownloadListener.class).invoke(invoke, this.h, this.k);
} catch (ClassNotFoundException e2) {
e2.printStackTrace();
} catch (NoSuchMethodException e3) {
e3.printStackTrace();
} catch (IllegalAccessException e4) {
e4.printStackTrace();
} catch (InvocationTargetException e5) {
e5.printStackTrace();
}
}
}
static /* synthetic */ void b(MBDownloadProgressBar mBDownloadProgressBar) {
ImageView imageView = mBDownloadProgressBar.e;
if (!(imageView == null || imageView.getVisibility() == 0)) {
mBDownloadProgressBar.e.setVisibility(0);
}
ProgressBar progressBar = mBDownloadProgressBar.d;
if (progressBar != null) {
progressBar.setProgress(mBDownloadProgressBar.c);
}
TextView textView = mBDownloadProgressBar.f;
if (textView != null) {
textView.setText(mBDownloadProgressBar.c + "%");
}
}
static /* synthetic */ void c(MBDownloadProgressBar mBDownloadProgressBar) {
ImageView imageView = mBDownloadProgressBar.e;
if (!(imageView == null || imageView.getVisibility() == 0)) {
mBDownloadProgressBar.e.setVisibility(0);
}
TextView textView = mBDownloadProgressBar.f;
if (textView != null) {
textView.setText(q.a(mBDownloadProgressBar.getContext(), "mbridge_cm_progress_status_descri_pause", TypedValues.Custom.S_STRING));
}
}
static /* synthetic */ void d(MBDownloadProgressBar mBDownloadProgressBar) {
ImageView imageView = mBDownloadProgressBar.e;
if (!(imageView == null || imageView.getVisibility() == 8)) {
mBDownloadProgressBar.e.setVisibility(8);
}
ProgressBar progressBar = mBDownloadProgressBar.d;
if (progressBar != null) {
progressBar.setProgress(100);
}
TextView textView = mBDownloadProgressBar.f;
if (textView != null) {
textView.setText(q.a(mBDownloadProgressBar.getContext(), "mbridge_cm_progress_status_descri_ins", TypedValues.Custom.S_STRING));
}
}
static /* synthetic */ void e(MBDownloadProgressBar mBDownloadProgressBar) {
ImageView imageView = mBDownloadProgressBar.e;
if (!(imageView == null || imageView.getVisibility() == 8)) {
mBDownloadProgressBar.e.setVisibility(8);
}
ProgressBar progressBar = mBDownloadProgressBar.d;
if (progressBar != null) {
progressBar.setProgress(100);
}
TextView textView = mBDownloadProgressBar.f;
if (textView != null) {
textView.setText(q.a(mBDownloadProgressBar.getContext(), "mbridge_cm_progress_status_descri_open", TypedValues.Custom.S_STRING));
}
}
}