package com.ss.android.ugc.aweme.base.component;

import X.0CB;
import X.0CH;
import X.1hK;
import X.1hT;
import X.2GO;
import X.2HZ;
import X.2kf;
import X.3GT;
import X.3af;
import X.3jJ;
import X.B9U;
import X.F2X;
import X.F5Q;
import X.F7A;
import X.F7B;
import X.F7C;
import X.FNE;
import X.ISm;
import X.LnP;
import X.Rc9;
import X.SfZ;
import android.app.Activity;
import android.os.Build;
import android.text.TextUtils;
import android.widget.Toast;
import com.bytedance.covode.number.Covode;
import com.ss.android.ugc.aweme.component.music.MusicService;
import com.ss.android.ugc.aweme.main.TabChangeManager;
import com.ss.android.ugc.aweme.out.AVExternalServiceImpl;
import com.ss.android.ugc.aweme.port.internal.MainActivityCallback;
import com.ss.android.ugc.aweme.shortvideo.publish.CreateAwemeResponse;
import java.lang.ref.WeakReference;
import java.util.HashMap;
import java.util.Map;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.ThreadMode;

public class EventActivityComponent implements 1hT, 2HZ, 2GO {
    public static F2X LIZJ;
    public static boolean LJ;
    public F7C LIZ;
    public 1hK LIZIZ;
    public WeakReference<B9U> LIZLLL;

    static {
        Covode.recordClassIndex(54205);
    }

    public Map<Integer, Object> getSubscriberEventTypes() {
        HashMap hashMap = new HashMap();
        hashMap.put(72, new Rc9(EventActivityComponent.class, "onNotificationRetry", F7B.class, ThreadMode.POSTING, 0, true));
        hashMap.put(73, new Rc9(EventActivityComponent.class, "onPublishStatus", F5Q.class, ThreadMode.POSTING, -1, true));
        return hashMap;
    }

    /* renamed from: com.ss.android.ugc.aweme.base.component.EventActivityComponent$1  reason: invalid class name */
    public static /* synthetic */ class AnonymousClass1 {
        public static final /* synthetic */ int[] LIZ;

        /* JADX WARNING: Can't wrap try/catch for region: R(10:0|1|2|3|4|5|6|7|8|10) */
        /* JADX WARNING: Can't wrap try/catch for region: R(8:0|1|2|3|4|5|6|(3:7|8|10)) */
        /* JADX WARNING: Failed to process nested try/catch */
        /* JADX WARNING: Missing exception handler attribute for start block: B:3:0x0018 */
        /* JADX WARNING: Missing exception handler attribute for start block: B:5:0x0023 */
        /* JADX WARNING: Missing exception handler attribute for start block: B:7:0x002e */
        static {
            /*
                r0 = 54206(0xd3be, float:7.5959E-41)
                com.bytedance.covode.number.Covode.recordClassIndex(r0)
                X.0CB[] r0 = X.0CB.values()
                int r0 = r0.length
                int[] r2 = new int[r0]
                LIZ = r2
                X.0CB r0 = X.0CB.ON_CREATE     // Catch:{ NoSuchFieldError -> 0x0018 }
                int r1 = r0.ordinal()     // Catch:{ NoSuchFieldError -> 0x0018 }
                r0 = 1
                r2[r1] = r0     // Catch:{ NoSuchFieldError -> 0x0018 }
            L_0x0018:
                int[] r2 = LIZ     // Catch:{ NoSuchFieldError -> 0x0023 }
                X.0CB r0 = X.0CB.ON_RESUME     // Catch:{ NoSuchFieldError -> 0x0023 }
                int r1 = r0.ordinal()     // Catch:{ NoSuchFieldError -> 0x0023 }
                r0 = 2
                r2[r1] = r0     // Catch:{ NoSuchFieldError -> 0x0023 }
            L_0x0023:
                int[] r2 = LIZ     // Catch:{ NoSuchFieldError -> 0x002e }
                X.0CB r0 = X.0CB.ON_PAUSE     // Catch:{ NoSuchFieldError -> 0x002e }
                int r1 = r0.ordinal()     // Catch:{ NoSuchFieldError -> 0x002e }
                r0 = 3
                r2[r1] = r0     // Catch:{ NoSuchFieldError -> 0x002e }
            L_0x002e:
                int[] r2 = LIZ     // Catch:{ NoSuchFieldError -> 0x0039 }
                X.0CB r0 = X.0CB.ON_DESTROY     // Catch:{ NoSuchFieldError -> 0x0039 }
                int r1 = r0.ordinal()     // Catch:{ NoSuchFieldError -> 0x0039 }
                r0 = 4
                r2[r1] = r0     // Catch:{ NoSuchFieldError -> 0x0039 }
            L_0x0039:
                return
            */
            throw new UnsupportedOperationException("Method not decompiled: com.ss.android.ugc.aweme.base.component.EventActivityComponent.AnonymousClass1.<clinit>():void");
        }
    }

