package com.bytedance.android.livesdk.utils.crop;

import X.0AA;
import X.0c0;
import X.2Pr;
import X.C1044Fun;
import X.C1189Fx8;
import X.C4272HDt;
import X.C4273HDu;
import X.C4274HDv;
import X.C6314Hxb;
import X.GSF;
import X.LsC;
import X.M12;
import android.content.DialogInterface;
import android.net.Uri;
import android.os.Bundle;
import android.os.SystemClock;
import android.view.View;
import android.widget.ImageView;
import androidx.fragment.app.Fragment;
import com.bytedance.android.livesdk.LiveDialogFragment;
import com.bytedance.covode.number.Covode;
import com.bytedance.ies.sdk.datachannel.DataChannel;
import java.util.HashMap;

public final class CropFragment extends LiveDialogFragment {
    public static final C4273HDu LIZIZ = new C4273HDu((byte) 0);
    public LsC<? super String, 2Pr> LIZ;
    public Uri LIZJ;
    public String LIZLLL;
    public long LJ = Long.MIN_VALUE;
    public HashMap LJFF;

    static {
        Covode.recordClassIndex(21502);
    }

    public final View LIZ(int i) {
        if (this.LJFF == null) {
            this.LJFF = new HashMap();
        }
        View view = (View) this.LJFF.get(Integer.valueOf(i));
        if (view != null) {
            return view;
        }
        View view2 = getView();
        if (view2 == null) {
            return null;
        }
        View findViewById = view2.findViewById(i);
        this.LJFF.put(Integer.valueOf(i), findViewById);
        return findViewById;
    }

    public final /* synthetic */ void onDestroyView() {
        super.onDestroyView();
        z_();
    }

    public final void z_() {
        HashMap hashMap = this.LJFF;
        if (hashMap != null) {
            hashMap.clear();
        }
    }

    public final C1044Fun LIZ() {
        C1044Fun fun = new C1044Fun(2131561740);
        fun.LJIIIIZZ = -1;
        return fun;
    }

    public final void onResume() {
        CropFragment.super.onResume();
        if (this.LJ != Long.MIN_VALUE) {
            0c0.LIZ("ttlive_crop_fragment_all", 0, SystemClock.elapsedRealtime() - this.LJ);
            this.LJ = Long.MIN_VALUE;
        }
    }

    public final void LIZ(LsC<? super String, 2Pr> lsC) {
        M12.LIZ(lsC);
        this.LIZ = lsC;
    }

    public final void onDismiss(DialogInterface dialogInterface) {
        super.onDismiss(dialogInterface);
        DataChannel LIZ2 = GSF.LIZ((Fragment) this);
        if (LIZ2 != null) {
            LIZ2.LIZIZ(C1189Fx8.class, true);
        }
    }

    public final void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        DataChannel LIZ2 = GSF.LIZ((Fragment) this);
        if (LIZ2 != null) {
            LIZ2.LIZIZ(C1189Fx8.class, false);
        }
        Bundle arguments = getArguments();
        if (arguments != null) {
            this.LIZJ = (Uri) arguments.getParcelable("arg_origin_uri");
            this.LIZLLL = arguments.getString("arg_origin_path");
        }
    }

    public final void show(0AA r3, String str) {
        M12.LIZ(r3, str);
        this.LJ = SystemClock.elapsedRealtime();
        super.show(r3, str);
    }

    public final void onViewCreated(View view, Bundle bundle) {
        M12.LIZ(view);
        super.onViewCreated(view, bundle);
        C6314Hxb hxb = (C6314Hxb) LIZ(2131363847);
        String str = this.LIZLLL;
        if (str != null) {
            hxb.setOriginPath(str);
        } else {
            hxb.setOriginUri(this.LIZJ);
        }
        ((ImageView) LIZ(2131371830)).setOnClickListener(new C4274HDv(this));
        ((ImageView) LIZ(2131371871)).setOnClickListener(new C4272HDt(this));
    }
}
