package com.mbridge.msdk.mbjscommon.confirmation; import android.content.Context; import android.text.TextUtils; 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.widget.custom.baseview.MBButton; import java.lang.reflect.InvocationTargetException; /* compiled from: NativeProgressController */ public final class d { MBButton a; private int b; private int c; private int d; private String e; private String f; private int g; private int h; private IDownloadListener i; public d(MBButton mBButton) { this.a = mBButton; c(); } public final void a(int i2) { this.d = i2; if (this.c == 2) { c(1); } } private void c(final int i2) { this.b = i2; if (this.h == 1 || i2 == 0) { this.a.post(new Runnable() { /* class com.mbridge.msdk.mbjscommon.confirmation.d.AnonymousClass1 */ public final void run() { int i = i2; if (i == 1) { d.b(d.this); } else if (i == 2) { d dVar = d.this; if (dVar.a != null) { dVar.a.setText(q.a(dVar.a.getContext(), "mbridge_cm_progress_status_descri_pause", TypedValues.Custom.S_STRING)); } } else if (i == 3) { d dVar2 = d.this; if (dVar2.a != null) { dVar2.a.setProgress(100); try { Context context = dVar2.a.getContext(); dVar2.a.setText(context.getResources().getString(q.a(context, "mbridge_cm_progress_status_descri_ins", TypedValues.Custom.S_STRING))); } catch (Exception e) { e.printStackTrace(); } } } else if (i != 4) { d.a(d.this); } else { d dVar3 = d.this; if (dVar3.a != null) { dVar3.a.setProgress(100); try { Context context2 = dVar3.a.getContext(); dVar3.a.setText(context2.getResources().getString(q.a(context2, "mbridge_cm_progress_status_descri_open", TypedValues.Custom.S_STRING))); } catch (Exception e2) { e2.printStackTrace(); } } } } }); } } public final void b(int i2) { this.g = i2; } public final void a(String str) { this.f = str; c(); } public final void b(String str) { if (TextUtils.isEmpty(str)) { return; } if ("1".equals(ag.a(str, "ctaldtype"))) { this.h = 1; if (!TextUtils.isEmpty(this.f)) { this.a.setProgress(50); } if (this.i == null) { this.i = new IDownloadListener() { /* class com.mbridge.msdk.mbjscommon.confirmation.d.AnonymousClass3 */ @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) { d.this.a(i); } @Override // com.mbridge.msdk.out.IDownloadListener public final void onStatus(int i) { if (d.this.c != i) { d.this.c = i; d.this.d((d) i); } } }; } if (!TextUtils.isEmpty(this.f)) { 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.f, this.i); } catch (ClassNotFoundException e2) { e2.printStackTrace(); } catch (NoSuchMethodException e3) { e3.printStackTrace(); } catch (IllegalAccessException e4) { e4.printStackTrace(); } catch (InvocationTargetException e5) { e5.printStackTrace(); } } } else { this.h = 0; } } public final void a() { if (this.g == 3) { c(); if (this.b == 2 && !TextUtils.isEmpty(this.f)) { try { String b2 = e.a(i.a(this.a.getContext())).b(this.f); 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.f, b2); } catch (ClassNotFoundException e2) { e2.printStackTrace(); } catch (NoSuchMethodException e3) { e3.printStackTrace(); } catch (IllegalAccessException e4) { e4.printStackTrace(); } catch (InvocationTargetException e5) { e5.printStackTrace(); } } } } private void c() { d(d()); } /* access modifiers changed from: private */ /* access modifiers changed from: public */ private void d(int i2) { if (i2 == -1) { this.b = 0; } else if (i2 == 9) { this.b = 4; } else if (i2 == 1) { this.b = 3; } else if (i2 == 2) { this.b = 1; } else if (i2 == 3) { this.b = 0; } else if (i2 == 5 || i2 == 6) { this.b = 2; } c(this.b); } private int d() { if (!TextUtils.isEmpty(this.f)) { 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.f)).intValue(); } catch (ClassNotFoundException e2) { e2.printStackTrace(); } catch (NoSuchMethodException e3) { e3.printStackTrace(); } catch (IllegalAccessException e4) { e4.printStackTrace(); } catch (InvocationTargetException e5) { e5.printStackTrace(); } } return -1; } public final void b() { if (!TextUtils.isEmpty(this.f)) { 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.f, this.i); this.i = null; } catch (ClassNotFoundException e2) { e2.printStackTrace(); } catch (NoSuchMethodException e3) { e3.printStackTrace(); } catch (IllegalAccessException e4) { e4.printStackTrace(); } catch (InvocationTargetException e5) { e5.printStackTrace(); } } } static /* synthetic */ void a(d dVar) { if (dVar.a == null) { return; } if (TextUtils.isEmpty(dVar.e)) { MBButton mBButton = dVar.a; mBButton.setText(q.a(mBButton.getContext(), "mbridge_cm_progress_status_descri_default", TypedValues.Custom.S_STRING)); return; } dVar.a.setText(dVar.e); } static /* synthetic */ void b(d dVar) { MBButton mBButton = dVar.a; if (mBButton != null) { mBButton.setIndeterminateProgressMode(false); dVar.a.post(new Runnable() { /* class com.mbridge.msdk.mbjscommon.confirmation.d.AnonymousClass2 */ public final void run() { d.this.a.setProgress(d.this.d); } }); if (dVar.d == 100) { try { Context context = dVar.a.getContext(); dVar.a.setText(context.getResources().getString(q.a(context, "mbridge_cm_progress_status_descri_ins", TypedValues.Custom.S_STRING))); } catch (Exception e2) { e2.printStackTrace(); } } } } }