    public EventActivityComponent(1hK r1) {
        this.LIZIZ = r1;
    }

    public final void LIZ(1hK r3) {
        3af r1 = new 3af(r3);
        r1.LJ(2131833067);
        3af.LIZ(r1);
    }

    public final String LIZ(Activity activity) {
        String str;
        1hK LIZIZ2 = 3jJ.LIZIZ(activity);
        if (LIZIZ2 == null || (str = TabChangeManager.LJII.LIZ(LIZIZ2).LIZLLL) == null) {
            return "";
        }
        return str;
    }

    @ISm(LIZIZ = true)
    public void onNotificationRetry(F7B f7b) {
        if (MainActivityCallback.LIZ(this.LIZIZ)) {
            new MainActivityCallback(this.LIZIZ, f7b.LIZ, true);
            EventBus.LIZ().LJFF(f7b);
        }
    }

    @ISm(LIZIZ = true, LIZJ = -1)
    public void onPublishStatus(F5Q f5q) {
        Activity activity = this.LIZIZ;
        if (activity != null && LnP.LIZ(activity)) {
            LJ = false;
            if (f5q.LIZIZ == 12) {
                if (activity == SfZ.LJIJ.LJIIIZ()) {
                    3af r1 = new 3af(this.LIZIZ);
                    r1.LJ(2131825156);
                    3af.LIZ(r1);
                }
                2kf.LIZ(new Exception(f5q.toString()));
            } else if (f5q.LIZIZ == 9) {
                if (activity == SfZ.LJIJ.LJIIIZ() && f5q.LJIIJJI) {
                    String str = f5q.LJ;
                    if (TextUtils.isEmpty(str)) {
                        str = activity.getResources().getString(2131831158);
                    }
                    Toast makeText = Toast.makeText(this.LIZIZ, str, 1);
                    if (Build.VERSION.SDK_INT == 25) {
                        3GT.LIZ(makeText);
                    }
                    makeText.show();
                }
                2kf.LIZ(new Exception(f5q.toString()));
            } else if (f5q.LIZIZ == 10 && !f5q.LJIIJ) {
                F7A f7a = new F7A(this, f5q, activity);
                FNE fne = f5q.LJII;
                if (!(fne instanceof CreateAwemeResponse) || ((CreateAwemeResponse) fne).couponInfo == null) {
                    f7a.run();
                } else {
                    MusicService.LJIJ().LJIIIIZZ();
                }
            }
            AVExternalServiceImpl.LIZ().publishService().setPublishStatus(f5q.LIZIZ);
        }
    }

    public void onStateChanged(0CH r3, 0CB r4) {
        F7C f7c;
        int i = AnonymousClass1.LIZ[r4.ordinal()];
        if (i != 1) {
            if (i == 2) {
                EventBus.LIZ(EventBus.LIZ(), this);
            } else if (i == 3) {
                EventBus.LIZ().LIZIZ(this);
            } else if (i == 4 && (f7c = this.LIZ) != null) {
                f7c.LIZJ();
            }
        } else if (this.LIZIZ instanceof B9U) {
            this.LIZLLL = new WeakReference<>(this.LIZIZ);
        }
    }
}
